Skip to content

Commit

Permalink
Remove class loader detection from DynamicClassLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed Sep 4, 2016
1 parent 6219962 commit e14b747
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,14 @@ public class DynamicClassLoader
private final ConcurrentMap<String, byte[]> pendingClasses = new ConcurrentHashMap<>();
private final Map<Long, MethodHandle> callSiteBindings;

public DynamicClassLoader()
{
this(null);
}

public DynamicClassLoader(ClassLoader parentClassLoader)
{
this(parentClassLoader, ImmutableMap.<Long, MethodHandle>of());
this(parentClassLoader, ImmutableMap.of());
}

public DynamicClassLoader(ClassLoader parentClassLoader, Map<Long, MethodHandle> callSiteBindings)
{
super(resolveClassLoader(parentClassLoader));
super(parentClassLoader);
this.callSiteBindings = ImmutableMap.copyOf(callSiteBindings);
}

Expand Down Expand Up @@ -126,18 +121,4 @@ private Class<?> resolveClass(Class<?> clazz, boolean resolve)
}
return clazz;
}

private static ClassLoader resolveClassLoader(ClassLoader parentClassLoader)
{
if (parentClassLoader == null) {
parentClassLoader = Thread.currentThread().getContextClassLoader();
}
if (parentClassLoader == null) {
parentClassLoader = DynamicClassLoader.class.getClassLoader();
}
if (parentClassLoader == null) {
parentClassLoader = ClassLoader.getSystemClassLoader();
}
return parentClassLoader;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static Object execute(Function<Scope, BytecodeNode> nodeGenerator, Parame
dumpBytecode.visitClass(classDefinition);
}

DynamicClassLoader classLoader = parentClassLoader.isPresent() ? new DynamicClassLoader(parentClassLoader.get()) : new DynamicClassLoader();
DynamicClassLoader classLoader = new DynamicClassLoader(parentClassLoader.orElse(BytecodeExpressionAssertions.class.getClassLoader()));
ClassWriter cw = new SmartClassWriter(ClassInfoLoader.createClassInfoLoader(ImmutableList.of(classDefinition), classLoader));
classDefinition.visit(cw);

Expand Down

0 comments on commit e14b747

Please sign in to comment.