src/share/classes/java/lang/System.java

Print this page


   1 /*
   2  * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1161         // way as other threads; we must do it ourselves here.
1162         Thread current = Thread.currentThread();
1163         current.getThreadGroup().add(current);
1164 
1165         // register shared secrets
1166         setJavaLangAccess();
1167 
1168         // Subsystems that are invoked during initialization can invoke
1169         // sun.misc.VM.isBooted() in order to avoid doing things that should
1170         // wait until the application class loader has been set up.
1171         // IMPORTANT: Ensure that this remains the last initialization action!
1172         sun.misc.VM.booted();
1173     }
1174 
1175     private static void setJavaLangAccess() {
1176         // Allow privileged classes outside of java.lang
1177         sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess(){
1178             public sun.reflect.ConstantPool getConstantPool(Class klass) {
1179                 return klass.getConstantPool();
1180             }
1181             public void setAnnotationType(Class klass, AnnotationType type) {
1182                 klass.setAnnotationType(type);
1183             }
1184             public AnnotationType getAnnotationType(Class klass) {
1185                 return klass.getAnnotationType();
1186             }



1187             public <E extends Enum<E>>
1188                     E[] getEnumConstantsShared(Class<E> klass) {
1189                 return klass.getEnumConstantsShared();
1190             }
1191             public void blockedOn(Thread t, Interruptible b) {
1192                 t.blockedOn(b);
1193             }
1194             public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
1195                 Shutdown.add(slot, registerShutdownInProgress, hook);
1196             }
1197             public int getStackTraceDepth(Throwable t) {
1198                 return t.getStackTraceDepth();
1199             }
1200             public StackTraceElement getStackTraceElement(Throwable t, int i) {
1201                 return t.getStackTraceElement(i);
1202             }
1203             public int getStringHash32(String string) {
1204                 return string.hash32();
1205             }
1206             public Thread newThreadWithAcc(Runnable target, AccessControlContext acc) {
   1 /*
   2  * Copyright (c) 1994, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1161         // way as other threads; we must do it ourselves here.
1162         Thread current = Thread.currentThread();
1163         current.getThreadGroup().add(current);
1164 
1165         // register shared secrets
1166         setJavaLangAccess();
1167 
1168         // Subsystems that are invoked during initialization can invoke
1169         // sun.misc.VM.isBooted() in order to avoid doing things that should
1170         // wait until the application class loader has been set up.
1171         // IMPORTANT: Ensure that this remains the last initialization action!
1172         sun.misc.VM.booted();
1173     }
1174 
1175     private static void setJavaLangAccess() {
1176         // Allow privileged classes outside of java.lang
1177         sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess(){
1178             public sun.reflect.ConstantPool getConstantPool(Class klass) {
1179                 return klass.getConstantPool();
1180             }
1181             public boolean casAnnotationType(Class<?> klass, AnnotationType oldType, AnnotationType newType) {
1182                 return klass.casAnnotationType(oldType, newType);
1183             }
1184             public AnnotationType getAnnotationType(Class klass) {
1185                 return klass.getAnnotationType();
1186             }
1187             public byte[] getRawClassAnnotations(Class<?> klass) {
1188                 return klass.getRawAnnotations();
1189             }
1190             public <E extends Enum<E>>
1191                     E[] getEnumConstantsShared(Class<E> klass) {
1192                 return klass.getEnumConstantsShared();
1193             }
1194             public void blockedOn(Thread t, Interruptible b) {
1195                 t.blockedOn(b);
1196             }
1197             public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
1198                 Shutdown.add(slot, registerShutdownInProgress, hook);
1199             }
1200             public int getStackTraceDepth(Throwable t) {
1201                 return t.getStackTraceDepth();
1202             }
1203             public StackTraceElement getStackTraceElement(Throwable t, int i) {
1204                 return t.getStackTraceElement(i);
1205             }
1206             public int getStringHash32(String string) {
1207                 return string.hash32();
1208             }
1209             public Thread newThreadWithAcc(Runnable target, AccessControlContext acc) {