Skip to content

Commit

Permalink
Reduce commentary.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed May 4, 2023
1 parent 92243f4 commit 7ddef27
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1818,22 +1818,15 @@ public Map<String, Class<?>> injectRaw(Map<? extends String, byte[]> types) {
: classLoader) {
for (Map.Entry<? extends String, byte[]> entry : types.entrySet()) {
try {
// first try to load the class from the given class loader
result.put(entry.getKey(), Class.forName(entry.getKey(), false, classLoader));
} catch (ClassNotFoundException ignored) {
try {
// if the class does not exist, try to define it
result.put(entry.getKey(), dispatcher.defineClass(classLoader, entry.getKey(), entry.getValue(), protectionDomain));
} catch (Exception defFailure) {
// when the bootstrap loader is in use (i.e. the classloader is null), synchronizing on the BOOTSTRAP_LOADER_LOCK
// is sufficient to prevent this instance of ClassInjector from concurrently trying to define a class.
// however, in an environment where many ClassInjectors exist (either because shaded into multiple projects or
// it is present in multiple classloaders)
} catch (Exception exception) { // The bootstrap loader lock might be replicated throughout multiple class loaders.
try {
result.put(entry.getKey(), Class.forName(entry.getKey(), false, classLoader));
} catch (ClassNotFoundException ignored2) {
//throw the failure from actually trying to define the class
throw defFailure;
throw exception;
}
}
}
Expand Down

0 comments on commit 7ddef27

Please sign in to comment.