diff --git a/src/main/java/cpw/mods/modlauncher/ModuleLayerHandler.java b/src/main/java/cpw/mods/modlauncher/ModuleLayerHandler.java index a83f33a..2275877 100644 --- a/src/main/java/cpw/mods/modlauncher/ModuleLayerHandler.java +++ b/src/main/java/cpw/mods/modlauncher/ModuleLayerHandler.java @@ -23,6 +23,7 @@ import cpw.mods.jarhandling.SecureJar; import cpw.mods.modlauncher.api.IModuleLayerManager; import cpw.mods.modlauncher.api.NamedPath; +import org.jetbrains.annotations.Nullable; import java.lang.module.Configuration; import java.lang.module.ModuleFinder; @@ -49,11 +50,15 @@ SecureJar build() { private final EnumMap completedLayers = new EnumMap<>(Layer.class); public ModuleLayerHandler() { + this(null); + } + + public ModuleLayerHandler(@Nullable ClassLoader parentLoader) { ClassLoader classLoader = getClass().getClassLoader(); // Create a new ModuleClassLoader from the boot module layer if it doesn't exist already. // This allows us to launch without BootstrapLauncher. ModuleClassLoader cl = classLoader instanceof ModuleClassLoader moduleCl ? moduleCl - : new ModuleClassLoader("BOOT", ModuleLayer.boot().configuration(), List.of()); + : new ModuleClassLoader("BOOT", ModuleLayer.boot().configuration(), List.of(), parentLoader); var ownLayer = Objects.requireNonNullElse(getClass().getModule().getLayer(), ModuleLayer.boot()); completedLayers.put(Layer.BOOT, new LayerInfo(ownLayer, cl)); }