Skip to content

Commit

Permalink
Allow ModuleClassLoader to delegate class-loading to parent for unit …
Browse files Browse the repository at this point in the history
…testing without class-loader isolation.
  • Loading branch information
shartte committed Jan 12, 2024
1 parent fd3fa25 commit ad8d7d7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/cpw/mods/cl/ModuleClassLoader.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cpw.mods.cl;

import cpw.mods.util.LambdaExceptionUtils;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -64,10 +65,15 @@ private static void bindToLayer(ModuleClassLoader classLoader, ModuleLayer layer
private final Map<String, JarModuleFinder.JarModuleReference> resolvedRoots;
private final Map<String, ResolvedModule> packageLookup;
private final Map<String, ClassLoader> parentLoaders;
private ClassLoader fallbackClassLoader = ClassLoader.getPlatformClassLoader();
private ClassLoader fallbackClassLoader;

public ModuleClassLoader(final String name, final Configuration configuration, final List<ModuleLayer> parentLayers) {
super(name, null);
this(name, configuration, parentLayers, null);
}

public ModuleClassLoader(final String name, final Configuration configuration, final List<ModuleLayer> parentLayers, @Nullable ClassLoader parentLoader) {
super(name, parentLoader);
this.fallbackClassLoader = Objects.requireNonNullElse(parentLoader, ClassLoader.getPlatformClassLoader());
this.configuration = configuration;
this.packageLookup = new HashMap<>();
this.resolvedRoots = configuration.modules().stream()
Expand Down

0 comments on commit ad8d7d7

Please sign in to comment.