jdk/src/java.base/share/classes/java/lang/System.java
author avstepan
Thu, 06 Aug 2015 13:20:13 +0300
changeset 32033 bf24e33c7919
parent 31671 362e0c0acece
child 32649 2ee9017c7597
permissions -rw-r--r--
8132468: docs: replace <tt> tags (obsolete in html5) for java.io, java.lang, java.math Reviewed-by: lancea, dfuchs, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
24367
705490680527 8030709: Tidy warnings cleanup for java.lang package; minor cleanup in java.math, javax.script
yan
parents: 21628
diff changeset
     2
 * Copyright (c) 1994, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4355
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4355
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4355
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4355
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4355
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package java.lang;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.io.*;
15510
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14676
diff changeset
    28
import java.lang.reflect.Executable;
21358
d41ff832d4f6 8027170: Annotations declared on super-super-class should be overridden by super-class.
alundblad
parents: 20831
diff changeset
    29
import java.lang.annotation.Annotation;
20805
ae41216325dd 8013739: Better LDAP resource management
weijun
parents: 18546
diff changeset
    30
import java.security.AccessControlContext;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.PropertyPermission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.StringTokenizer;
21358
d41ff832d4f6 8027170: Annotations declared on super-super-class should be overridden by super-class.
alundblad
parents: 20831
diff changeset
    34
import java.util.Map;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.security.AllPermission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.nio.channels.Channel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.nio.channels.spi.SelectorProvider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.nio.ch.Interruptible;
16906
44dfee24cb71 8010117: Annotate jdk caller sensitive methods with @sun.reflect.CallerSensitive
mchung
parents: 16479
diff changeset
    41
import sun.reflect.CallerSensitive;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.reflect.Reflection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import sun.security.util.SecurityConstants;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import sun.reflect.annotation.AnnotationType;
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 29986
diff changeset
    45
import jdk.internal.HotSpotIntrinsicCandidate;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * The <code>System</code> class contains several useful class fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * and methods. It cannot be instantiated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <p>Among the facilities provided by the <code>System</code> class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * are standard input, standard output, and error output streams;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * access to externally defined properties and environment
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * variables; a means of loading files and libraries; and a utility
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * method for quickly copying a portion of an array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @author  unascribed
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 24367
diff changeset
    58
 * @since   1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
