Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control ctxClassLoader usage per thread #250

Merged
merged 1 commit into from Mar 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/main/javassist/runtime/Desc.java
Expand Up @@ -34,10 +34,25 @@ public class Desc {
*/
public static boolean useContextClassLoader = false;

private static final ThreadLocal<Boolean> USE_CONTEXT_CLASS_LOADER_LOCALLY = new ThreadLocal<Boolean>() {
@Override
protected Boolean initialValue() {
return false;
}
};

public static void setUseContextClassLoaderLocally() {
USE_CONTEXT_CLASS_LOADER_LOCALLY.set(true);
}

public static void resetUseContextClassLoaderLocally() {
USE_CONTEXT_CLASS_LOADER_LOCALLY.remove();
}

private static Class<?> getClassObject(String name)
throws ClassNotFoundException
{
if (useContextClassLoader)
if (useContextClassLoader || USE_CONTEXT_CLASS_LOADER_LOCALLY.get())
return Class.forName(name, true, Thread.currentThread().getContextClassLoader());
return Class.forName(name);
}
Expand Down