Skip to content

Commit

Permalink
Attempt preload if not in ClassLoader#defineClass
Browse files Browse the repository at this point in the history
  • Loading branch information
safris committed Apr 24, 2019
1 parent 85d59fa commit f165603
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public T get(final Object key) {

private static final ClassLoaderMap<Boolean> classLoaderToCompatibility = new ClassLoaderMap<>();
private static final ClassLoaderMap<RuleClassLoader> classLoaderToRuleClassLoader = new ClassLoaderMap<>();
private static final String DEFINE_CLASS = ClassLoader.class.getName() + ".defineClass";

private static String agentArgs;
private static AllPluginsClassLoader allPluginsClassLoader;
Expand Down Expand Up @@ -537,6 +538,13 @@ else if (classLoader == ClassLoader.getSystemClassLoader()) {

// Associate the ruleClassLoader with the target class's classLoader
classLoaderToRuleClassLoader.put(classLoader, ruleClassLoader);

// Attempt to preload classes if the callstack is not coming from ClassLoader#defineClass
for (final StackTraceElement stackTraceElement : Thread.currentThread().getStackTrace())
if (DEFINE_CLASS.equals(stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName()))
return true;

ruleClassLoader.preLoad(classLoader);
return true;
}

Expand Down

0 comments on commit f165603

Please sign in to comment.