From 4f9533c7722fa07511a94d005227961f4a4dec23 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 18 May 2006 17:29:21 +0000 Subject: Imported GNU Classpath 0.90 Imported GNU Classpath 0.90 * scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale. * sources.am: Regenerated. * gcj/javaprims.h: Regenerated. * Makefile.in: Regenerated. * gcj/Makefile.in: Regenerated. * include/Makefile.in: Regenerated. * testsuite/Makefile.in: Regenerated. * gnu/java/lang/VMInstrumentationImpl.java: New override. * gnu/java/net/local/LocalSocketImpl.java: Likewise. * gnu/classpath/jdwp/VMMethod.java: Likewise. * gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest interface. * java/lang/Thread.java: Add UncaughtExceptionHandler. * java/lang/reflect/Method.java: Implements GenericDeclaration and isSynthetic(), * java/lang/reflect/Field.java: Likewise. * java/lang/reflect/Constructor.java * java/lang/Class.java: Implements Type, GenericDeclaration, getSimpleName() and getEnclosing*() methods. * java/lang/Class.h: Add new public methods. * java/lang/Math.java: Add signum(), ulp() and log10(). * java/lang/natMath.cc (log10): New function. * java/security/VMSecureRandom.java: New override. * java/util/logging/Logger.java: Updated to latest classpath version. * java/util/logging/LogManager.java: New override. From-SVN: r113887 --- .../classpath/vm/reference/java/lang/VMSystem.java | 71 +++++++++++++++++----- 1 file changed, 55 insertions(+), 16 deletions(-) (limited to 'libjava/classpath/vm/reference/java/lang/VMSystem.java') diff --git a/libjava/classpath/vm/reference/java/lang/VMSystem.java b/libjava/classpath/vm/reference/java/lang/VMSystem.java index 8a83cad92ff..f96986df373 100644 --- a/libjava/classpath/vm/reference/java/lang/VMSystem.java +++ b/libjava/classpath/vm/reference/java/lang/VMSystem.java @@ -37,6 +37,8 @@ exception statement from your version. */ package java.lang; +import java.util.List; + import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.FileDescriptor; @@ -50,6 +52,7 @@ import java.io.PrintStream; * VM must implement. * * @author John Keiser + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) */ final class VMSystem { @@ -134,41 +137,77 @@ final class VMSystem */ public static native long currentTimeMillis(); + /** + *

+ * 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: + *

+ *

+ * long startTime = System.nanoTime();
+ * ... event code ...
+ * long endTime = System.nanoTime();
+ * long duration = endTime - startTime;
+ *

+ *

+ * 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. + *

+ * + * @return the time of a system timer in nanoseconds. + * @since 1.5 + */ + public static long nanoTime() + { + return currentTimeMillis() * 1000; + } + + /** + * Returns a list of 'name=value' pairs representing the current environment + * variables. + * + * @return a list of 'name=value' pairs. + */ + static native List environ(); + /** * Helper method which creates the standard input stream. * VM implementors may choose to construct these streams differently. * This method can also return null if the stream is created somewhere * else in the VM startup sequence. */ - - static InputStream makeStandardInputStream() - { - return new BufferedInputStream(new FileInputStream(FileDescriptor.in)); - } - + static InputStream makeStandardInputStream() + { + return new BufferedInputStream(new FileInputStream(FileDescriptor.in)); + } + /** * Helper method which creates the standard output stream. * VM implementors may choose to construct these streams differently. * This method can also return null if the stream is created somewhere * else in the VM startup sequence. */ + static PrintStream makeStandardOutputStream() + { + return new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out)), true); + } - static PrintStream makeStandardOutputStream() - { - return new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out)), true); - } /** * Helper method which creates the standard error stream. * VM implementors may choose to construct these streams differently. * This method can also return null if the stream is created somewhere * else in the VM startup sequence. */ - - static PrintStream makeStandardErrorStream() - { - return new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err)), true); - } - + static PrintStream makeStandardErrorStream() + { + return new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err)), true); + } + /** * Gets the value of an environment variable. * Always returning null is a valid (but not very useful) implementation. -- cgit v1.2.1