summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorskybber <lada.dvorak7@gmail.com>2019-03-17 09:26:09 +0100
committerskybber <lada.dvorak7@gmail.com>2019-03-17 09:26:09 +0100
commitf1e12688218e3f47574946ccddbb8402798e3540 (patch)
treedc4a6792f66fd6db05d814c819510186d98a04c5 /src
parenteff2f4bbd0246476edfa43782f38e58ddedef952 (diff)
downloadjavassist-f1e12688218e3f47574946ccddbb8402798e3540.tar.gz
javassist-f1e12688218e3f47574946ccddbb8402798e3540.zip
Control ctxClassLoader usage per thread
Diffstat (limited to 'src')
-rw-r--r--src/main/javassist/runtime/Desc.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/javassist/runtime/Desc.java b/src/main/javassist/runtime/Desc.java
index c733b30d..9fbe8f22 100644
--- a/src/main/javassist/runtime/Desc.java
+++ b/src/main/javassist/runtime/Desc.java
@@ -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);
}