< prev index next >

src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java

Print this page




 111             INHERITABLE_THREAD_LOCALS = UNSAFE.objectFieldOffset
 112                     (tk.getDeclaredField("inheritableThreadLocals"));
 113             INHERITEDACCESSCONTROLCONTEXT = UNSAFE.objectFieldOffset
 114                 (tk.getDeclaredField("inheritedAccessControlContext"));
 115             CONTEXTCLASSLOADER = UNSAFE.objectFieldOffset
 116                 (tk.getDeclaredField("contextClassLoader"));
 117 
 118             long tg = UNSAFE.objectFieldOffset(tk.getDeclaredField("group"));
 119             long gp = UNSAFE.objectFieldOffset(gk.getDeclaredField("parent"));
 120             ThreadGroup group = (ThreadGroup)
 121                 UNSAFE.getObject(Thread.currentThread(), tg);
 122 
 123             while (group != null) {
 124                 ThreadGroup parent = (ThreadGroup)UNSAFE.getObject(group, gp);
 125                 if (parent == null)
 126                     break;
 127                 group = parent;
 128             }
 129             final ThreadGroup root = group;
 130             INNOCUOUSTHREADGROUP = AccessController.doPrivileged(
 131                 (PrivilegedAction<ThreadGroup>) () ->
 132                     { return new ThreadGroup(root, "InnocuousThreadGroup"); });




 133         } catch (Exception e) {
 134             throw new Error(e);
 135         }
 136     }
 137 }


 111             INHERITABLE_THREAD_LOCALS = UNSAFE.objectFieldOffset
 112                     (tk.getDeclaredField("inheritableThreadLocals"));
 113             INHERITEDACCESSCONTROLCONTEXT = UNSAFE.objectFieldOffset
 114                 (tk.getDeclaredField("inheritedAccessControlContext"));
 115             CONTEXTCLASSLOADER = UNSAFE.objectFieldOffset
 116                 (tk.getDeclaredField("contextClassLoader"));
 117 
 118             long tg = UNSAFE.objectFieldOffset(tk.getDeclaredField("group"));
 119             long gp = UNSAFE.objectFieldOffset(gk.getDeclaredField("parent"));
 120             ThreadGroup group = (ThreadGroup)
 121                 UNSAFE.getObject(Thread.currentThread(), tg);
 122 
 123             while (group != null) {
 124                 ThreadGroup parent = (ThreadGroup)UNSAFE.getObject(group, gp);
 125                 if (parent == null)
 126                     break;
 127                 group = parent;
 128             }
 129             final ThreadGroup root = group;
 130             INNOCUOUSTHREADGROUP = AccessController.doPrivileged(
 131                 new PrivilegedAction<ThreadGroup>() {
 132                     @Override
 133                     public ThreadGroup run() {
 134                         return new ThreadGroup(root, "InnocuousThreadGroup");
 135                     }
 136                 });
 137         } catch (Exception e) {
 138             throw new Error(e);
 139         }
 140     }
 141 }
< prev index next >