diff --git a/java/lang/Thread.java b/java/lang/Thread.java index bc2dbb5b70..cb903fabdd 100644 --- a/java/lang/Thread.java +++ b/java/lang/Thread.java @@ -159,7 +159,7 @@ public class Thread implements Runnable /** Thread local storage. Package accessible for use by * InheritableThreadLocal. */ - final ThreadLocalMap locals; + ThreadLocalMap locals; /** The uncaught exception handler. */ UncaughtExceptionHandler exceptionHandler; @@ -1073,7 +1073,10 @@ synchronized void die() */ static ThreadLocalMap getThreadLocals() { - return currentThread().locals; + Thread t = currentThread(); + if (t.locals == null) + t.locals = new ThreadLocalMap(); + return t.locals; } /**