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 final 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
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}
896 * classes.
897 */
|
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 final 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
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 * Indicates that the caller is momentarily unable to progress, until the
880 * occurrence of one or more actions on the part of other activities. By
881 * invoking this method within each iteration of a spin-wait loop construct,
882 * the calling thread indicates to the runtime that it is busy-waiting. The runtime
883 * may take action to improve the performance of invoking spin-wait loop
884 * constructions.
885 */
886 @HotSpotIntrinsicCandidate
887 public static void onSpinWait() { }
888
889 /**
890 * Creates a localized version of an input stream. This method takes
891 * an {@code InputStream} and returns an {@code InputStream}
892 * equivalent to the argument in all respects except that it is
893 * localized: as characters in the local character set are read from
894 * the stream, they are automatically converted from the local
895 * character set to Unicode.
896 * <p>
897 * If the argument is already a localized stream, it may be returned
898 * as the result.
899 *
900 * @param in InputStream to localize
901 * @return a localized input stream
902 * @see java.io.InputStream
903 * @see java.io.BufferedReader#BufferedReader(java.io.Reader)
904 * @see java.io.InputStreamReader#InputStreamReader(java.io.InputStream)
905 * @deprecated As of JDK 1.1, the preferred way to translate a byte
906 * stream in the local encoding into a character stream in Unicode is via
907 * the {@code InputStreamReader} and {@code BufferedReader}
908 * classes.
909 */
|