public final class System {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
6882
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
    62
    /* register the natives via the static initializer.
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
    63
     *
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
    64
     * VM will invoke the initializeSystemClass method to complete
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
    65
     * the initialization for this class separated from clinit.
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
    66
     * Note that to use properties set by the VM, see the constraints
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
    67
     * described in the initializeSystemClass method.
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
    68
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private static native void registerNatives();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        registerNatives();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    /** Don't let anyone instantiate this class */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private System() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * The "standard" input stream. This stream is already
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * open and ready to supply input data. Typically this stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * corresponds to keyboard input or another input source specified by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * the host environment or user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
6001
8d781af24b23 6967533: Epoch bug: ExceptionInInitializerError on systems with uninitialized clock
martin
parents: 5506
diff changeset
    84
    public final static InputStream in = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * The "standard" output stream. This stream is already
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * open and ready to accept output data. Typically this stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * corresponds to display output or another output destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * specified by the host environment or user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * For simple stand-alone Java applications, a typical way to write
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * a line of output data is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *     System.out.println(data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * See the <code>println</code> methods in class <code>PrintStream</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @see     java.io.PrintStream#println()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @see     java.io.PrintStream#println(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @see     java.io.PrintStream#println(char)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @see     java.io.PrintStream#println(char[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @see     java.io.PrintStream#println(double)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @see     java.io.PrintStream#println(float)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @see     java.io.PrintStream#println(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @see     java.io.PrintStream#println(long)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @see     java.io.PrintStream#println(java.lang.Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @see     java.io.PrintStream#println(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
6001
8d781af24b23 6967533: Epoch bug: ExceptionInInitializerError on systems with uninitialized clock
martin
parents: 5506
diff changeset
   111
    public final static PrintStream out = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * The "standard" error output stream. This stream is already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * open and ready to accept output data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Typically this stream corresponds to display output or another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * output destination specified by the host environment or user. By
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * convention, this output stream is used to display error messages
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * or other information that should come to the immediate attention
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * of a user even if the principal output stream, the value of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * variable <code>out</code>, has been redirected to a file or other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * destination that is typically not continuously monitored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     */
6001
8d781af24b23 6967533: Epoch bug: ExceptionInInitializerError on systems with uninitialized clock
martin
parents: 5506
diff changeset
   125
    public final static PrintStream err = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /* The security manager for the system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    private static volatile SecurityManager security = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * Reassigns the "standard" input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * <p>First, if there is a security manager, its <code>checkPermission</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * method is called with a <code>RuntimePermission("setIO")</code> permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *  to see if it's ok to reassign the "standard" input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @param in the new standard input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *        if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     *        <code>checkPermission</code> method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *        reassigning of the standard input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @see SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @see java.lang.RuntimePermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 24367
diff changeset
   148
     * @since   1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public static void setIn(InputStream in) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        checkIO();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        setIn0(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * Reassigns the "standard" output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * <p>First, if there is a security manager, its <code>checkPermission</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * method is called with a <code>RuntimePermission("setIO")</code> permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     *  to see if it's ok to reassign the "standard" output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @param out the new standard output stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *        if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *        <code>checkPermission</code> method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *        reassigning of the standard output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @see SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @see java.lang.RuntimePermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 24367
diff changeset
   172
     * @since   1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    public static void setOut(PrintStream out) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        checkIO();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        setOut0(out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * Reassigns the "standard" error output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * <p>First, if there is a security manager, its <code>checkPermission</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * method is called with a <code>RuntimePermission("setIO")</code> permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *  to see if it's ok to reassign the "standard" error output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @param err the new standard error output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *        if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *        <code>checkPermission</code> method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *        reassigning of the standard error output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @see SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @see java.lang.RuntimePermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     *
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 24367
diff changeset
   196
     * @since   1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    public static void setErr(PrintStream err) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        checkIO();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        setErr0(err);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    private static volatile Console cons = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Returns the unique {@link java.io.Console Console} object associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * with the current Java virtual machine, if any.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *
32033
bf24e33c7919 8132468: docs: replace <tt> tags (obsolete in html5) for java.io, java.lang, java.math
avstepan
parents: 31671
diff changeset
   208
     * @return  The system console, if any, otherwise {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @since   1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     public static Console console() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
         if (cons == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
             synchronized (System.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                 cons = sun.misc.SharedSecrets.getJavaIOAccess().console();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
             }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
         return cons;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * Returns the channel inherited from the entity that created this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * Java virtual machine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * <p> This method returns the channel obtained by invoking the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * {@link java.nio.channels.spi.SelectorProvider#inheritedChannel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * inheritedChannel} method of the system-wide default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * {@link java.nio.channels.spi.SelectorProvider} object. </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * <p> In addition to the network-oriented channels described in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * {@link java.nio.channels.spi.SelectorProvider#inheritedChannel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * inheritedChannel}, this method may return other kinds of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * channels in the future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     *
32033
bf24e33c7919 8132468: docs: replace <tt> tags (obsolete in html5) for java.io, java.lang, java.math
avstepan
parents: 31671
diff changeset
   235
     * @return  The inherited channel, if any, otherwise {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @throws  IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *          If an I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @throws  SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     *          If a security manager is present and it does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     *          permit access to the channel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    public static Channel inheritedChannel() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        return SelectorProvider.provider().inheritedChannel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    private static void checkIO() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        SecurityManager sm = getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        if (sm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            sm.checkPermission(new RuntimePermission("setIO"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    private static native void setIn0(InputStream in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    private static native void setOut0(PrintStream out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    private static native void setErr0(PrintStream err);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * Sets the System security.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * <p> If there is a security manager already installed, this method first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * calls the security manager's <code>checkPermission</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * with a <code>RuntimePermission("setSecurityManager")</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * permission to ensure it's ok to replace the existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * security manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * This may result in throwing a <code>SecurityException</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * <p> Otherwise, the argument is established as the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * security manager. If the argument is <code>null</code> and no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * security manager has been established, then no action is taken and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * the method simply returns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @param      s   the security manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @exception  SecurityException  if the security manager has already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *             been set and its <code>checkPermission</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *             doesn't allow it to be replaced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @see #getSecurityManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @see SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @see java.lang.RuntimePermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    public static
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    void setSecurityManager(final SecurityManager s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            s.checkPackageAccess("java.lang");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            // no-op
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        setSecurityManager0(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    private static synchronized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    void setSecurityManager0(final SecurityManager s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        SecurityManager sm = getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        if (sm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            // ask the currently installed security manager if we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            // can replace it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            sm.checkPermission(new RuntimePermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                                     ("setSecurityManager"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        if ((s != null) && (s.getClass().getClassLoader() != null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            // New security manager class is not on bootstrap classpath.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            // Cause policy to get initialized before we install the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            // security manager, in order to prevent infinite loops when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            // trying to initialize the policy (which usually involves
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            // accessing some security and/or system properties, which in turn
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            // calls the installed security manager's checkPermission method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            // which will loop infinitely if there is a non-system class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            // (in this case: the new security manager class) on the stack).
29986
97167d851fc4 8078467: Update core libraries to use diamond with anonymous classes
darcy
parents: 28668
diff changeset
   313
            AccessController.doPrivileged(new PrivilegedAction<>() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                public Object run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                    s.getClass().getProtectionDomain().implies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                        (SecurityConstants.ALL_PERMISSION);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        security = s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * Gets the system security interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @return  if a security manager has already been established for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *          current application, then that security manager is returned;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     *          otherwise, <code>null</code> is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * @see     #setSecurityManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    public static SecurityManager getSecurityManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        return security;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * Returns the current time in milliseconds.  Note that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * while the unit of time of the return value is a millisecond,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * the granularity of the value depends on the underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * operating system and may be larger.  For example, many
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * operating systems measure time in units of tens of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * milliseconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * <p> See the description of the class <code>Date</code> for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * a discussion of slight discrepancies that may arise between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * "computer time" and coordinated universal time (UTC).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * @return  the difference, measured in milliseconds, between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     *          the current time and midnight, January 1, 1970 UTC.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * @see     java.util.Date
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     */
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 29986
diff changeset
   353
    @HotSpotIntrinsicCandidate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    public static native long currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * Returns the current value of the running Java Virtual Machine's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * high-resolution time source, in nanoseconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * <p>This method can only be used to measure elapsed time and is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * not related to any other notion of system or wall-clock time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * The value returned represents nanoseconds since some fixed but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * arbitrary <i>origin</i> time (perhaps in the future, so values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * may be negative).  The same origin is used by all invocations of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * this method in an instance of a Java virtual machine; other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * virtual machine instances are likely to use a different origin.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * <p>This method provides nanosecond precision, but not necessarily
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * nanosecond resolution (that is, how frequently the value changes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * - no guarantees are made except that the resolution is at least as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * good as that of {@link #currentTimeMillis()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * <p>Differences in successive calls that span greater than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * approximately 292 years (2<sup>63</sup> nanoseconds) will not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * correctly compute elapsed time due to numerical overflow.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * <p>The values returned by this method become meaningful only when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * the difference between two such values, obtained within the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * instance of a Java virtual machine, is computed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     *
28668
a5b9168af1bb 8069269: (spec) Defect in the System.nanoTime spec
bpb
parents: 27565
diff changeset
   381
     * <p>For example, to measure how long some code takes to execute:
a5b9168af1bb 8069269: (spec) Defect in the System.nanoTime spec
bpb
parents: 27565
diff changeset
   382
     * <pre> {@code
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * long startTime = System.nanoTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * // ... the code being measured ...
28668
a5b9168af1bb 8069269: (spec) Defect in the System.nanoTime spec
bpb
parents: 27565
diff changeset
   385
     * long elapsedNanos = System.nanoTime() - startTime;}</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     *
28668
a5b9168af1bb 8069269: (spec) Defect in the System.nanoTime spec
bpb
parents: 27565
diff changeset
   387
     * <p>To compare elapsed time against a timeout, use <pre> {@code
a5b9168af1bb 8069269: (spec) Defect in the System.nanoTime spec
bpb
parents: 27565
diff changeset
   388
     * if (System.nanoTime() - startTime >= timeoutNanos) ...}</pre>
a5b9168af1bb 8069269: (spec) Defect in the System.nanoTime spec
bpb
parents: 27565
diff changeset
   389
     * instead of <pre> {@code
a5b9168af1bb 8069269: (spec) Defect in the System.nanoTime spec
bpb
parents: 27565
diff changeset
   390
     * if (System.nanoTime() >= startTime + timeoutNanos) ...}</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * because of the possibility of numerical overflow.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * @return the current value of the running Java Virtual Machine's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     *         high-resolution time source, in nanoseconds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     */
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 29986
diff changeset
   397
    @HotSpotIntrinsicCandidate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    public static native long nanoTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * Copies an array from the specified source array, beginning at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * specified position, to the specified position of the destination array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * A subsequence of array components are copied from the source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * array referenced by <code>src</code> to the destination array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * referenced by <code>dest</code>. The number of components copied is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * equal to the <code>length</code> argument. The components at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * positions <code>srcPos</code> through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * <code>srcPos+length-1</code> in the source array are copied into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * positions <code>destPos</code> through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * <code>destPos+length-1</code>, respectively, of the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * If the <code>src</code> and <code>dest</code> arguments refer to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * same array object, then the copying is performed as if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * components at positions <code>srcPos</code> through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * <code>srcPos+length-1</code> were first copied to a temporary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * array with <code>length</code> components and then the contents of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * the temporary array were copied into positions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * <code>destPos</code> through <code>destPos+length-1</code> of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * destination array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * If <code>dest</code> is <code>null</code>, then a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * <code>NullPointerException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * If <code>src</code> is <code>null</code>, then a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * <code>NullPointerException</code> is thrown and the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * array is not modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * Otherwise, if any of the following is true, an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * <code>ArrayStoreException</code> is thrown and the destination is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * not modified:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * <li>The <code>src</code> argument refers to an object that is not an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     *     array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * <li>The <code>dest</code> argument refers to an object that is not an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     *     array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * <li>The <code>src</code> argument and <code>dest</code> argument refer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     *     to arrays whose component types are different primitive types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * <li>The <code>src</code> argument refers to an array with a primitive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     *    component type and the <code>dest</code> argument refers to an array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     *     with a reference component type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * <li>The <code>src</code> argument refers to an array with a reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     *    component type and the <code>dest</code> argument refers to an array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     *     with a primitive component type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * Otherwise, if any of the following is true, an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * <code>IndexOutOfBoundsException</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * thrown and the destination is not modified:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * <li>The <code>srcPos</code> argument is negative.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * <li>The <code>destPos</code> argument is negative.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * <li>The <code>length</code> argument is negative.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * <li><code>srcPos+length</code> is greater than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     *     <code>src.length</code>, the length of the source array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * <li><code>destPos+length</code> is greater than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     *     <code>dest.length</code>, the length of the destination array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * Otherwise, if any actual component of the source array from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * position <code>srcPos</code> through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * <code>srcPos+length-1</code> cannot be converted to the component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * type of the destination array by assignment conversion, an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * <code>ArrayStoreException</code> is thrown. In this case, let
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * <b><i>k</i></b> be the smallest nonnegative integer less than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * length such that <code>src[srcPos+</code><i>k</i><code>]</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * cannot be converted to the component type of the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * array; when the exception is thrown, source array components from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * positions <code>srcPos</code> through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * <code>srcPos+</code><i>k</i><code>-1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * will already have been copied to destination array positions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * <code>destPos</code> through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * <code>destPos+</code><i>k</I><code>-1</code> and no other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * positions of the destination array will have been modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * (Because of the restrictions already itemized, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * paragraph effectively applies only to the situation where both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * arrays have component types that are reference types.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * @param      src      the source array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * @param      srcPos   starting position in the source array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * @param      dest     the destination array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * @param      destPos  starting position in the destination data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * @param      length   the number of array elements to be copied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * @exception  IndexOutOfBoundsException  if copying would cause
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     *               access of data outside array bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * @exception  ArrayStoreException  if an element in the <code>src</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     *               array could not be stored into the <code>dest</code> array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     *               because of a type mismatch.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * @exception  NullPointerException if either <code>src</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     *               <code>dest</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     */
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 29986
diff changeset
   492
    @HotSpotIntrinsicCandidate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    public static native void arraycopy(Object src,  int  srcPos,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                                        Object dest, int destPos,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                                        int length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * Returns the same hash code for the given object as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * would be returned by the default method hashCode(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * whether or not the given object's class overrides
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * hashCode().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * The hash code for the null reference is zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * @param x object for which the hashCode is to be calculated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * @return  the hashCode
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 24367
diff changeset
   506
     * @since   1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     */
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 29986
diff changeset
   508
    @HotSpotIntrinsicCandidate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    public static native int identityHashCode(Object x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * System properties. The following properties are guaranteed to be defined:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * <dl>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * <dt>java.version         <dd>Java version number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * <dt>java.vendor          <dd>Java vendor specific string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * <dt>java.vendor.url      <dd>Java vendor URL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * <dt>java.home            <dd>Java installation directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * <dt>java.class.version   <dd>Java class version number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * <dt>java.class.path      <dd>Java classpath
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * <dt>os.name              <dd>Operating System Name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * <dt>os.arch              <dd>Operating System Architecture
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * <dt>os.version           <dd>Operating System Version
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * <dt>file.separator       <dd>File separator ("/" on Unix)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * <dt>path.separator       <dd>Path separator (":" on Unix)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * <dt>line.separator       <dd>Line separator ("\n" on Unix)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * <dt>user.name            <dd>User account name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * <dt>user.home            <dd>User home directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * <dt>user.dir             <dd>User's current working directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * </dl>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    private static Properties props;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    private static native Properties initProperties(Properties props);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * Determines the current system properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * First, if there is a security manager, its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * <code>checkPropertiesAccess</code> method is called with no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * arguments. This may result in a security exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * The current set of system properties for use by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * {@link #getProperty(String)} method is returned as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * <code>Properties</code> object. If there is no current set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * system properties, a set of system properties is first created and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * initialized. This set of system properties always includes values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * for the following keys:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * <table summary="Shows property keys and associated values">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * <tr><th>Key</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     *     <th>Description of Associated Value</th></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * <tr><td><code>java.version</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     *     <td>Java Runtime Environment version</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * <tr><td><code>java.vendor</code></td>
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 12038
diff changeset
   554
     *     <td>Java Runtime Environment vendor</td></tr>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * <tr><td><code>java.vendor.url</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     *     <td>Java vendor URL</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * <tr><td><code>java.home</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     *     <td>Java installation directory</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * <tr><td><code>java.vm.specification.version</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     *     <td>Java Virtual Machine specification version</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * <tr><td><code>java.vm.specification.vendor</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     *     <td>Java Virtual Machine specification vendor</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * <tr><td><code>java.vm.specification.name</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     *     <td>Java Virtual Machine specification name</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * <tr><td><code>java.vm.version</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     *     <td>Java Virtual Machine implementation version</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * <tr><td><code>java.vm.vendor</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     *     <td>Java Virtual Machine implementation vendor</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * <tr><td><code>java.vm.name</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     *     <td>Java Virtual Machine implementation name</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * <tr><td><code>java.specification.version</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     *     <td>Java Runtime Environment specification  version</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * <tr><td><code>java.specification.vendor</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     *     <td>Java Runtime Environment specification  vendor</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * <tr><td><code>java.specification.name</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     *     <td>Java Runtime Environment specification  name</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * <tr><td><code>java.class.version</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     *     <td>Java class format version number</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * <tr><td><code>java.class.path</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     *     <td>Java class path</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * <tr><td><code>java.library.path</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     *     <td>List of paths to search when loading libraries</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * <tr><td><code>java.io.tmpdir</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     *     <td>Default temp file path</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * <tr><td><code>java.compiler</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     *     <td>Name of JIT compiler to use</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * <tr><td><code>os.name</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     *     <td>Operating system name</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * <tr><td><code>os.arch</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     *     <td>Operating system architecture</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * <tr><td><code>os.version</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     *     <td>Operating system version</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * <tr><td><code>file.separator</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     *     <td>File separator ("/" on UNIX)</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * <tr><td><code>path.separator</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     *     <td>Path separator (":" on UNIX)</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * <tr><td><code>line.separator</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     *     <td>Line separator ("\n" on UNIX)</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * <tr><td><code>user.name</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     *     <td>User's account name</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * <tr><td><code>user.home</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     *     <td>User's home directory</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * <tr><td><code>user.dir</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     *     <td>User's current working directory</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * Multiple paths in a system property value are separated by the path
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * separator character of the platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * Note that even if the security manager does not permit the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     * <code>getProperties</code> operation, it may choose to permit the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * {@link #getProperty(String)} operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * @return     the system properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     *             <code>checkPropertiesAccess</code> method doesn't allow access
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     *              to the system properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * @see        #setProperties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * @see        java.lang.SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * @see        java.lang.SecurityManager#checkPropertiesAccess()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * @see        java.util.Properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    public static Properties getProperties() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        SecurityManager sm = getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        if (sm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            sm.checkPropertiesAccess();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        return props;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    /**
4355
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   633
     * Returns the system-dependent line separator string.  It always
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   634
     * returns the same value - the initial value of the {@linkplain
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   635
     * #getProperty(String) system property} {@code line.separator}.
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   636
     *
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   637
     * <p>On UNIX systems, it returns {@code "\n"}; on Microsoft
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   638
     * Windows systems it returns {@code "\r\n"}.
18546
862067c6481c 8017550: Fix doclint issues in java.lang and subpackages
darcy
parents: 17426
diff changeset
   639
     *
862067c6481c 8017550: Fix doclint issues in java.lang and subpackages
darcy
parents: 17426
diff changeset
   640
     * @return the system-dependent line separator string
10360
d1a6fafde2fa 7082231: Put a @since 1.7 on System.lineSeparator
darcy
parents: 9035
diff changeset
   641
     * @since 1.7
4355
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   642
     */
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   643
    public static String lineSeparator() {
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   644
        return lineSeparator;
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   645
    }
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   646
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   647
    private static String lineSeparator;
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   648
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
   649
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * Sets the system properties to the <code>Properties</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     * First, if there is a security manager, its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * <code>checkPropertiesAccess</code> method is called with no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * arguments. This may result in a security exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * The argument becomes the current set of system properties for use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * by the {@link #getProperty(String)} method. If the argument is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * <code>null</code>, then the current set of system properties is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     * forgotten.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     * @param      props   the new system properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     *             <code>checkPropertiesAccess</code> method doesn't allow access
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     *              to the system properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * @see        #getProperties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * @see        java.util.Properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     * @see        java.lang.SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * @see        java.lang.SecurityManager#checkPropertiesAccess()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    public static void setProperties(Properties props) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        SecurityManager sm = getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        if (sm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            sm.checkPropertiesAccess();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        if (props == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
            props = new Properties();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            initProperties(props);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        System.props = props;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * Gets the system property indicated by the specified key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * First, if there is a security manager, its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * <code>checkPropertyAccess</code> method is called with the key as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * its argument. This may result in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * If there is no current set of system properties, a set of system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * properties is first created and initialized in the same manner as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * for the <code>getProperties</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     * @param      key   the name of the system property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     * @return     the string value of the system property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     *             or <code>null</code> if there is no property with that key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     *             <code>checkPropertyAccess</code> method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     *              access to the specified system property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * @exception  NullPointerException if <code>key</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     *             <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * @exception  IllegalArgumentException if <code>key</code> is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * @see        #setProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * @see        java.lang.SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * @see        java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * @see        java.lang.System#getProperties()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    public static String getProperty(String key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        checkKey(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        SecurityManager sm = getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        if (sm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            sm.checkPropertyAccess(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        return props.getProperty(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * Gets the system property indicated by the specified key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * First, if there is a security manager, its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * <code>checkPropertyAccess</code> method is called with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * <code>key</code> as its argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * If there is no current set of system properties, a set of system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * properties is first created and initialized in the same manner as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * for the <code>getProperties</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * @param      key   the name of the system property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * @param      def   a default value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     * @return     the string value of the system property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     *             or the default value if there is no property with that key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     *             <code>checkPropertyAccess</code> method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
     *             access to the specified system property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * @exception  NullPointerException if <code>key</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     *             <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     * @exception  IllegalArgumentException if <code>key</code> is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * @see        #setProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     * @see        java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     * @see        java.lang.System#getProperties()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    public static String getProperty(String key, String def) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        checkKey(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        SecurityManager sm = getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        if (sm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
            sm.checkPropertyAccess(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        return props.getProperty(key, def);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     * Sets the system property indicated by the specified key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     * First, if a security manager exists, its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     * <code>SecurityManager.checkPermission</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     * is called with a <code>PropertyPermission(key, "write")</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     * permission. This may result in a SecurityException being thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     * If no exception is thrown, the specified property is set to the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     * value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * @param      key   the name of the system property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     * @param      value the value of the system property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * @return     the previous value of the system property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     *             or <code>null</code> if it did not have one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     *             <code>checkPermission</code> method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     *             setting of the specified property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * @exception  NullPointerException if <code>key</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     *             <code>value</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * @exception  IllegalArgumentException if <code>key</code> is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * @see        #getProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * @see        java.lang.System#getProperty(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     * @see        java.lang.System#getProperty(java.lang.String, java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * @see        java.util.PropertyPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     * @see        SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * @since      1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    public static String setProperty(String key, String value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        checkKey(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        SecurityManager sm = getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        if (sm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
            sm.checkPermission(new PropertyPermission(key,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                SecurityConstants.PROPERTY_WRITE_ACTION));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        return (String) props.setProperty(key, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     * Removes the system property indicated by the specified key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     * First, if a security manager exists, its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * <code>SecurityManager.checkPermission</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * is called with a <code>PropertyPermission(key, "write")</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * permission. This may result in a SecurityException being thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * If no exception is thrown, the specified property is removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     * @param      key   the name of the system property to be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * @return     the previous string value of the system property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     *             or <code>null</code> if there was no property with that key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     *             <code>checkPropertyAccess</code> method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     *              access to the specified system property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     * @exception  NullPointerException if <code>key</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     *             <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     * @exception  IllegalArgumentException if <code>key</code> is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
     * @see        #getProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     * @see        #setProperty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     * @see        java.util.Properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     * @see        java.lang.SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     * @see        java.lang.SecurityManager#checkPropertiesAccess()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    public static String clearProperty(String key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        checkKey(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        SecurityManager sm = getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        if (sm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
            sm.checkPermission(new PropertyPermission(key, "write"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        return (String) props.remove(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    private static void checkKey(String key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        if (key == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            throw new NullPointerException("key can't be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        if (key.equals("")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            throw new IllegalArgumentException("key can't be empty");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     * Gets the value of the specified environment variable. An
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * environment variable is a system-dependent external named
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     * value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * <p>If a security manager exists, its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     * {@link SecurityManager#checkPermission checkPermission}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     * method is called with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
     * <code>{@link RuntimePermission}("getenv."+name)</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     * permission.  This may result in a {@link SecurityException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     * being thrown.  If no exception is thrown the value of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     * variable <code>name</code> is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
     * <p><a name="EnvironmentVSSystemProperties"><i>System
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     * properties</i> and <i>environment variables</i></a> are both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
     * conceptually mappings between names and values.  Both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
     * mechanisms can be used to pass user-defined information to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
     * Java process.  Environment variables have a more global effect,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
     * because they are visible to all descendants of the process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
     * which defines them, not just the immediate Java subprocess.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
     * They can have subtly different semantics, such as case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
     * insensitivity, on different operating systems.  For these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
     * reasons, environment variables are more likely to have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
     * unintended side effects.  It is best to use system properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
     * where possible.  Environment variables should be used when a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
     * global effect is desired, or when an external system interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     * requires an environment variable (such as <code>PATH</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     * <p>On UNIX systems the alphabetic case of <code>name</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     * typically significant, while on Microsoft Windows systems it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     * typically not.  For example, the expression
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     * <code>System.getenv("FOO").equals(System.getenv("foo"))</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
     * is likely to be true on Microsoft Windows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
     * @param  name the name of the environment variable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
     * @return the string value of the variable, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     *         if the variable is not defined in the system environment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     * @throws NullPointerException if <code>name</code> is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
     *         if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
     *         {@link SecurityManager#checkPermission checkPermission}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
     *         method doesn't allow access to the environment variable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     *         <code>name</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     * @see    #getenv()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
     * @see    ProcessBuilder#environment()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    public static String getenv(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        SecurityManager sm = getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        if (sm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
            sm.checkPermission(new RuntimePermission("getenv."+name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        return ProcessEnvironment.getenv(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     * Returns an unmodifiable string map view of the current system environment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     * The environment is a system-dependent mapping from names to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     * values which is passed from parent to child processes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
     * <p>If the system does not support environment variables, an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
     * empty map is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
     * <p>The returned map will never contain null keys or values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     * Attempting to query the presence of a null key or value will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
     * throw a {@link NullPointerException}.  Attempting to query
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
     * the presence of a key or value which is not of type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
     * {@link String} will throw a {@link ClassCastException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
     * <p>The returned map and its collection views may not obey the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
     * general contract of the {@link Object#equals} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
     * {@link Object#hashCode} methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
     * <p>The returned map is typically case-sensitive on all platforms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
     * <p>If a security manager exists, its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
     * {@link SecurityManager#checkPermission checkPermission}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
     * method is called with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     * <code>{@link RuntimePermission}("getenv.*")</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     * permission.  This may result in a {@link SecurityException} being
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     * thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
     * <p>When passing information to a Java subprocess,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
     * <a href=#EnvironmentVSSystemProperties>system properties</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
     * are generally preferred over environment variables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     * @return the environment as a map of variable names to values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     *         if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
     *         {@link SecurityManager#checkPermission checkPermission}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
     *         method doesn't allow access to the process environment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
     * @see    #getenv(String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
     * @see    ProcessBuilder#environment()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
     * @since  1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
    public static java.util.Map<String,String> getenv() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        SecurityManager sm = getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        if (sm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
            sm.checkPermission(new RuntimePermission("getenv.*"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        return ProcessEnvironment.getenv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
     * Terminates the currently running Java Virtual Machine. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
     * argument serves as a status code; by convention, a nonzero status
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
     * code indicates abnormal termination.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * This method calls the <code>exit</code> method in class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     * <code>Runtime</code>. This method never returns normally.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * The call <code>System.exit(n)</code> is effectively equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     * the call:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
     * Runtime.getRuntime().exit(n)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
     * @param      status   exit status.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
     * @throws  SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
     *        if a security manager exists and its <code>checkExit</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
     *        method doesn't allow exit with the specified status.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
     * @see        java.lang.Runtime#exit(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
    public static void exit(int status) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        Runtime.getRuntime().exit(status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
     * Runs the garbage collector.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
     * Calling the <code>gc</code> method suggests that the Java Virtual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
     * Machine expend effort toward recycling unused objects in order to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     * make the memory they currently occupy available for quick reuse.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     * When control returns from the method call, the Java Virtual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
     * Machine has made a best effort to reclaim space from all discarded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     * objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
     * The call <code>System.gc()</code> is effectively equivalent to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     * call:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * Runtime.getRuntime().gc()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     * @see     java.lang.Runtime#gc()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
    public static void gc() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
        Runtime.getRuntime().gc();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     * Runs the finalization methods of any objects pending finalization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
     * Calling this method suggests that the Java Virtual Machine expend
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
     * effort toward running the <code>finalize</code> methods of objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
     * that have been found to be discarded but whose <code>finalize</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     * methods have not yet been run. When control returns from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
     * method call, the Java Virtual Machine has made a best effort to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * complete all outstanding finalizations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     * The call <code>System.runFinalization()</code> is effectively
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * equivalent to the call:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     * Runtime.getRuntime().runFinalization()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
     * @see     java.lang.Runtime#runFinalization()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
    public static void runFinalization() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
        Runtime.getRuntime().runFinalization();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
     * Enable or disable finalization on exit; doing so specifies that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
     * finalizers of all objects that have finalizers that have not yet been
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
     * automatically invoked are to be run before the Java runtime exits.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
     * By default, finalization on exit is disabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
     * <p>If there is a security manager,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
     * its <code>checkExit</code> method is first called
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
     * with 0 as its argument to ensure the exit is allowed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
     * This could result in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     * @deprecated  This method is inherently unsafe.  It may result in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     *      finalizers being called on live objects while other threads are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     *      concurrently manipulating those objects, resulting in erratic
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
     *      behavior or deadlock.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     * @param value indicating enabling or disabling of finalization
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * @throws  SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     *        if a security manager exists and its <code>checkExit</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     *        method doesn't allow the exit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
     * @see     java.lang.Runtime#exit(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     * @see     java.lang.Runtime#gc()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
     * @see     java.lang.SecurityManager#checkExit(int)
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 24367
diff changeset
  1035
     * @since   1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
    public static void runFinalizersOnExit(boolean value) {
11275
7cb0861d512f 7117612: Miscellaneous warnings in java.lang
omajid
parents: 11117
diff changeset
  1039
        Runtime.runFinalizersOnExit(value);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
    /**
16479
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1043
     * Loads the native library specified by the filename argument.  The filename
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1044
     * argument must be an absolute path name.
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1045
     *
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1046
     * If the filename argument, when stripped of any platform-specific library
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1047
     * prefix, path, and file extension, indicates a library whose name is,
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1048
     * for example, L, and a native library called L is statically linked
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1049
     * with the VM, then the JNI_OnLoad_L function exported by the library
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1050
     * is invoked rather than attempting to load a dynamic library.
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1051
     * A filename matching the argument does not have to exist in the
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1052
     * file system.
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1053
     * See the JNI Specification for more details.
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1054
     *
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1055
     * Otherwise, the filename argument is mapped to a native library image in
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1056
     * an implementation-dependent manner.
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1057
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
     * The call <code>System.load(name)</code> is effectively equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
     * to the call:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
     * Runtime.getRuntime().load(name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
     * @param      filename   the file to load.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
     *             <code>checkLink</code> method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
     *             loading of the specified dynamic library
16479
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1069
     * @exception  UnsatisfiedLinkError  if either the filename is not an
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1070
     *             absolute path name, the native library is not statically
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1071
     *             linked with the VM, or the library cannot be mapped to
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1072
     *             a native library image by the host system.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
     * @exception  NullPointerException if <code>filename</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
     *             <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
     * @see        java.lang.Runtime#load(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
     * @see        java.lang.SecurityManager#checkLink(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
     */
16906
44dfee24cb71 8010117: Annotate jdk caller sensitive methods with @sun.reflect.CallerSensitive
mchung
parents: 16479
diff changeset
  1078
    @CallerSensitive
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
    public static void load(String filename) {
16906
44dfee24cb71 8010117: Annotate jdk caller sensitive methods with @sun.reflect.CallerSensitive
mchung
parents: 16479
diff changeset
  1080
        Runtime.getRuntime().load0(Reflection.getCallerClass(), filename);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
    /**
16479
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1084
     * Loads the native library specified by the <code>libname</code>
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1085
     * argument.  The <code>libname</code> argument must not contain any platform
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1086
     * specific prefix, file extension or path. If a native library
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1087
     * called <code>libname</code> is statically linked with the VM, then the
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1088
     * JNI_OnLoad_<code>libname</code> function exported by the library is invoked.
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1089
     * See the JNI Specification for more details.
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1090
     *
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1091
     * Otherwise, the libname argument is loaded from a system library
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1092
     * location and mapped to a native library image in an implementation-
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1093
     * dependent manner.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
     * The call <code>System.loadLibrary(name)</code> is effectively
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
     * equivalent to the call
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
     * Runtime.getRuntime().loadLibrary(name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
     * @param      libname   the name of the library.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
     *             <code>checkLink</code> method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
     *             loading of the specified dynamic library
16479
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1105
     * @exception  UnsatisfiedLinkError if either the libname argument
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1106
     *             contains a file path, the native library is not statically
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1107
     *             linked with the VM,  or the library cannot be mapped to a
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 15511
diff changeset
  1108
     *             native library image by the host system.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
     * @exception  NullPointerException if <code>libname</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
     *             <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
     * @see        java.lang.Runtime#loadLibrary(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
     * @see        java.lang.SecurityManager#checkLink(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
     */
16906
44dfee24cb71 8010117: Annotate jdk caller sensitive methods with @sun.reflect.CallerSensitive
mchung
parents: 16479
diff changeset
  1114
    @CallerSensitive
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
    public static void loadLibrary(String libname) {
16906
44dfee24cb71 8010117: Annotate jdk caller sensitive methods with @sun.reflect.CallerSensitive
mchung
parents: 16479
diff changeset
  1116
        Runtime.getRuntime().loadLibrary0(Reflection.getCallerClass(), libname);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
     * Maps a library name into a platform-specific string representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
     * a native library.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     * @param      libname the name of the library.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
     * @return     a platform-dependent native library name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
     * @exception  NullPointerException if <code>libname</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     *             <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
     * @see        java.lang.System#loadLibrary(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
     * @see        java.lang.ClassLoader#findLibrary(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
     * @since      1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
    public static native String mapLibraryName(String libname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
    /**
11906
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1134
     * Create PrintStream for stdout/err based on encoding.
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1135
     */
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1136
    private static PrintStream newPrintStream(FileOutputStream fos, String enc) {
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1137
       if (enc != null) {
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1138
            try {
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1139
                return new PrintStream(new BufferedOutputStream(fos, 128), true, enc);
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1140
            } catch (UnsupportedEncodingException uee) {}
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1141
        }
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1142
        return new PrintStream(new BufferedOutputStream(fos, 128), true);
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1143
    }
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1144
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1145
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1146
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
     * Initialize the system class.  Called after thread initialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
    private static void initializeSystemClass() {
8399
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1150
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1151
        // VM might invoke JNU_NewStringPlatform() to set those encoding
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1152
        // sensitive properties (user.home, user.name, boot.class.path, etc.)
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1153
        // during "props" initialization, in which it may need access, via
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1154
        // System.getProperty(), to the related system encoding property that
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1155
        // have been initialized (put into "props") at early stage of the
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1156
        // initialization. So make sure the "props" is available at the
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1157
        // very beginning of the initialization and all system properties to
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1158
        // be put into it directly.
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1159
        props = new Properties();
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1160
        initProperties(props);  // initialized by the VM
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1161
6882
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
  1162
        // There are certain system configurations that may be controlled by
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
  1163
        // VM options such as the maximum amount of direct memory and
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
  1164
        // Integer cache size used to support the object identity semantics
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
  1165
        // of autoboxing.  Typically, the library will obtain these values
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
  1166
        // from the properties set by the VM.  If the properties are for
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
  1167
        // internal implementation use only, these properties should be
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
  1168
        // removed from the system properties.
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
  1169
        //
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
  1170
        // See java.lang.Integer.IntegerCache and the
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
  1171
        // sun.misc.VM.saveAndRemoveProperties method for example.
8399
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1172
        //
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1173
        // Save a private copy of the system properties object that
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1174
        // can only be accessed by the internal implementation.  Remove
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1175
        // certain system properties that are not intended for public access.
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1176
        sun.misc.VM.saveAndRemoveProperties(props);
0a7dab5d5922 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters
sherman
parents: 7668
diff changeset
  1177
6882
637546039be3 6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents: 6668
diff changeset
  1178
4355
12d58d6de82f 6900043: Add method to return line.separator property
martin
parents: 3288
diff changeset
  1179
        lineSeparator = props.getProperty("line.separator");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
        sun.misc.Version.init();
2425
99a19a90813e 6807702: Integer.valueOf cache should be configurable
alanb
parents: 2288
diff changeset
  1181
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
        FileInputStream fdIn = new FileInputStream(FileDescriptor.in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
        FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
        FileOutputStream fdErr = new FileOutputStream(FileDescriptor.err);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        setIn0(new BufferedInputStream(fdIn));
11906
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1186
        setOut0(newPrintStream(fdOut, props.getProperty("sun.stdout.encoding")));
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1187
        setErr0(newPrintStream(fdErr, props.getProperty("sun.stderr.encoding")));
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 11275
diff changeset
  1188
6668
bf6309ced0b6 6888546: restore System.initializeSystemClasses
mchung
parents: 6001
diff changeset
  1189
        // Load the zip library now in order to keep java.util.zip.ZipFile
bf6309ced0b6 6888546: restore System.initializeSystemClasses
mchung
parents: 6001
diff changeset
  1190
        // from trying to use itself to load this library later.
bf6309ced0b6 6888546: restore System.initializeSystemClasses
mchung
parents: 6001
diff changeset
  1191
        loadLibrary("zip");
bf6309ced0b6 6888546: restore System.initializeSystemClasses
mchung
parents: 6001
diff changeset
  1192
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
        // Setup Java signal handlers for HUP, TERM, and INT (where available).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
        Terminator.setup();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
25979
42e5d9f8087e 8054857: Fix typos in java.lang.** packages
prappo
parents: 25660
diff changeset
  1196
        // Initialize any miscellaneous operating system settings that need to be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
        // set for the class libraries. Currently this is no-op everywhere except
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
        // for Windows where the process-wide error mode is set before the java.io
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
        // classes are used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        sun.misc.VM.initializeOSEnvironment();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
        // The main thread is not added to its thread group in the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
        // way as other threads; we must do it ourselves here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
        Thread current = Thread.currentThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
        current.getThreadGroup().add(current);
6668
bf6309ced0b6 6888546: restore System.initializeSystemClasses
mchung
parents: 6001
diff changeset
  1206
bf6309ced0b6 6888546: restore System.initializeSystemClasses
mchung
parents: 6001
diff changeset
  1207
        // register shared secrets
bf6309ced0b6 6888546: restore System.initializeSystemClasses
mchung
parents: 6001
diff changeset
  1208
        setJavaLangAccess();
12038
ba8cfc6c5118 7149320: Move sun.misc.VM.booted() to the end of System.initializeSystemClass()
mduigou
parents: 11906
diff changeset
  1209
ba8cfc6c5118 7149320: Move sun.misc.VM.booted() to the end of System.initializeSystemClass()
mduigou
parents: 11906
diff changeset
  1210
        // Subsystems that are invoked during initialization can invoke
ba8cfc6c5118 7149320: Move sun.misc.VM.booted() to the end of System.initializeSystemClass()
mduigou
parents: 11906
diff changeset
  1211
        // sun.misc.VM.isBooted() in order to avoid doing things that should
ba8cfc6c5118 7149320: Move sun.misc.VM.booted() to the end of System.initializeSystemClass()
mduigou
parents: 11906
diff changeset
  1212
        // wait until the application class loader has been set up.
ba8cfc6c5118 7149320: Move sun.misc.VM.booted() to the end of System.initializeSystemClass()
mduigou
parents: 11906
diff changeset
  1213
        // IMPORTANT: Ensure that this remains the last initialization action!
ba8cfc6c5118 7149320: Move sun.misc.VM.booted() to the end of System.initializeSystemClass()
mduigou
parents: 11906
diff changeset
  1214
        sun.misc.VM.booted();
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2703
diff changeset
  1215
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2703
diff changeset
  1217
    private static void setJavaLangAccess() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
        // Allow privileged classes outside of java.lang
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
        sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess(){
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 10360
diff changeset
  1220
            public sun.reflect.ConstantPool getConstantPool(Class<?> klass) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
                return klass.getConstantPool();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
            }
18827
ecbd9c8bef12 7122142: (ann) Race condition between isAnnotationPresent and getAnnotations
plevart
parents: 18546
diff changeset
  1223
            public boolean casAnnotationType(Class<?> klass, AnnotationType oldType, AnnotationType newType) {
ecbd9c8bef12 7122142: (ann) Race condition between isAnnotationPresent and getAnnotations
plevart
parents: 18546
diff changeset
  1224
                return klass.casAnnotationType(oldType, newType);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
            }
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 10360
diff changeset
  1226
            public AnnotationType getAnnotationType(Class<?> klass) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
                return klass.getAnnotationType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
            }
21358
d41ff832d4f6 8027170: Annotations declared on super-super-class should be overridden by super-class.
alundblad
parents: 20831
diff changeset
  1229
            public Map<Class<? extends Annotation>, Annotation> getDeclaredAnnotationMap(Class<?> klass) {
d41ff832d4f6 8027170: Annotations declared on super-super-class should be overridden by super-class.
alundblad
parents: 20831
diff changeset
  1230
                return klass.getDeclaredAnnotationMap();
d41ff832d4f6 8027170: Annotations declared on super-super-class should be overridden by super-class.
alundblad
parents: 20831
diff changeset
  1231
            }
18827
ecbd9c8bef12 7122142: (ann) Race condition between isAnnotationPresent and getAnnotations
plevart
parents: 18546
diff changeset
  1232
            public byte[] getRawClassAnnotations(Class<?> klass) {
ecbd9c8bef12 7122142: (ann) Race condition between isAnnotationPresent and getAnnotations
plevart
parents: 18546
diff changeset
  1233
                return klass.getRawAnnotations();
ecbd9c8bef12 7122142: (ann) Race condition between isAnnotationPresent and getAnnotations
plevart
parents: 18546
diff changeset
  1234
            }
15510
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14676
diff changeset
  1235
            public byte[] getRawClassTypeAnnotations(Class<?> klass) {
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14676
diff changeset
  1236
                return klass.getRawTypeAnnotations();
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14676
diff changeset
  1237
            }
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14676
diff changeset
  1238
            public byte[] getRawExecutableTypeAnnotations(Executable executable) {
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14676
diff changeset
  1239
                return Class.getExecutableTypeAnnotationBytes(executable);
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 14676
diff changeset
  1240
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
            public <E extends Enum<E>>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
                    E[] getEnumConstantsShared(Class<E> klass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
                return klass.getEnumConstantsShared();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
            public void blockedOn(Thread t, Interruptible b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
                t.blockedOn(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
            }
2703
acd4d6a53e3e 6829503: addShutdownHook fails if called after shutdown has commenced.
mchung
parents: 2425
diff changeset
  1248
            public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
acd4d6a53e3e 6829503: addShutdownHook fails if called after shutdown has commenced.
mchung
parents: 2425
diff changeset
  1249
                Shutdown.add(slot, registerShutdownInProgress, hook);
2277
445a331b4a8b 6810254: Lazily instantiate the shared secret access objects
mchung
parents: 2
diff changeset
  1250
            }
2947
b0135c99348e 6511515: poor performance of LogRecord.inferCaller depending on java.lang.Throwable.getStackTraceElement
martin
parents: 2703
diff changeset
  1251
            public int getStackTraceDepth(Throwable t) {
b0135c99348e 6511515: poor performance of LogRecord.inferCaller depending on java.lang.Throwable.getStackTraceElement
martin
parents: 2703
diff changeset
  1252
                return t.getStackTraceDepth();
b0135c99348e 6511515: poor performance of LogRecord.inferCaller depending on java.lang.Throwable.getStackTraceElement
martin
parents: 2703
diff changeset
  1253
            }
b0135c99348e 6511515: poor performance of LogRecord.inferCaller depending on java.lang.Throwable.getStackTraceElement
martin
parents: 2703
diff changeset
  1254
            public StackTraceElement getStackTraceElement(Throwable t, int i) {
b0135c99348e 6511515: poor performance of LogRecord.inferCaller depending on java.lang.Throwable.getStackTraceElement
martin
parents: 2703
diff changeset
  1255
                return t.getStackTraceElement(i);
b0135c99348e 6511515: poor performance of LogRecord.inferCaller depending on java.lang.Throwable.getStackTraceElement
martin
parents: 2703
diff changeset
  1256
            }
17426
45db19517346 8013528: Provide SharedSecrets access to String(char[], boolean) constructor
mduigou
parents: 16906
diff changeset
  1257
            public String newStringUnsafe(char[] chars) {
45db19517346 8013528: Provide SharedSecrets access to String(char[], boolean) constructor
mduigou
parents: 16906
diff changeset
  1258
                return new String(chars, true);
45db19517346 8013528: Provide SharedSecrets access to String(char[], boolean) constructor
mduigou
parents: 16906
diff changeset
  1259
            }
20805
ae41216325dd 8013739: Better LDAP resource management
weijun
parents: 18546
diff changeset
  1260
            public Thread newThreadWithAcc(Runnable target, AccessControlContext acc) {
ae41216325dd 8013739: Better LDAP resource management
weijun
parents: 18546
diff changeset
  1261
                return new Thread(target, acc);
ae41216325dd 8013739: Better LDAP resource management
weijun
parents: 18546
diff changeset
  1262
            }
21628
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents: 21358
diff changeset
  1263
            public void invokeFinalize(Object o) throws Throwable {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents: 21358
diff changeset
  1264
                o.finalize();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents: 21358
diff changeset
  1265
            }
25660
01fa3ccedf50 8050114: Expose Integer/Long formatUnsigned methods internally
redestad
parents: 24865
diff changeset
  1266
            public void formatUnsignedLong(long val, int shift, char[] buf, int offset, int len) {
01fa3ccedf50 8050114: Expose Integer/Long formatUnsigned methods internally
redestad
parents: 24865
diff changeset
  1267
                Long.formatUnsignedLong(val, shift, buf, offset, len);
01fa3ccedf50 8050114: Expose Integer/Long formatUnsigned methods internally
redestad
parents: 24865
diff changeset
  1268
            }
01fa3ccedf50 8050114: Expose Integer/Long formatUnsigned methods internally
redestad
parents: 24865
diff changeset
  1269
            public void formatUnsignedInt(int val, int shift, char[] buf, int offset, int len) {
01fa3ccedf50 8050114: Expose Integer/Long formatUnsigned methods internally
redestad
parents: 24865
diff changeset
  1270
                Integer.formatUnsignedInt(val, shift, buf, offset, len);
01fa3ccedf50 8050114: Expose Integer/Long formatUnsigned methods internally
redestad
parents: 24865
diff changeset
  1271
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
}