Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassLoader loading order issue(?) #64

Closed
magneticflux- opened this issue Mar 31, 2021 · 17 comments
Closed

ClassLoader loading order issue(?) #64

magneticflux- opened this issue Mar 31, 2021 · 17 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@magneticflux-
Copy link
Owner

From CurseForge: https://www.curseforge.com/minecraft/mc-mods/mumble-link-fabric?comment=175

Log: https://pastebin.com/raw/UWz4ppgm

Stack trace:

java.lang.LinkageError: loader constraint violation: when resolving interface method "com.sun.jna.platform.win32.Kernel32.MapViewOfFile(Lcom/sun/jna/platform/win32/WinNT$HANDLE;IIII)Lcom/sun/jna/Pointer;" the class loader (instance of net/fabricmc/loader/launch/knot/KnotClassLoader) of the current class, com/skaggsm/mumblelinkmod/shaded/sharedmemory/win32/SharedMemoryWin32, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for the method's defining class, com/sun/jna/platform/win32/WinNT, have different Class objects for the type com/sun/jna/Pointer used in the signature
	at com.skaggsm.mumblelinkmod.shaded.sharedmemory.win32.SharedMemoryWin32.<init>(SharedMemoryWin32.java:30)
	at com.skaggsm.mumblelinkmod.shaded.sharedmemory.SharedMemory.getSharedMemory(SharedMemory.java:32)
	at com.skaggsm.mumblelinkmod.shaded.jmumblelink.MumbleLinkImpl.<init>(MumbleLinkImpl.java:16)
	at com.skaggsm.mumblelinkmod.ClientMumbleLinkMod.ensureLinked(ClientMumbleLinkMod.java:109)
	at com.skaggsm.mumblelinkmod.ClientMumbleLinkMod.access$ensureLinked(ClientMumbleLinkMod.java:35)
	at com.skaggsm.mumblelinkmod.ClientMumbleLinkMod$onInitializeClient$2.onStartTick(ClientMumbleLinkMod.java:68)
	at net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents.lambda$static$0(ClientTickEvents.java:43)
	at net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents$$Lambda$4989/1221502511.onStartTick(Unknown Source)
	at net.minecraft.class_310.handler$dne000$onStartTick(class_310.java:20381)
	at net.minecraft.class_310.method_1574(class_310.java)
	at net.minecraft.class_310.method_1523(class_310.java:1021)
	at net.minecraft.class_310.method_1514(class_310.java:681)
	at net.minecraft.client.main.Main.main(Main.java:215)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:226)
	at net.fabricmc.loader.launch.knot.Knot.launch(Knot.java:146)
	at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:28)
@magneticflux- magneticflux- added the bug Something isn't working label Mar 31, 2021
@magneticflux- magneticflux- self-assigned this Mar 31, 2021
@magneticflux-
Copy link
Owner Author

magneticflux- commented Apr 7, 2021

Additional stack trace from #66:

java.lang.LinkageError: loader constraint violation: when resolving interface method "com.sun.jna.platform.win32.Kernel32.MapViewOfFile(Lcom/sun/jna/platform/win32/WinNT$HANDLE;IIII)Lcom/sun/jna/Pointer;" the class loader (instance of net/fabricmc/loader/launch/knot/KnotClassLoader) of the current class, com/skaggsm/mumblelinkmod/shaded/sharedmemory/win32/SharedMemoryWin32, and the class loader (instance of java/net/URLClassLoader) for the method's defining class, com/sun/jna/platform/win32/WinNT, have different Class objects for the type com/sun/jna/Pointer used in the signature
	at com.skaggsm.mumblelinkmod.shaded.sharedmemory.win32.SharedMemoryWin32.<init>(SharedMemoryWin32.java:30)
	at com.skaggsm.mumblelinkmod.shaded.sharedmemory.SharedMemory.getSharedMemory(SharedMemory.java:32)
	at com.skaggsm.mumblelinkmod.shaded.jmumblelink.MumbleLinkImpl.<init>(MumbleLinkImpl.java:16)
	at com.skaggsm.mumblelinkmod.ClientMumbleLinkMod.ensureLinked(ClientMumbleLinkMod.java:109)
	at com.skaggsm.mumblelinkmod.ClientMumbleLinkMod.access$ensureLinked(ClientMumbleLinkMod.java:35)
	at com.skaggsm.mumblelinkmod.ClientMumbleLinkMod$onInitializeClient$2.onStartTick(ClientMumbleLinkMod.java:68)
	at net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents.lambda$static$0(ClientTickEvents.java:43)
	at net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents$$Lambda$5251/1706854837.onStartTick(Unknown Source)
	at net.minecraft.class_310.handler$ecb000$onStartTick(class_310.java:23381)
	at net.minecraft.class_310.method_1574(class_310.java)
	at net.minecraft.class_310.method_1523(class_310.java:1021)
	at net.minecraft.class_310.method_1514(class_310.java:681)
	at net.minecraft.client.main.Main.main(Main.java:215)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:226)
	at net.fabricmc.loader.launch.knot.Knot.launch(Knot.java:146)
	at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at link.infra.jumploader.Jumploader.onLoad(Jumploader.java:171)
	at cpw.mods.modlauncher.TransformationServiceDecorator.onLoad(TransformationServiceDecorator.java:53)
	at cpw.mods.modlauncher.TransformationServicesHandler.lambda$loadTransformationServices$11(TransformationServicesHandler.java:131)
	at cpw.mods.modlauncher.TransformationServicesHandler$$Lambda$58/1364913072.accept(Unknown Source)
	at java.util.HashMap$Values.forEach(HashMap.java:972)
	at cpw.mods.modlauncher.TransformationServicesHandler.loadTransformationServices(TransformationServicesHandler.java:131)
	at cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:56)
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:76)
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:66)

