package java.lang;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilterInputStream;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.util.Properties;
import java.util.PropertyPermission;
import java.util.TimeZone;
public final class System
{
public static native void arraycopy (Object src, int srcOffset,
Object dst, int dstOffset,
int count);
public static native long currentTimeMillis ();
private static native String getSystemTimeZone ();
private static String getDefaultTimeZoneId ()
{
String sysTimeZoneId = getSystemTimeZone ();
TimeZone tz = TimeZone.getTimeZone (sysTimeZoneId);
if (tz.getID ().equals (sysTimeZoneId))
return sysTimeZoneId;
int startGMToffset = 0;
int sysTimeZoneIdLength = sysTimeZoneId.length();
for (int i = 0; i < sysTimeZoneIdLength && startGMToffset == 0; i++)
{
if (Character.isDigit (sysTimeZoneId.charAt (i)))
startGMToffset = i;
}
int startDaylightZoneName = 0;
boolean usesDaylight = false;
for (int i = sysTimeZoneIdLength - 1;
i >= 0 && !Character.isDigit (sysTimeZoneId.charAt (i)); --i)
{
startDaylightZoneName = i;
}
if (startDaylightZoneName > 0)
usesDaylight = true;
int GMToffset = Integer.parseInt (startDaylightZoneName == 0 ?
sysTimeZoneId.substring (startGMToffset) :
sysTimeZoneId.substring (startGMToffset, startDaylightZoneName));
if (GMToffset < 24)
GMToffset *= 60 * 60;
GMToffset *= -1000;
String tzBasename = sysTimeZoneId.substring (0, startGMToffset);
tz = TimeZone.getTimeZone (tzBasename);
if (tz.getID ().equals (tzBasename) && tz.getRawOffset () == GMToffset)
{
boolean tzUsesDaylight = tz.useDaylightTime ();
if (usesDaylight && tzUsesDaylight || !usesDaylight && !tzUsesDaylight)
return tzBasename;
}
String[] IDs = TimeZone.getAvailableIDs (GMToffset);
for (int i = 0; i < IDs.length; ++i)
{
boolean IDusesDaylight =
TimeZone.getTimeZone (IDs[i]).useDaylightTime ();
if (usesDaylight && IDusesDaylight || !usesDaylight && !IDusesDaylight)
return IDs[i];
}
return null;
}
public static void exit (int status)
{
Runtime.getRuntime().exit(status);
}
public static void gc ()
{
Runtime.getRuntime().gc();
}
public static String getenv (String name)
{
throw new Error ();
}
private static native void init_properties ();
public static Properties getProperties ()
{
if (secman != null)
secman.checkPropertiesAccess();
if (properties == null)
init_properties ();
return properties;
}
public static String getProperty (String property)
{
if (secman != null)
secman.checkPropertyAccess(property);
if (properties == null)
init_properties ();
return properties.getProperty(property);
}
public static String getProperty (String property, String defval)
{
if (secman != null)
secman.checkPropertyAccess(property);
if (properties == null)
init_properties ();
return properties.getProperty(property, defval);
}
public static SecurityManager getSecurityManager ()
{
return secman;
}
public static native int identityHashCode (Object obj);
public static void load (String pathname)
{
Runtime.getRuntime().load(pathname);
}
public static void loadLibrary (String libname)
{
Runtime.getRuntime().loadLibrary(libname);
}
public static void runFinalization ()
{
Runtime.getRuntime().runFinalization();
}
public static void runFinalizersOnExit (boolean run)
{
Runtime.getRuntime().runFinalizersOnExit(run);
}
private static void checkSetIO ()
{
if (secman != null)
secman.checkExec("");
}
public static native void setErr (PrintStream newErr);
public static native void setIn (InputStream newIn);
public static native void setOut (PrintStream newOut);
public static void setProperties (Properties props)
{
if (secman != null)
secman.checkPropertiesAccess();
synchronized (System.class)
{
properties = props;
}
}
public static String setProperty (String key, String value)
{
if (secman != null)
secman.checkPermission (new PropertyPermission (key, "write"));
if (properties == null)
init_properties ();
return (String) properties.setProperty (key, value);
}
public static void setSecurityManager (SecurityManager s)
{
if (secman != null)
secman.checkPermission(new RuntimePermission("setSecurityManager"));
secman = s;
}
public static final InputStream in = new BufferedInputStream (new FileInputStream (FileDescriptor.in));
public static final PrintStream out = new PrintStream (new BufferedOutputStream (new FileOutputStream (FileDescriptor.out)), true);
public static final PrintStream err = new PrintStream (new BufferedOutputStream (new FileOutputStream (FileDescriptor.err)), true);
private System ()
{
}
private static SecurityManager secman = null;
private static Properties properties = null;
}