Skip to content

Commit

Permalink
CompositeClassLoader is inappropriately using reflection for methods …
Browse files Browse the repository at this point in the history
…it has access to #214

#214
Invoked registerAsParallelCapable directly.
Add some logging if there is an error (fail silently is rarely a good thing).

Signed-off-by: Steve Davidson <steve@j2eeguys.com>
  • Loading branch information
gorky committed Jul 29, 2020
1 parent 4438248 commit 9391ed3
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ public class CompositeClassLoader extends ClassLoader {
static {
// see http://www.cs.duke.edu/csed/java/jdk1.7/technotes/guides/lang/cl-mt.html
try {
final Method m = ClassLoader.class.getDeclaredMethod("registerAsParallelCapable");
if (!m.isAccessible()) {
m.setAccessible(true);
}
m.invoke(null);
ClassLoader.registerAsParallelCapable();
} catch (final Exception e) {
// ignore errors, JVM will synchronize class for Java 7 or higher
//Should write that there was an issue before proceeding.
System.err.println("Warning: Failed to register as a Parallel ClassLoader: " + e.getMessage());
System.err.println("This may negatively impact performance");
System.err.println("Falling back to synchronized classloading");
}
}

Expand Down

0 comments on commit 9391ed3

Please sign in to comment.