SpongePowered / Mixin

Mixin is a trait/mixin and bytecode weaving framework for Java using ASM
MIT License
1.43k stars 193 forks source link

java.lang.LinkageError: loader constraint violation: loader #235

Closed 0-x-2-2 closed 6 years ago

0-x-2-2 commented 6 years ago

This is super wierd it only happens on some mc versions but works fine on 1.8.9 and 1.12.2 and only happens if I override it from a interface.

Code that cause's this below.

@Mixin(Minecraft.class)
public abstract class MixinMinecraft implements IMixinMinecraft {

    @Accessor @Override public abstract void setSession(Session session);
}

public interface IMixinMinecraft {

    void setSession(Session session);
}

Error below.

[16:34:48] [main/WARN]: Reference map 'mixins.test.refmap.json' for mixins.test.json could not be read. If this is a development environment you can ignore this message
[16:34:48] [main/INFO]: Launching wrapped minecraft {net.minecraft.client.main.Main}
Exception in thread "main" [16:34:50] [main/ERROR]: Unable to launch
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_152]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_152]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_152]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_152]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
    at GradleStart.main(Unknown Source) [start/:?]
Caused by: java.lang.NoClassDefFoundError: net/minecraft/util/Session
    at net.minecraft.client.main.Main.main(Main.java:140) ~[Main.class:?]
    ... 8 more
Caused by: java.lang.ClassNotFoundException: net.minecraft.util.Session
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.12.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_152]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_152]
    at net.minecraft.client.main.Main.main(Main.java:140) ~[Main.class:?]
    ... 8 more
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of net/minecraft/launchwrapper/LaunchClassLoader) previously initiated loading for a different type with name "net/minecraft/util/Session"
    at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_152]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[?:1.8.0_152]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.8.0_152]
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182) ~[launchwrapper-1.12.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_152]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_152]
    at net.minecraft.client.main.Main.main(Main.java:140) ~[Main.class:?]
    ... 8 more
[16:34:50] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:748]: cpw.mods.fml.relauncher.FMLSecurityManager$ExitTrappedException
[16:34:50] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:748]:   at cpw.mods.fml.relauncher.FMLSecurityManager.checkPermission(FMLSecurityManager.java:25)
[16:34:50] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:748]:   at java.lang.SecurityManager.checkExit(SecurityManager.java:761)
[16:34:50] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:748]:   at java.lang.Runtime.exit(Runtime.java:107)
[16:34:50] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:748]:   at java.lang.System.exit(System.java:971)
[16:34:50] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:748]:   at net.minecraft.launchwrapper.Launch.launch(Launch.java:138)
[16:34:50] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:748]:   at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
[16:34:50] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:748]:   at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
[16:34:50] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:748]:   at GradleStart.main(Unknown Source)
Mumfrey commented 6 years ago

Can you please post the entire log. I am unable to reproduce this and wonder if I'm missing some piece of the puzzle.

0-x-2-2 commented 6 years ago

As I said this is really weird I believe it might be something todo with 1.7.10 (Modified ForgeGradle 2.1 so it works with 1.7.10 without crashing on setupDevEnv) anyways I found a solution that is hackery but it works for my little mod I'm making for some friends. It seems the error was caused by having a interface.

ryantheleach commented 6 years ago

@w-o-a-h i doubt it's relevent, but mind mentioning what the solution was?

0-x-2-2 commented 6 years ago

I did this instead,

@Mixin(Minecraft.class)
public abstract class MixinMinecraft implements IMixinMinecraft {

    @Accessor
    abstract void setSession(Session session);

    @Override
    public void setSessionWrapper(Session session) {
        this.setSession(sesson);
    }
}

public interface IMixinMinecraft {

    void setSessionWrapper(Session session);
}