1 /*
2 * Copyright (c) 1994, 2012, 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
23 * questions.
24 */
25 package java.lang;
26
27 import java.io.*;
28 import java.lang.annotation.Annotation;
29 import java.util.Properties;
30 import java.util.PropertyPermission;
31 import java.util.StringTokenizer;
32 import java.security.AccessController;
33 import java.security.PrivilegedAction;
34 import java.security.AllPermission;
35 import java.nio.channels.Channel;
36 import java.nio.channels.spi.SelectorProvider;
37 import sun.nio.ch.Interruptible;
38 import sun.reflect.Reflection;
39 import sun.security.util.SecurityConstants;
40 import sun.reflect.annotation.AnnotationType;
41
42 /**
43 * The <code>System</code> class contains several useful class fields
44 * and methods. It cannot be instantiated.
45 *
46 * <p>Among the facilities provided by the <code>System</code> class
47 * are standard input, standard output, and error output streams;
48 * access to externally defined properties and environment
1181 // sun.misc.VM.isBooted() in order to avoid doing things that should
1182 // wait until the application class loader has been set up.
1183 // IMPORTANT: Ensure that this remains the last initialization action!
1184 sun.misc.VM.booted();
1185 }
1186
1187 private static void setJavaLangAccess() {
1188 // Allow privileged classes outside of java.lang
1189 sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess(){
1190 public sun.reflect.ConstantPool getConstantPool(Class<?> klass) {
1191 return klass.getConstantPool();
1192 }
1193 public void setAnnotationType(Class<?> klass, AnnotationType type) {
1194 klass.setAnnotationType(type);
1195 }
1196 public AnnotationType getAnnotationType(Class<?> klass) {
1197 return klass.getAnnotationType();
1198 }
1199 public <A extends Annotation> A getDirectDeclaredAnnotation(Class<?> klass, Class<A> anno) {
1200 return klass.getDirectDeclaredAnnotation(anno);
1201 }
1202 public <E extends Enum<E>>
1203 E[] getEnumConstantsShared(Class<E> klass) {
1204 return klass.getEnumConstantsShared();
1205 }
1206 public void blockedOn(Thread t, Interruptible b) {
1207 t.blockedOn(b);
1208 }
1209 public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
1210 Shutdown.add(slot, registerShutdownInProgress, hook);
1211 }
1212 public int getStackTraceDepth(Throwable t) {
1213 return t.getStackTraceDepth();
1214 }
1215 public StackTraceElement getStackTraceElement(Throwable t, int i) {
1216 return t.getStackTraceElement(i);
1217 }
1218 });
1219 }
1220
|
1 /*
2 * Copyright (c) 1994, 2013, 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
23 * questions.
24 */
25 package java.lang;
26
27 import java.io.*;
28 import java.lang.annotation.Annotation;
29 import java.lang.reflect.Executable;
30 import java.util.Properties;
31 import java.util.PropertyPermission;
32 import java.util.StringTokenizer;
33 import java.security.AccessController;
34 import java.security.PrivilegedAction;
35 import java.security.AllPermission;
36 import java.nio.channels.Channel;
37 import java.nio.channels.spi.SelectorProvider;
38 import sun.nio.ch.Interruptible;
39 import sun.reflect.Reflection;
40 import sun.security.util.SecurityConstants;
41 import sun.reflect.annotation.AnnotationType;
42
43 /**
44 * The <code>System</code> class contains several useful class fields
45 * and methods. It cannot be instantiated.
46 *
47 * <p>Among the facilities provided by the <code>System</code> class
48 * are standard input, standard output, and error output streams;
49 * access to externally defined properties and environment
1182 // sun.misc.VM.isBooted() in order to avoid doing things that should
1183 // wait until the application class loader has been set up.
1184 // IMPORTANT: Ensure that this remains the last initialization action!
1185 sun.misc.VM.booted();
1186 }
1187
1188 private static void setJavaLangAccess() {
1189 // Allow privileged classes outside of java.lang
1190 sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess(){
1191 public sun.reflect.ConstantPool getConstantPool(Class<?> klass) {
1192 return klass.getConstantPool();
1193 }
1194 public void setAnnotationType(Class<?> klass, AnnotationType type) {
1195 klass.setAnnotationType(type);
1196 }
1197 public AnnotationType getAnnotationType(Class<?> klass) {
1198 return klass.getAnnotationType();
1199 }
1200 public <A extends Annotation> A getDirectDeclaredAnnotation(Class<?> klass, Class<A> anno) {
1201 return klass.getDirectDeclaredAnnotation(anno);
1202 }
1203 public byte[] getRawClassTypeAnnotations(Class<?> klass) {
1204 return klass.getRawTypeAnnotations();
1205 }
1206 public byte[] getRawExecutableTypeAnnotations(Executable executable) {
1207 return Class.getExecutableTypeAnnotationBytes(executable);
1208 }
1209 public <E extends Enum<E>>
1210 E[] getEnumConstantsShared(Class<E> klass) {
1211 return klass.getEnumConstantsShared();
1212 }
1213 public void blockedOn(Thread t, Interruptible b) {
1214 t.blockedOn(b);
1215 }
1216 public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
1217 Shutdown.add(slot, registerShutdownInProgress, hook);
1218 }
1219 public int getStackTraceDepth(Throwable t) {
1220 return t.getStackTraceDepth();
1221 }
1222 public StackTraceElement getStackTraceElement(Throwable t, int i) {
1223 return t.getStackTraceElement(i);
1224 }
1225 });
1226 }
1227
|