Skip to content

Commit

Permalink
Merge pull request #16617 from geoand/parent-frst-public
Browse files Browse the repository at this point in the history
Add isParentFirst method to QuarkusClassLoader
  • Loading branch information
geoand authored Apr 21, 2021
2 parents 6762300 + 8485eee commit f659381
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit f659381

Please sign in to comment.