Skip to content

Commit

Permalink
Fix implementation of ClassLoaderSupport.isNativeImageClassLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
olpaw committed May 11, 2022
1 parent 1e55daf commit 9ca9ba5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,23 @@ class ClassLoaderSupportImpl extends ClassLoaderSupport {

@Override
protected boolean isNativeImageClassLoaderImpl(ClassLoader loader) {
return loader == imageClassLoader || loader instanceof NativeImageSystemClassLoader;
if (loader == imageClassLoader) {
/* Trivial case */
return true;
}
if (loader == classLoaderSupport.classPathClassLoader) {
/*
* If imageClassLoader is a module classloader (building image with non-empty
* NativeImageClassLoaderSupport.imagemp), the passed loader could also be our
* classLoaderSupport.classPathClassLoader (building image with non-empty
* NativeImageClassLoaderSupport.imagecp).
*/
return true;
}
if (loader instanceof NativeImageSystemClassLoader) {
return true;
}
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class NativeImageClassLoaderSupport {
private final EconomicMap<URI, EconomicSet<String>> packages;
private final EconomicSet<String> emptySet;

private final URLClassLoader classPathClassLoader;
final URLClassLoader classPathClassLoader;
private final ClassLoader modulePathClassLoader;

public final ModuleFinder upgradeAndSystemModuleFinder;
Expand Down

0 comments on commit 9ca9ba5

Please sign in to comment.