Skip to content

Commit

Permalink
Introduce extra indirection in ObjectBuilder$ModuleFinder
Browse files Browse the repository at this point in the history
The reason this is done is to allow
ObjectBuilder$ModuleFinder the class to be
loaded and initialized even when JBoss Modules
is not present on the classpath.
The ultimate goal of this is to allow for Quarkus
to substitute the method when building a native
image and fix the problem mentioned in
quarkusio/quarkus#33318 (comment)
  • Loading branch information
geoand committed Aug 8, 2023
1 parent bd5bdd6 commit 7afd61a
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,18 @@ private ModuleFinder() {
}

static ClassLoader getClassLoader(final String moduleName) throws Exception {
ModuleLoader moduleLoader = ModuleLoader.forClass(ModuleFinder.class);
if (moduleLoader == null) {
moduleLoader = Module.getBootModuleLoader();
return Holder.getClassLoader(moduleName);
}

private static class Holder {

static ClassLoader getClassLoader(final String moduleName) throws Exception {
ModuleLoader moduleLoader = ModuleLoader.forClass(ModuleFinder.class);
if (moduleLoader == null) {
moduleLoader = Module.getBootModuleLoader();
}
return moduleLoader.loadModule(moduleName).getClassLoader();
}
return moduleLoader.loadModule(moduleName).getClassLoader();
}
}

Expand Down

0 comments on commit 7afd61a

Please sign in to comment.