mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 00:37:52 +00:00
Fix NullPointerException on java 8u242 in dev environment. (#6473)
Java 8u242 no longer re-initializes internal sys_paths and usr_paths fields in loadLibrary when they are null, so the value can't be set to null.
This commit is contained in:
1 parent
e539e7ecbb
commit
4839d18c73
1 file changed
+7
-3
@@ -28,6 +28,7 @@ import cpw.mods.modlauncher.Launcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.Proxy;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
@@ -122,9 +123,12 @@ public class LaunchTesting
|
||||
// hack the classloader now.
|
||||
try
|
||||
{
|
||||
final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths");
|
||||
sysPathsField.setAccessible(true);
|
||||
sysPathsField.set(null, null);
|
||||
final Method initializePathMethod = ClassLoader.class.getDeclaredMethod("initializePath", String.class);
|
||||
initializePathMethod.setAccessible(true);
|
||||
final Object usrPathsValue = initializePathMethod.invoke(null, "java.library.path");
|
||||
final Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths");
|
||||
usrPathsField.setAccessible(true);
|
||||
usrPathsField.set(null, usrPathsValue);
|
||||
}
|
||||
catch(Throwable t) {}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user