diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/Main.java b/LaunchServer/src/main/java/pro/gravit/launchserver/Main.java index 8026ddb2..a4bbc556 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/Main.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/Main.java @@ -1,5 +1,6 @@ package pro.gravit.launchserver; +import pro.gravit.launchserver.holder.LaunchServerControlHolder; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.launch.ClassLoaderControl; import pro.gravit.utils.launch.LaunchOptions; @@ -54,7 +55,6 @@ public static void main(String[] args) throws Throwable { unpackLog4j(); ModuleLaunch launch = new ModuleLaunch(); LaunchOptions options = new LaunchOptions(); - options.disablePackageDelegateSupport = true; options.moduleConf = new LaunchOptions.ModuleConf(); List libraries; try(Stream files = Files.walk(Path.of("libraries"), FileVisitOption.FOLLOW_LINKS)) { @@ -73,7 +73,12 @@ public static void main(String[] args) throws Throwable { options.moduleConf.modulePath.addAll(modulepath); options.moduleConf.modules.add("ALL-MODULE-PATH"); ClassLoaderControl control = launch.init(classpath, "natives", options); + control.clearLauncherPackages(); + control.addLauncherPackage("pro.gravit.utils.launch"); + control.addLauncherPackage("pro.gravit.launchserver.holder"); ModuleLayer.Controller controller = (ModuleLayer.Controller) control.getJava9ModuleController(); + LaunchServerControlHolder.setControl(control); + LaunchServerControlHolder.setController(controller); launch.launch("pro.gravit.launchserver.LaunchServerStarter", null, Arrays.asList(args)); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/holder/LaunchServerControlHolder.java b/LaunchServer/src/main/java/pro/gravit/launchserver/holder/LaunchServerControlHolder.java new file mode 100644 index 00000000..a29d4cd4 --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/holder/LaunchServerControlHolder.java @@ -0,0 +1,24 @@ +package pro.gravit.launchserver.holder; + +import pro.gravit.utils.launch.ClassLoaderControl; + +public class LaunchServerControlHolder { + private static ClassLoaderControl control; + private static ModuleLayer.Controller controller; + + public static ClassLoaderControl getControl() { + return control; + } + + public static void setControl(ClassLoaderControl control) { + LaunchServerControlHolder.control = control; + } + + public static ModuleLayer.Controller getController() { + return controller; + } + + public static void setController(ModuleLayer.Controller controller) { + LaunchServerControlHolder.controller = controller; + } +} diff --git a/LauncherCore/src/main/java/pro/gravit/utils/launch/BasicLaunch.java b/LauncherCore/src/main/java/pro/gravit/utils/launch/BasicLaunch.java index 1cb326a4..b4865b8d 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/launch/BasicLaunch.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/launch/BasicLaunch.java @@ -56,6 +56,11 @@ public void addLauncherPackage(String prefix) { throw new UnsupportedOperationException(); } + @Override + public void clearLauncherPackages() { + throw new UnsupportedOperationException(); + } + @Override public void addTransformer(ClassTransformer transformer) { if (instrumentation == null) { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/launch/ClassLoaderControl.java b/LauncherCore/src/main/java/pro/gravit/utils/launch/ClassLoaderControl.java index 08e44065..8d2cfd98 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/launch/ClassLoaderControl.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/launch/ClassLoaderControl.java @@ -7,6 +7,7 @@ public interface ClassLoaderControl { void addLauncherPackage(String prefix); + void clearLauncherPackages(); void addTransformer(ClassTransformer transformer); void addURL(URL url); void addJar(Path path); diff --git a/LauncherCore/src/main/java/pro/gravit/utils/launch/LegacyLaunch.java b/LauncherCore/src/main/java/pro/gravit/utils/launch/LegacyLaunch.java index 08f65795..1a155fe4 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/launch/LegacyLaunch.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/launch/LegacyLaunch.java @@ -126,6 +126,10 @@ public void addAllowedPackage(String pkg) { packages.add(pkg); } + public void clearAllowedPackages() { + packages.clear(); + } + private LegacyClassLoaderControl makeControl() { return new LegacyClassLoaderControl(); } @@ -137,6 +141,11 @@ public void addLauncherPackage(String prefix) { addAllowedPackage(prefix); } + @Override + public void clearLauncherPackages() { + clearAllowedPackages(); + } + @Override public void addTransformer(ClassTransformer transformer) { transformers.add(transformer); diff --git a/LauncherCore/src/main/java/pro/gravit/utils/launch/ModuleLaunch.java b/LauncherCore/src/main/java/pro/gravit/utils/launch/ModuleLaunch.java index ab4d829d..5a414ea8 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/launch/ModuleLaunch.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/launch/ModuleLaunch.java @@ -264,6 +264,10 @@ public void addAllowedPackage(String pkg) { packages.add(pkg); } + public void clearAllowedPackages() { + packages.clear(); + } + private ModuleClassLoaderControl makeControl() { return new ModuleClassLoaderControl(); } @@ -275,6 +279,11 @@ public void addLauncherPackage(String prefix) { addAllowedPackage(prefix); } + @Override + public void clearLauncherPackages() { + clearAllowedPackages(); + } + @Override public void addTransformer(ClassTransformer transformer) { transformers.add(transformer);