Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Dec 17, 2024
1 parent 841022e commit 735c8b4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/cpw/mods/modlauncher/ModuleLayerHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -49,11 +50,15 @@ SecureJar build() {
private final EnumMap<Layer, LayerInfo> 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));
}
Expand Down

0 comments on commit 735c8b4

Please sign in to comment.