1515
1616public final class Bootstrap {
1717
18+ private static ModuleLayer parent ;
19+ private static boolean set = false ;
20+
21+ public static void setParent (ModuleLayer moduleLayer ) {
22+ if (set ) return ;
23+ set = true ;
24+ Bootstrap .parent = moduleLayer ;
25+ }
26+
27+
1828 // --launchProfile mangobot
1929 public static void main (String [] args ) throws IOException {
2030
31+ if (parent == null ) {
32+ parent = ModuleLayer .boot ();
33+ set = true ;
34+ }
35+
2136 final var librariesPath = Path .of ("libraries" );
2237 final var pluginsPath = Path .of ("plugins" );
2338
@@ -34,7 +49,7 @@ public static void main(String[] args) throws IOException {
3449 final var moduleCfg = Configuration .resolve (
3550 ModuleFinder .of (pluginsPath ),
3651 List .of (
37- ModuleLayer . boot () .configuration ()
52+ parent .configuration ()
3853 ),
3954 ModuleFinder .of (
4055 Path .of ("sorted-libraries" )
@@ -44,7 +59,7 @@ public static void main(String[] args) throws IOException {
4459
4560 final var moduleCl = new MangoLoader (fetchJars (librariesPath , pluginsPath ), moduleCfg .modules (), Thread .currentThread ().getContextClassLoader ());
4661
47- final var moduleLayerController = ModuleLayer .defineModules (moduleCfg , List .of (ModuleLayer . boot () ), s -> moduleCl );
62+ final var moduleLayerController = ModuleLayer .defineModules (moduleCfg , List .of (parent ), s -> moduleCl );
4863 final var moduleLayer = moduleLayerController .layer ();
4964
5065 Thread .currentThread ().setContextClassLoader (moduleCl );
0 commit comments