-
-
Notifications
You must be signed in to change notification settings - Fork 442
Description
There has been an update to OpenJDK 8 Java that breaks the launch of minecraft with the runClient gradle task. In GradleStart there is a hackNatives function that hacks the Java library path to include Minecraft's native libraries. This code depends on inner workings of how Java loads native libraries. This behavior has recently changed to only load library paths on JVM startup.
How it used to work:
- GradleStart sets
sys_pathstonulland adds the minecraft natives directory tojava.library.pathproperty at start of the task. - Minecraft boots and tries to load the
awtsystem library. - The java
ClassLoaderchecks ifsys_pathsis null, which istrue, and then re-initializes the library paths. - Library
awtis loaded normally and boot continues.
Behavior after Java update:
- GradleStart sets
sys_pathstonulland adds the minecraft natives directory tojava.library.pathproperty at start of the task. - Minecraft boots and tries to load the
awtsystem library. - The java
ClassLoaderdoes not check ifsys_pathsis null, and crashes with a NullPointerException.
Exception log:
[17:01:09] [main/ERROR] [LaunchWrapper]: Unable to launch
java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_242]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_242]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_242]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_242]
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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_242]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_242]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_242]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_242]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:25) [start/:?]
Caused by: java.lang.ExceptionInInitializerError
at org.lwjgl.LinuxSysImplementation.<clinit>(LinuxSysImplementation.java:50) ~[lwjgl-2.9.4-nightly-20150209.jar:?]
at org.lwjgl.Sys.createImplementation(Sys.java:131) ~[lwjgl-2.9.4-nightly-20150209.jar:?]
at org.lwjgl.Sys.<clinit>(Sys.java:116) ~[lwjgl-2.9.4-nightly-20150209.jar:?]
at net.minecraft.client.Minecraft.getSystemTime(Minecraft.java:3159) ~[Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:42) ~[Main.class:?]
... 12 more
Caused by: java.lang.NullPointerException
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1847) ~[?:1.8.0_242]
at java.lang.Runtime.loadLibrary0(Runtime.java:871) ~[?:1.8.0_242]
at java.lang.System.loadLibrary(System.java:1124) ~[?:1.8.0_242]
at java.awt.Toolkit$3.run(Toolkit.java:1636) ~[?:1.8.0_242]
at java.awt.Toolkit$3.run(Toolkit.java:1634) ~[?:1.8.0_242]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_242]
at java.awt.Toolkit.loadLibraries(Toolkit.java:1633) ~[?:1.8.0_242]
at java.awt.Toolkit.<clinit>(Toolkit.java:1670) ~[?:1.8.0_242]
Exception in thread "main" at org.lwjgl.LinuxSysImplementation.<clinit>(LinuxSysImplementation.java:50) ~[lwjgl-2.9.4-nightly-20150209.jar:?]
at org.lwjgl.Sys.createImplementation(Sys.java:131) ~[lwjgl-2.9.4-nightly-20150209.jar:?]
at org.lwjgl.Sys.<clinit>(Sys.java:116) ~[lwjgl-2.9.4-nightly-20150209.jar:?]
at net.minecraft.client.Minecraft.getSystemTime(Minecraft.java:3159) ~[Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:42) ~[Main.class:?]
... 12 more
Full log: https://pastebin.com/jVYg2ZX8
ForgeGradle hack code:
| sysPathsField.set(null, null); |
OpenJDK 8u commit which changed the behavior: http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/rev/1d666f78532a/
Corresponding OpenJDK issue: https://bugs.openjdk.java.net/browse/JDK-8235886
Possible solution:
Change hack to be like Option 2 in this post: https://stackoverflow.com/questions/15409223/adding-new-paths-for-native-libraries-at-runtime-in-java/15409446#15409446