diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/NodeUtils.java b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/NodeUtils.java index 56b9e221..9919cde7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/NodeUtils.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/NodeUtils.java @@ -15,6 +15,17 @@ import static org.objectweb.asm.Opcodes.*; public final class NodeUtils { + public static final boolean JAVA9; + + static { + boolean java9 = false; + try { + Class.forName("java.lang.StackWalker"); + java9 = true; + } catch (final Throwable e) { + } + JAVA9 = java9; + } private NodeUtils() { } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/ProguardConf.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/ProguardConf.java index 123b8a89..ff9e3277 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/ProguardConf.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/ProguardConf.java @@ -1,6 +1,7 @@ package pro.gravit.launchserver.binary; import pro.gravit.launchserver.LaunchServer; +import pro.gravit.launchserver.asm.NodeUtils; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.SecurityHelper; @@ -13,11 +14,21 @@ import java.nio.file.Path; import java.security.SecureRandom; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class ProguardConf { private static final String chars = "1aAbBcC2dDeEfF3gGhHiI4jJkKl5mMnNoO6pPqQrR7sStT8uUvV9wWxX0yYzZ"; + public static final String[] JAVA9_OPTS = new String[] { + "-libraryjars '/jmods/'" + }; + public static final String[] JAVA8_OPTS = new String[] { + "-libraryjars '/lib/rt.jar'", + "-libraryjars '/lib/jce.jar'", + "-libraryjars '/lib/ext/nashorn.jar'", + "-libraryjars '/lib/ext/jfxrt.jar'" + }; private static String generateString(SecureRandom rand, String lowString, String upString, int il) { StringBuilder sb = new StringBuilder(Math.max(il, lowString.length())); for (int i = 0; i < lowString.length(); ++i) { @@ -50,9 +61,11 @@ public String[] buildConfig(Path inputJar, Path outputJar) { confStrs.add("-obfuscationdictionary \'" + words.toFile().getName() + "\'"); confStrs.add("-injar \'" + inputJar.toAbsolutePath() + "\'"); confStrs.add("-outjar \'" + outputJar.toAbsolutePath() + "\'"); + Collections.addAll(confStrs, NodeUtils.JAVA9 ? JAVA9_OPTS : JAVA8_OPTS); srv.launcherBinary.coreLibs.stream() .map(e -> "-libraryjars \'" + e.toAbsolutePath().toString() + "\'") .forEach(confStrs::add); + srv.launcherBinary.addonLibs.stream() .map(e -> "-libraryjars \'" + e.toAbsolutePath().toString() + "\'") .forEach(confStrs::add); diff --git a/LaunchServer/src/main/resources/pro/gravit/launchserver/defaults/proguard.cfg b/LaunchServer/src/main/resources/pro/gravit/launchserver/defaults/proguard.cfg index 5a4eb1ef..08b511c1 100644 --- a/LaunchServer/src/main/resources/pro/gravit/launchserver/defaults/proguard.cfg +++ b/LaunchServer/src/main/resources/pro/gravit/launchserver/defaults/proguard.cfg @@ -1,7 +1,3 @@ --libraryjars '/lib/rt.jar' --libraryjars '/lib/jce.jar' --libraryjars '/lib/ext/nashorn.jar' --libraryjars '/lib/ext/jfxrt.jar' -keepattributes SourceFile,LineNumberTable -renamesourcefileattribute Source