12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.lang;
27
28 import java.io.*;
29 import java.util.StringTokenizer;
30 import sun.reflect.CallerSensitive;
31 import sun.reflect.Reflection;
32
33 /**
34 * Every Java application has a single instance of class
35 * {@code Runtime} that allows the application to interface with
36 * the environment in which the application is running. The current
37 * runtime can be obtained from the {@code getRuntime} method.
38 * <p>
39 * An application cannot create its own instance of this class.
40 *
41 * @author unascribed
42 * @see java.lang.Runtime#getRuntime()
43 * @since 1.0
44 */
45
46 public class Runtime {
47 private static Runtime currentRuntime = new Runtime();
48
49 /**
50 * Returns the runtime object associated with the current Java application.
51 * Most of the methods of class {@code Runtime} are instance
856 * {@code null}
857 * @see java.lang.SecurityException
858 * @see java.lang.SecurityManager#checkLink(java.lang.String)
859 */
860 @CallerSensitive
861 public void loadLibrary(String libname) {
862 loadLibrary0(Reflection.getCallerClass(), libname);
863 }
864
865 synchronized void loadLibrary0(Class<?> fromClass, String libname) {
866 SecurityManager security = System.getSecurityManager();
867 if (security != null) {
868 security.checkLink(libname);
869 }
870 if (libname.indexOf((int)File.separatorChar) != -1) {
871 throw new UnsatisfiedLinkError(
872 "Directory separator should not appear in library name: " + libname);
873 }
874 ClassLoader.loadLibrary(fromClass, libname, false);
875 }
876
877 /**
878 * Creates a localized version of an input stream. This method takes
879 * an {@code InputStream} and returns an {@code InputStream}
880 * equivalent to the argument in all respects except that it is
881 * localized: as characters in the local character set are read from
882 * the stream, they are automatically converted from the local
883 * character set to Unicode.
884 * <p>
885 * If the argument is already a localized stream, it may be returned
886 * as the result.
887 *
888 * @param in InputStream to localize
889 * @return a localized input stream
890 * @see java.io.InputStream
891 * @see java.io.BufferedReader#BufferedReader(java.io.Reader)
892 * @see java.io.InputStreamReader#InputStreamReader(java.io.InputStream)
893 * @deprecated As of JDK 1.1, the preferred way to translate a byte
894 * stream in the local encoding into a character stream in Unicode is via
895 * the {@code InputStreamReader} and {@code BufferedReader}
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.lang;
27
28 import java.io.*;
29 import java.util.StringTokenizer;
30 import sun.reflect.CallerSensitive;
31 import sun.reflect.Reflection;
32 import jdk.internal.HotSpotIntrinsicCandidate;
33
34 /**
35 * Every Java application has a single instance of class
36 * {@code Runtime} that allows the application to interface with
37 * the environment in which the application is running. The current
38 * runtime can be obtained from the {@code getRuntime} method.
39 * <p>
40 * An application cannot create its own instance of this class.
41 *
42 * @author unascribed
43 * @see java.lang.Runtime#getRuntime()
44 * @since 1.0
45 */
46
47 public class Runtime {
48 private static Runtime currentRuntime = new Runtime();
49
50 /**
51 * Returns the runtime object associated with the current Java application.
52 * Most of the methods of class {@code Runtime} are instance
857 * {@code null}
858 * @see java.lang.SecurityException
859 * @see java.lang.SecurityManager#checkLink(java.lang.String)
860 */
861 @CallerSensitive
862 public void loadLibrary(String libname) {
863 loadLibrary0(Reflection.getCallerClass(), libname);
864 }
865
866 synchronized void loadLibrary0(Class<?> fromClass, String libname) {
867 SecurityManager security = System.getSecurityManager();
868 if (security != null) {
869 security.checkLink(libname);
870 }
871 if (libname.indexOf((int)File.separatorChar) != -1) {
872 throw new UnsatisfiedLinkError(
873 "Directory separator should not appear in library name: " + libname);
874 }
875 ClassLoader.loadLibrary(fromClass, libname, false);
876 }
877
878 /**
879 * Method signifying that the caller is momentarily unable to
880 * progress until the occurrence of one or more actions of one or
881 * more other activities. When invoked within each iteration, this
882 * method typically improves performance of spin wait loop
883 * constructions.
884 */
885 @HotSpotIntrinsicCandidate
886 public static void onSpinWait() {};
887
888 /**
889 * Creates a localized version of an input stream. This method takes
890 * an {@code InputStream} and returns an {@code InputStream}
891 * equivalent to the argument in all respects except that it is
892 * localized: as characters in the local character set are read from
893 * the stream, they are automatically converted from the local
894 * character set to Unicode.
895 * <p>
896 * If the argument is already a localized stream, it may be returned
897 * as the result.
898 *
899 * @param in InputStream to localize
900 * @return a localized input stream
901 * @see java.io.InputStream
902 * @see java.io.BufferedReader#BufferedReader(java.io.Reader)
903 * @see java.io.InputStreamReader#InputStreamReader(java.io.InputStream)
904 * @deprecated As of JDK 1.1, the preferred way to translate a byte
905 * stream in the local encoding into a character stream in Unicode is via
906 * the {@code InputStreamReader} and {@code BufferedReader}
|