From b56eed68bedbf675ed74164dfbdb9246be82767a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 31 Jul 2007 18:08:20 -0600 Subject: [PATCH] implement Thread.[get|set]ContextClassloader() --- classpath/java/lang/Thread.java | 15 ++++++++++++++- src/machine.cpp | 3 ++- src/types.def | 3 ++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/classpath/java/lang/Thread.java b/classpath/java/lang/Thread.java index b9908e1298..0dd5811f04 100644 --- a/classpath/java/lang/Thread.java +++ b/classpath/java/lang/Thread.java @@ -9,11 +9,14 @@ public class Thread implements Runnable { private Map locals; private boolean interrupted; private Object sleepLock; + private ClassLoader classLoader; public Thread(Runnable task) { this.task = task; - Map map = currentThread().locals; + Thread current = currentThread(); + + Map map = current.locals; if (map != null) { for (Map.Entry e: map.entrySet()) { if (e.getKey() instanceof InheritableThreadLocal) { @@ -22,6 +25,8 @@ public class Thread implements Runnable { } } } + + classLoader = current.classLoader; } public synchronized void start() { @@ -43,6 +48,14 @@ public class Thread implements Runnable { } } + public ClassLoader getContextClassLoader() { + return classLoader; + } + + public void setContextClassLoader(ClassLoader v) { + classLoader = v; + } + public Map locals() { if (locals == null) { locals = new WeakHashMap(); diff --git a/src/machine.cpp b/src/machine.cpp index 981b859084..7aba445fa2 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -1336,7 +1336,8 @@ Thread::Thread(Machine* m, object javaThread, Thread* parent): populateBuiltinMap(t, m->builtinMap); - t->javaThread = makeThread(t, reinterpret_cast(t), 0, 0, 0, 0); + t->javaThread = makeThread + (t, reinterpret_cast(t), 0, 0, 0, 0, t->vm->loader); } else { threadPeer(this, javaThread) = reinterpret_cast(this); parent->child = this; diff --git a/src/types.def b/src/types.def index 187a46a80f..ebc3b48309 100644 --- a/src/types.def +++ b/src/types.def @@ -140,7 +140,8 @@ (object task) (object locals) (uint8_t interrupted) - (object sleepLock)) + (object sleepLock) + (object classLoader)) (type stackTraceElement java/lang/StackTraceElement (extends jobject)