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

Task runClient unable to launch in OpenJDK 8 for ForgeGradle 2.3 #652

Closed
milandamen opened this issue Feb 1, 2020 · 7 comments
Closed
Labels
forum Not an issue with ForgeGradle, see the forums won't fix Issue is not a real issue or not something worth fixing

Comments

@milandamen
Copy link

milandamen commented Feb 1, 2020

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:

  1. GradleStart sets sys_paths to null and adds the minecraft natives directory to java.library.path property at start of the task.
  2. Minecraft boots and tries to load the awt system library.
  3. The java ClassLoader checks if sys_paths is null, which is true, and then re-initializes the library paths.
  4. Library awt is loaded normally and boot continues.

Behavior after Java update:

  1. GradleStart sets sys_paths to null and adds the minecraft natives directory to java.library.path property at start of the task.
  2. Minecraft boots and tries to load the awt system library.
  3. The java ClassLoader does not check if sys_paths is 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

@Barteks2x
Copy link
Contributor

This is already fixed in 1.15.x, and FG2 is very unlikely to get updates anymore (because 1.12.2 is no longer supported). Especially since this only affects dev environment.

@DaemonUmbra DaemonUmbra added the won't fix Issue is not a real issue or not something worth fixing label Feb 1, 2020
@milandamen
Copy link
Author

@DaemonUmbra I guess that even if I made a pull request for this it would be denied?

@DaemonUmbra
Copy link
Member

Lex has actually asked anyone who's willing to do so, to get older versions working with FG3, so I would say that would be preferable

@LexManos
Copy link
Member

LexManos commented Feb 1, 2020

FG2 is dead due to its extreme age and hard reliance on old Gradles.
However, FG3 was specifically designed to work with ANY Minecraft version, as long as the data was there.
So if someone wishes to come along and PR to the old Forge branches to make them into FG3 workspaces, it'd be fine.

@FinnT730
Copy link

Maybe make a PR for this?

@DaemonUmbra
Copy link
Member

Adding Forum label to kill this as any effort should go towards FG3 rather than previous versions.

@DaemonUmbra DaemonUmbra added the forum Not an issue with ForgeGradle, see the forums label Mar 28, 2020
@support
Copy link

support bot commented Mar 28, 2020

👋 We use the issue tracker exclusively for final bug reports and feature requests. However, this issue appears to be better suited for the Forge Modder Support Forums. Please create a new topic on the Modder Support forum with this issue, and the conversation can continue there.

@support support bot locked as off-topic and limited conversation to collaborators Mar 28, 2020
@MinecraftForge MinecraftForge deleted a comment from draknyte1 Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
forum Not an issue with ForgeGradle, see the forums won't fix Issue is not a real issue or not something worth fixing
Projects
None yet
Development

No branches or pull requests

5 participants