It seems like Jumploader may mess with the class loading order by injecting its own ClassLoader. More investigation is needed, I may be able to delay my class's loading until it works.

@StormPrime
Copy link

is it possible to use jumploader with it as I need to as it makes it easier with downloading the modpack

@magneticflux-
Copy link
Owner Author

Not currently. I do not use Jumploader, so I will need to debug using it specifically to figure out what goes wrong. This kind of class loading issue is interesting to me, so I'll probably have enough motivation to figure it out this week.

@StormPrime

This comment has been minimized.

@magneticflux-

This comment has been minimized.

@StormPrime

This comment has been minimized.

@StormPrime
Copy link

so it was still in for some reason but it still crashing https://pastebin.com/xDsXvYjy

@StormPrime
Copy link

im trying to find the mod but it might take a little to find the issue cuz i cant really read the logs and understand them

@StormPrime
Copy link

here my entire crash log i cant figure it out https://pastebin.com/09zPds1L

@magneticflux-
Copy link
Owner Author

Can you email me a zip of all of the mods you are using? I'd like to try to reproduce the issue in a controlled environment.

@NikkyAI
Copy link

NikkyAI commented Aug 16, 2021

i am encountering this issue as well, without jumploader, but with a lot of other mods, do you still need a pack to reproduce this?
the pack is for 1.16.5

@magneticflux-
Copy link
Owner Author

Yes please! If you can narrow down the mods before you send it that would be fantastic, but even just the pack is enough. This weird issue has persisted for so long and I'm excited to finally have a fresh lead to go on.

@NikkyAI
Copy link

NikkyAI commented Aug 16, 2021

see comment below

@NikkyAI
Copy link

NikkyAI commented Aug 16, 2021

i disabled almost all mods.. i think

https://paste.ee/p/gOOeA
down to disabling fabric-language-scala that fixes the issue

here i managed to open a world fine:
https://paste.ee/p/ibGaw

here is a pack to reproduce it
https://nikky.moe/.mc/test_mumblink.zip

@magneticflux-
Copy link
Owner Author

Got somewhere: scala-compiler depends on JNA (a newer version than Minecraft :rage1:). It was added in this commit: FabricMC/fabric-language-scala@1751ea7

The shadow task transitively includes dependencies, so the entirety of JNA is getting shadowed into fabric-language-scala. I think this warrants a backport of the library.

Looks like somebody beat me to the punch with the analysis: FabricMC/fabric-language-scala#17

@NikkyAI
Copy link

NikkyAI commented Aug 17, 2021

you might be able to shadow JNA and repackage it to avoid scala messing with it?

either way i hope the fix will be available for 1.16.5 too

@magneticflux-
Copy link
Owner Author

That would just delay the issue and cause more problems down the line.

To fix the issue right now, you could build a version of fabric-language-scala that doesn't shadow JNA and has a higher version number so Fabric would load it over the older bundled version.

Either way, it seems like the solution is to update fabric-language-scala since that's the mod that is incorrectly shadowing JNA. I'll close this issue since I don't think it's something I can address in this repository; check FabricMC/fabric-language-scala#17 for updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants