[FIX] Переписал код использующий ProccessBuilder. Активные участники прошу работоспособность после этого коммита.

This commit is contained in:
Zaxar163 2019-11-28 18:12:40 +01:00
parent 97b30aa234
commit 358e92ad9e
No known key found for this signature in database
GPG key ID: 1FE4F2E1F053831B
2 changed files with 14 additions and 15 deletions

View file

@ -12,7 +12,6 @@
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -62,8 +61,8 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
JVMHelper.addSystemPropertyToArgs(args, DirBridge.USE_OPTDIR_PROPERTY); JVMHelper.addSystemPropertyToArgs(args, DirBridge.USE_OPTDIR_PROPERTY);
if (!noJava9check && !System.getProperty("java.version").startsWith("1.8")) { if (!noJava9check && !System.getProperty("java.version").startsWith("1.8")) {
LogHelper.debug("Found Java 9+ ( %s )", System.getProperty("java.version")); LogHelper.debug("Found Java 9+ ( %s )", System.getProperty("java.version"));
Collections.addAll(args, "--add-modules"); args.add("--add-modules");
Collections.addAll(args, "javafx.base,javafx.fxml,javafx.controls,jdk.unsupported"); args.add("javafx.base,javafx.fxml,javafx.controls,jdk.unsupported");
Path jvmDir = Paths.get(System.getProperty("java.home")); Path jvmDir = Paths.get(System.getProperty("java.home"));
String pathToFx = System.getenv("PATH_TO_FX"); String pathToFx = System.getenv("PATH_TO_FX");
Path fxPath = pathToFx == null ? null : Paths.get(pathToFx); Path fxPath = pathToFx == null ? null : Paths.get(pathToFx);
@ -75,17 +74,17 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
tryAddModule(findPath, "javafx.controls", builder); tryAddModule(findPath, "javafx.controls", builder);
String modulePath = builder.toString(); String modulePath = builder.toString();
if (!modulePath.isEmpty()) { if (!modulePath.isEmpty()) {
Collections.addAll(args, "--module-path"); args.add("--module-path");
Collections.addAll(args, modulePath); args.add(modulePath);
} }
} }
Collections.addAll(args, MAGIC_ARG); args.add(MAGIC_ARG);
Collections.addAll(args, "-XX:+DisableAttachMechanism"); args.add("-XX:+DisableAttachMechanism");
Collections.addAll(args, "-Xmx256M"); args.add("-Xmx256M");
//Collections.addAll(args, "-javaagent:".concat(pathLauncher)); //Collections.addAll(args, "-javaagent:".concat(pathLauncher));
Collections.addAll(args, "-cp"); args.add("-cp");
Collections.addAll(args, pathLauncher); args.add(pathLauncher);
Collections.addAll(args, LauncherEngine.class.getName()); args.add(LauncherEngine.class.getName());
LauncherEngine.modulesManager.callWrapper(processBuilder, args); LauncherEngine.modulesManager.callWrapper(processBuilder, args);
EnvHelper.addEnv(processBuilder); EnvHelper.addEnv(processBuilder);
LogHelper.debug("Commandline: " + args); LogHelper.debug("Commandline: " + args);

View file

@ -109,14 +109,14 @@ public ClientLauncherContext build() throws IOException {
// Add classpath and main class // Add classpath and main class
String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString(); String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString();
context.pathLauncher = pathLauncher; context.pathLauncher = pathLauncher;
Collections.addAll(context.args, ClientLauncherWrapper.MAGIC_ARG); context.args.add(ClientLauncherWrapper.MAGIC_ARG);
Collections.addAll(context.args, profile.getJvmArgs()); Collections.addAll(context.args, profile.getJvmArgs());
profile.pushOptionalJvmArgs(context.args); profile.pushOptionalJvmArgs(context.args);
Collections.addAll(context.args, "-Djava.library.path=".concat(params.clientDir.resolve(nativesDir).toString())); // Add Native Path context.args.add("-Djava.library.path=".concat(params.clientDir.resolve(nativesDir).toString())); // Add Native Path
Collections.addAll(context.args, "-javaagent:".concat(pathLauncher)); context.args.add("-javaagent:".concat(pathLauncher));
ClientHookManager.clientLaunchHook.hook(context); ClientHookManager.clientLaunchHook.hook(context);
LauncherGuardManager.guard.addCustomParams(context); LauncherGuardManager.guard.addCustomParams(context);
Collections.addAll(context.args, ClientLauncher.class.getName()); context.args.add(ClientLauncher.class.getName());
ClientHookManager.clientLaunchFinallyHook.hook(context); ClientHookManager.clientLaunchFinallyHook.hook(context);
// Print commandline debug message // Print commandline debug message