Skip to content

Commit

Permalink
Add a test entrypoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Jan 13, 2024
1 parent 97faffc commit 8d4bef4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repositories {
}

dependencies {
implementation('cpw.mods:securejarhandler:2.1.2')
implementation('cpw.mods:securejarhandler:2.1.24')
}

java {
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/cpw/mods/bootstraplauncher/BootstrapLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,16 @@
public class BootstrapLauncher {
private static final boolean DEBUG = System.getProperties().containsKey("bsl.debug");

@SuppressWarnings("unchecked")
public static void testMain(String... args) {
run(false, args);
}

public static void main(String... args) {
run(true, args);
}

@SuppressWarnings("unchecked")
private static void run(boolean classloaderIsolation, String... args) {
var legacyClasspath = loadLegacyClassPath();
// Ensure backwards compatibility if somebody reads this value later on.
System.setProperty("legacyClassPath", String.join(File.pathSeparator, legacyClasspath));
Expand Down Expand Up @@ -126,9 +134,11 @@ public static void main(String... args) {
// And the list of root modules for this configuration (that is, the modules that 'belong' to the configuration) are
// the above modules from the SecureJars
var bootstrapConfiguration = bootModuleConfiguration.resolveAndBind(jarModuleFinder, ModuleFinder.ofSystem(), allTargets);
// If the classloading should be isolated, we do not configure a parent loader, otherwise we use the context CL
ClassLoader parentLoader = classloaderIsolation ? null : Thread.currentThread().getContextClassLoader();
// Creates the module class loader, which does the loading of classes and resources from the bootstrap module layer/configuration,
// falling back to the boot layer if not in the bootstrap layer
var moduleClassLoader = new ModuleClassLoader("MC-BOOTSTRAP", bootstrapConfiguration, List.of(ModuleLayer.boot()));
var moduleClassLoader = new ModuleClassLoader("MC-BOOTSTRAP", bootstrapConfiguration, List.of(ModuleLayer.boot()), parentLoader);
// Actually create the module layer, using the bootstrap configuration above, the boot layer as the parent layer (as configured),
// and mapping all modules to the module class loader
var layer = ModuleLayer.defineModules(bootstrapConfiguration, List.of(ModuleLayer.boot()), m -> moduleClassLoader);
Expand Down

0 comments on commit 8d4bef4

Please sign in to comment.