LinkageError: loader constraint violation

Версия Minecraft
1.13+
214
11
59
У меня есть наследник IClassTransformer, который хукает метод Minecraft.displayGuiScreen(GuiScreen). При загрузке класса GuiScreen я ловлю вот такое исключение:
CFI.class = Minecraft.class
CJS.class = GuiScreen.class
Java:
> ---- Minecraft Crash Report ----
[QUOTE] // You should try our sister game, Minceraft!

 Time: 08.09.19 10:52
 Description: Initializing game

 java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "cjs"
     at java.lang.ClassLoader.defineClass1(Native Method)
     at java.lang.ClassLoader.defineClass(Unknown Source)
     at java.security.SecureClassLoader.defineClass(Unknown Source)
     at java.net.URLClassLoader.defineClass(Unknown Source)
     at java.net.URLClassLoader.access$100(Unknown Source)
     at java.net.URLClassLoader$1.run(Unknown Source)
     at java.net.URLClassLoader$1.run(Unknown Source)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at java.lang.ClassLoader.defineClass1(Native Method)
     at java.lang.ClassLoader.defineClass(Unknown Source)
     at java.security.SecureClassLoader.defineClass(Unknown Source)
     at java.net.URLClassLoader.defineClass(Unknown Source)
     at java.net.URLClassLoader.access$100(Unknown Source)
     at java.net.URLClassLoader$1.run(Unknown Source)
     at java.net.URLClassLoader$1.run(Unknown Source)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at org.aaa.bbb.ccc.DDD.displayGuiScreen(DDD.java:13)
     at cfi.a(SourceFile)
     at cfi.am(SourceFile:458)
     at cfi.a(SourceFile:377)
     at net.minecraft.client.main.Main.main(SourceFile:144)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
     at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
[/QUOTE]
Покопался в интернетах, нашел причину, которая более вероятна для этой ситуации:
In the scenario, when a custom classloader does not query the parent hierarchy and decided to load the class itself, there might be case wherein the class being loaded is already loaded by some classloader in parent hierarchy.
В моем случае GuiScreen мог быть загружен как батя какого-нибудь GuiКласса.

Верны ли мои догадки ? И если так, то как мне обойти эту проблему ?
Если догадки не верны, то как быть тогда ?
 
7,099
324
1,510
Покажи код трансформера и вообще все, что около него
 
1,111
47
420
Parent hierarchy in this case is not about hierarchy of classes. Most of all class loaders have parent class loader. В обычной ситуации загрузчик-наследник сначала просит класс у загрузчика-родителя и, в случае если его нет, пытается подгрузить сам. В твоем случае загрузчик-наследник не спросил ничо у родителя в то время как родитель уже загрузил.
Как чинить хз, сильно от ситуации зависит, но вроде не рокет саенс.
 
Сверху