2010-12-06 03:21:09 +00:00
|
|
|
/* Copyright (c) 2008-2010, Avian Contributors
|
2008-02-19 18:06:52 +00:00
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software
|
|
|
|
for any purpose with or without fee is hereby granted, provided
|
|
|
|
that the above copyright notice and this permission notice appear
|
|
|
|
in all copies.
|
|
|
|
|
|
|
|
There is NO WARRANTY for this software. See license.txt for
|
|
|
|
details. */
|
|
|
|
|
2007-06-25 01:34:07 +00:00
|
|
|
package java.lang;
|
|
|
|
|
2007-07-25 00:34:45 +00:00
|
|
|
import java.io.PrintStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.BufferedInputStream;
|
|
|
|
import java.io.BufferedOutputStream;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
import java.io.FileDescriptor;
|
2008-07-14 00:27:05 +00:00
|
|
|
import java.util.Properties;
|
2007-06-25 01:34:07 +00:00
|
|
|
|
2007-07-25 00:34:45 +00:00
|
|
|
public abstract class System {
|
2007-09-12 01:13:05 +00:00
|
|
|
private static Property properties;
|
|
|
|
|
2010-08-15 12:47:45 +00:00
|
|
|
private static SecurityManager securityManager;
|
2008-07-03 16:49:08 +00:00
|
|
|
// static {
|
|
|
|
// loadLibrary("natives");
|
|
|
|
// }
|
2007-06-25 01:34:07 +00:00
|
|
|
|
2007-07-25 00:34:45 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
public static final InputStream in
|
|
|
|
= new BufferedInputStream(new FileInputStream(FileDescriptor.in));
|
|
|
|
|
2007-07-07 23:47:35 +00:00
|
|
|
public static native void arraycopy(Object src, int srcOffset, Object dst,
|
|
|
|
int dstOffset, int length);
|
|
|
|
|
2007-08-27 13:46:17 +00:00
|
|
|
public static String getProperty(String name) {
|
2007-09-12 01:13:05 +00:00
|
|
|
for (Property p = properties; p != null; p = p.next) {
|
|
|
|
if (p.name.equals(name)) {
|
|
|
|
return p.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-26 18:13:21 +00:00
|
|
|
boolean[] found = new boolean[1];
|
|
|
|
String value = getProperty(name, found);
|
|
|
|
if (found[0]) return value;
|
2007-08-27 13:46:17 +00:00
|
|
|
|
2007-10-26 18:13:21 +00:00
|
|
|
value = getVMProperty(name, found);
|
|
|
|
if (found[0]) return value;
|
|
|
|
|
|
|
|
return null;
|
2007-08-27 13:46:17 +00:00
|
|
|
}
|
2008-07-03 15:16:32 +00:00
|
|
|
|
|
|
|
public static String getProperty(String name, String defaultValue) {
|
2008-07-03 16:49:08 +00:00
|
|
|
String result = getProperty(name);
|
|
|
|
if (result==null) {
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
return result;
|
2008-07-03 15:16:32 +00:00
|
|
|
}
|
|
|
|
|
2007-08-27 13:46:17 +00:00
|
|
|
|
2007-09-17 14:10:27 +00:00
|
|
|
public static String setProperty(String name, String value) {
|
2007-09-12 01:13:05 +00:00
|
|
|
for (Property p = properties; p != null; p = p.next) {
|
|
|
|
if (p.name.equals(name)) {
|
2007-09-17 14:10:27 +00:00
|
|
|
String oldValue = p.value;
|
2007-09-12 01:13:05 +00:00
|
|
|
p.value = value;
|
2007-09-17 14:10:27 +00:00
|
|
|
return oldValue;
|
2007-09-12 01:13:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
properties = new Property(name, value, properties);
|
2007-09-17 14:10:27 +00:00
|
|
|
return null;
|
2007-09-12 01:13:05 +00:00
|
|
|
}
|
|
|
|
|
2008-07-14 00:27:05 +00:00
|
|
|
public static Properties getProperties () {
|
|
|
|
Properties prop = new Properties();
|
|
|
|
for (Property p = properties; p != null; p = p.next) {
|
|
|
|
prop.put(p.name, p.value);
|
|
|
|
}
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2007-10-26 18:13:21 +00:00
|
|
|
private static native String getProperty(String name, boolean[] found);
|
2007-08-27 13:46:17 +00:00
|
|
|
|
2007-10-26 18:13:21 +00:00
|
|
|
private static native String getVMProperty(String name, boolean[] found);
|
2007-07-04 22:27:08 +00:00
|
|
|
|
2007-07-22 19:06:21 +00:00
|
|
|
public static native long currentTimeMillis();
|
|
|
|
|
2007-08-13 00:50:25 +00:00
|
|
|
public static native int identityHashCode(Object o);
|
|
|
|
|
2007-09-12 01:13:05 +00:00
|
|
|
public static String mapLibraryName(String name) {
|
|
|
|
if (name != null) {
|
|
|
|
return doMapLibraryName(name);
|
|
|
|
} else {
|
|
|
|
throw new NullPointerException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static native String doMapLibraryName(String name);
|
|
|
|
|
|
|
|
public static void load(String path) {
|
|
|
|
Runtime.getRuntime().load(path);
|
|
|
|
}
|
|
|
|
|
2007-07-21 17:50:26 +00:00
|
|
|
public static void loadLibrary(String name) {
|
|
|
|
Runtime.getRuntime().loadLibrary(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void gc() {
|
|
|
|
Runtime.getRuntime().gc();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void exit(int code) {
|
|
|
|
Runtime.getRuntime().exit(code);
|
|
|
|
}
|
2010-08-15 12:47:45 +00:00
|
|
|
|
|
|
|
public static SecurityManager getSecurityManager() {
|
|
|
|
return securityManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setSecurityManager(SecurityManager securityManager) {
|
|
|
|
System.securityManager = securityManager;
|
|
|
|
}
|
2007-09-12 01:13:05 +00:00
|
|
|
|
|
|
|
private static class Property {
|
|
|
|
public final String name;
|
|
|
|
public String value;
|
|
|
|
public final Property next;
|
|
|
|
|
|
|
|
public Property(String name, String value, Property next) {
|
|
|
|
this.name = name;
|
|
|
|
this.value = value;
|
|
|
|
this.next = next;
|
|
|
|
}
|
|
|
|
}
|
2007-06-25 01:34:07 +00:00
|
|
|
}
|