[FIX] Запуск версий с vaargs в параметрах main метода

This commit is contained in:
Zaxar163 2019-06-14 13:27:31 +03:00
parent bbc48ec239
commit 8e6f1334e2

View file

@ -148,7 +148,6 @@ public void write(HOutput output) throws IOException {
} }
} }
private static final String[] EMPTY_ARRAY = new String[0];
private static final String SOCKET_HOST = "127.0.0.1"; private static final String SOCKET_HOST = "127.0.0.1";
private static final int SOCKET_PORT = Launcher.getConfig().clientPort; private static final int SOCKET_PORT = Launcher.getConfig().clientPort;
private static final String MAGICAL_INTEL_OPTION = "-XX:HeapDumpPath=ThisTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump"; private static final String MAGICAL_INTEL_OPTION = "-XX:HeapDumpPath=ThisTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump";
@ -277,18 +276,19 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl
Collection<String> args = new LinkedList<>(); Collection<String> args = new LinkedList<>();
if (profile.getVersion().compareTo(ClientProfile.Version.MC164) >= 0) if (profile.getVersion().compareTo(ClientProfile.Version.MC164) >= 0)
addClientArgs(args, profile, params); addClientArgs(args, profile, params);
else else {
addClientLegacyArgs(args, profile, params); addClientLegacyArgs(args, profile, params);
System.setProperty("minecraft.applet.TargetDirectory", params.clientDir.toString());
}
Collections.addAll(args, profile.getClientArgs()); Collections.addAll(args, profile.getClientArgs());
LogHelper.debug("Args: " + args); LogHelper.debug("Args: " + args);
// Resolve main class and method // Resolve main class and method
Class<?> mainClass = classLoader.loadClass(profile.getMainClass()); Class<?> mainClass = classLoader.loadClass(profile.getMainClass());
MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)); MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)).asFixedArity();
// Invoke main method with exception wrapping
Launcher.LAUNCHED.set(true); Launcher.LAUNCHED.set(true);
JVMHelper.fullGC(); JVMHelper.fullGC();
System.setProperty("minecraft.applet.TargetDirectory", params.clientDir.toString()); // For 1.5.2 // Invoke main method
mainMethod.invoke((Object) args.toArray(EMPTY_ARRAY)); mainMethod.invoke((Object) args.toArray(new String[0]));
} }
private static Process process = null; private static Process process = null;