diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java index 416b6c684f1a4..61e3880abdf68 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java @@ -117,6 +117,32 @@ private String sanitizeName(String name) { return name; } + /** + * Returns true if the supplied class is a class that would be loaded parent-first + */ + public boolean isParentFirst(String name) { + if (name.startsWith(JAVA)) { + return true; + } + + //even if the thread is interrupted we still want to be able to load classes + //if the interrupt bit is set then we clear it and restore it at the end + boolean interrupted = Thread.interrupted(); + try { + ClassLoaderState state = getState(); + synchronized (getClassLoadingLock(name)) { + String resourceName = sanitizeName(name).replace(".", "/") + ".class"; + return parentFirst(resourceName, state); + } + + } finally { + if (interrupted) { + //restore interrupt state + Thread.currentThread().interrupt(); + } + } + } + private boolean parentFirst(String name, ClassLoaderState state) { return parentFirst || state.parentFirstResources.contains(name); }