1 // System.java - System-specific info.
3 /* Copyright (C) 1998, 1999 Red Hat, Inc.
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
13 import java.io.FileDescriptor;
14 import java.io.FileInputStream;
15 import java.io.FileOutputStream;
16 import java.io.FilterInputStream;
17 import java.io.InputStream;
18 import java.io.PrintStream;
19 import java.io.BufferedInputStream;
20 import java.io.BufferedOutputStream;
21 import java.util.Properties;
24 * @author Tom Tromey <tromey@cygnus.com>
25 * @date August 27, 1998
28 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
29 * "The Java Language Specification", ISBN 0-201-63451-1
30 * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
31 * Status: 1.1. Some 1.2 methods missing. Properties code not fully
35 public final class System
37 public static native void arraycopy (Object src, int srcOffset,
38 Object dst, int dstOffset,
41 public static native long currentTimeMillis ();
43 public static void exit (int status)
45 Runtime.getRuntime().exit(status);
48 public static void gc ()
50 Runtime.getRuntime().gc();
53 // Marked deprecated in 1.1. We implement what the JCL book says.
54 public static String getenv (String name)
59 private static native void init_properties ();
61 public static Properties getProperties ()
64 secman.checkPropertiesAccess();
69 public static String getProperty (String property)
72 secman.checkPropertyAccess(property);
74 return properties.getProperty(property);
77 public static String getProperty (String property, String defval)
80 secman.checkPropertyAccess(property, defval);
82 return properties.getProperty(property, defval);
85 public static SecurityManager getSecurityManager ()
90 public static native int identityHashCode (Object obj);
92 public static void load (String pathname)
94 Runtime.getRuntime().load(pathname);
97 public static void loadLibrary (String libname)
99 Runtime.getRuntime().loadLibrary(libname);
102 public static void runFinalization ()
104 Runtime.getRuntime().runFinalization();
107 // Marked as deprecated in 1.2.
108 public static void runFinalizersOnExit (boolean run)
110 Runtime.getRuntime().runFinalizersOnExit(run);
113 private static void checkSetIO ()
115 // In 1.1, we are supposed to call checkExec, but the argument is
116 // not specified. In 1.2, we are supposed to use checkPermission,
117 // which doesn't exist in 1.1.
119 secman.checkExec("");
122 public static native void setErr (PrintStream newErr);
123 public static native void setIn (InputStream newIn);
124 public static native void setOut (PrintStream newOut);
126 public static void setProperties (Properties props)
129 secman.checkPropertiesAccess();
130 // We might not have initialized yet.
136 // public static String setProperty (String key, String value);
139 // public static String mapLibraryName (String libname);
141 public static void setSecurityManager (SecurityManager s)
144 throw new SecurityException ();
149 public static final InputStream in = new BufferedInputStream (new FileInputStream (FileDescriptor.in));
151 public static final PrintStream out = new PrintStream (new BufferedOutputStream (new FileOutputStream (FileDescriptor.out)), true);
153 public static final PrintStream err = new PrintStream (new BufferedOutputStream (new FileOutputStream (FileDescriptor.err)), true);
155 // Don't allow System objects to be made.
161 private static SecurityManager secman = null;
162 private static Properties properties = null;
163 // This boolean is only required for 1.1 and earlier. After 1.1, a
164 // null properties should always be re-initialized.
165 private static boolean prop_init = false;