|
From: <ls...@us...> - 2007-01-07 05:41:45
|
Revision: 2994
http://jnode.svn.sourceforge.net/jnode/?rev=2994&view=rev
Author: lsantha
Date: 2007-01-06 21:41:44 -0800 (Sat, 06 Jan 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/lang/System.java
trunk/core/src/classpath/java/java/security/PrivilegedExceptionAction.java
trunk/core/src/classpath/vm/java/lang/Thread.java
Modified: trunk/core/src/classpath/java/java/lang/System.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/System.java 2007-01-07 05:41:17 UTC (rev 2993)
+++ trunk/core/src/classpath/java/java/lang/System.java 2007-01-07 05:41:44 UTC (rev 2994)
@@ -44,6 +44,14 @@
import java.io.InputStream;
import java.io.PrintStream;
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.Properties;
import java.util.PropertyPermission;
@@ -98,6 +106,11 @@
public static final PrintStream err = VMSystem.makeStandardErrorStream();
/**
+ * A cached copy of the environment variable map.
+ */
+ private static Map<String,String> environmentMap;
+
+ /**
* This class is uninstantiable.
*/
private System()
@@ -118,6 +131,7 @@
SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPermission(new RuntimePermission("setIO"));
+
VMSystem.setIn(in);
}
@@ -223,6 +237,38 @@
}
/**
+ * <p>
+ * Returns the current value of a nanosecond-precise system timer.
+ * The value of the timer is an offset relative to some arbitrary fixed
+ * time, which may be in the future (making the value negative). This
+ * method is useful for timing events where nanosecond precision is
+ * required. This is achieved by calling this method before and after the
+ * event, and taking the difference betweent the two times:
+ * </p>
+ * <p>
+ * <code>long startTime = System.nanoTime();</code><br />
+ * <code>... <emph>event code</emph> ...</code><br />
+ * <code>long endTime = System.nanoTime();</code><br />
+ * <code>long duration = endTime - startTime;</code><br />
+ * </p>
+ * <p>
+ * Note that the value is only nanosecond-precise, and not accurate; there
+ * is no guarantee that the difference between two values is really a
+ * nanosecond. Also, the value is prone to overflow if the offset
+ * exceeds 2^63.
+ * </p>
+ *
+ * @return the time of a system timer in nanoseconds.
+ * @since 1.5
+ */
+ public static long nanoTime()
+ {
+ //todo
+ throw new RuntimeException("Implement it");
+ //return VMSystem.nanoTime();
+ }
+
+ /**
* Copy one array onto another from <code>src[srcStart]</code> ...
* <code>src[srcStart+len-1]</code> to <code>dest[destStart]</code> ...
* <code>dest[destStart+len-1]</code>. First, the arguments are validated:
@@ -319,6 +365,7 @@
* <dt>gnu.java.io.encoding_scheme_alias.iso-latin-_?</dt> <dd>8859_?</dd>
* <dt>gnu.java.io.encoding_scheme_alias.latin?</dt> <dd>8859_?</dd>
* <dt>gnu.java.io.encoding_scheme_alias.utf-8</dt> <dd>UTF8</dd>
+ * <dt>gnu.javax.print.server</dt> <dd>Hostname of external CUPS server.</dd>
* </dl>
*
* @return the system properties, will never be null
@@ -364,7 +411,7 @@
SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPropertyAccess(key);
- else if (key.length() == 0)
+ if (key.length() == 0)
throw new IllegalArgumentException("key can't be empty");
return SystemProperties.getProperty(key);
}
@@ -385,6 +432,10 @@
SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPropertyAccess(key);
+ // This handles both the null pointer exception and the illegal
+ // argument exception.
+ if (key.length() == 0)
+ throw new IllegalArgumentException("key can't be empty");
return SystemProperties.getProperty(key, def);
}
@@ -405,6 +456,10 @@
SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPermission(new PropertyPermission(key, "write"));
+ // This handles both the null pointer exception and the illegal
+ // argument exception.
+ if (key.length() == 0)
+ throw new IllegalArgumentException("key can't be empty");
return SystemProperties.setProperty(key, value);
}
Modified: trunk/core/src/classpath/java/java/security/PrivilegedExceptionAction.java
===================================================================
--- trunk/core/src/classpath/java/java/security/PrivilegedExceptionAction.java 2007-01-07 05:41:17 UTC (rev 2993)
+++ trunk/core/src/classpath/java/java/security/PrivilegedExceptionAction.java 2007-01-07 05:41:44 UTC (rev 2994)
@@ -46,9 +46,9 @@
*
* @author Aaron M. Renn (ar...@ur...)
* @since 1.1
- * @status updated to 1.4
+ * @status updated to 1.5
*/
-public interface PrivilegedExceptionAction
+public interface PrivilegedExceptionAction<T>
{
/**
* This method performs an operation that requires higher privileges to
@@ -61,5 +61,5 @@
* @see AccessController#doPrivileged(PrivilegedExceptionAction,
* AccessControlContext)
*/
- Object run() throws Exception;
+ T run() throws Exception;
} // interface PrivilegedExceptionAction
Modified: trunk/core/src/classpath/vm/java/lang/Thread.java
===================================================================
--- trunk/core/src/classpath/vm/java/lang/Thread.java 2007-01-07 05:41:17 UTC (rev 2993)
+++ trunk/core/src/classpath/vm/java/lang/Thread.java 2007-01-07 05:41:44 UTC (rev 2994)
@@ -262,6 +262,56 @@
InheritableThreadLocal.newChildThread(this); // FDy : CLASSPATH patch ?
}
+ /**
+ * Allocate a new Thread object, as if by
+ * <code>Thread(group, null, name)</code>, and give it the specified stack
+ * size, in bytes. The stack size is <b>highly platform independent</b>,
+ * and the virtual machine is free to round up or down, or ignore it
+ * completely. A higher value might let you go longer before a
+ * <code>StackOverflowError</code>, while a lower value might let you go
+ * longer before an <code>OutOfMemoryError</code>. Or, it may do absolutely
+ * nothing! So be careful, and expect to need to tune this value if your
+ * virtual machine even supports it.
+ *
+ * @param group the group to put the Thread into
+ * @param target the Runnable object to execute
+ * @param name the name for the Thread
+ * @param size the stack size, in bytes; 0 to be ignored
+ * @throws NullPointerException if name is null
+ * @throws SecurityException if this thread cannot access <code>group</code>
+ * @throws IllegalThreadStateException if group is destroyed
+ * @since 1.4
+ */
+ public Thread(ThreadGroup group, Runnable target, String name, long size)
+ {
+ Thread current = currentThread();
+
+ if (group != null) {
+ group.checkAccess();
+ } else {
+ group = current.getThreadGroup();
+ }
+
+ if (group == null) {
+ throw new InternalError("Live thread has invalid group: " + name);
+ }
+
+ group.addThread(this);
+
+ this.group = group;
+ this.target = target;
+ this.name = name;
+ this.parent = current;
+
+ this.daemon = current.isDaemon();
+
+ this.vmThread = VmProcessor.current().createThread(this);
+ this.vmThread.setPriority(current.getPriority());
+ this.vmThread.updateName();
+
+ InheritableThreadLocal.newChildThread(this); // FDy : CLASSPATH patch ?
+ }
+
/**
* Create a new instance with a given group as containing group, a runnable
* as thread runner and a given name.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|