From ee141b882274c83730b641028543aaa2ca59dcc4 Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Mon, 25 Apr 2005 19:48:35 +0000 Subject: [multiple changes] 2005-04-25 Archie Cobbs * java/lang/Throwable.java: simplify initializing cause in constructor 2005-04-25 Michael Koch * gnu/classpath/SystemProperties.java: New file. * gnu/classpath/natSystemProperties.cc: New file. * java/lang/Runtime.java (defaultProperties): Removed. (static): Likewise. (): Made thrown exceptions more verbose. (insertSystemProperties): Removed. * java/lang/System.java (static): Likewise. (properties): Likewise. (setSecurityManager): Reordered modifiers. (getenv): Improved javadoc. (): Likewise. (isWordsBigEndian): Removed. * java/lang/natRuntime.cc (_Jv_SetDLLSearchPath): Likewise. (file_encoding): Likewise. (default_file_encoding): Likewise. (getpwuid_adaptor): Likewise. (insertSystemProperties): Likewise. * java/lang/natSystem.cc (isWordsBigEndian): Likewise. * Makefile.am (ordinary_java_source_files): Added gnu/classpath/SystemProperties.java. (nat_source_files): Added gnu/classpath/natSystemProperties.cc. * Makefile.in: Regenerated. From-SVN: r98734 --- libjava/java/lang/Runtime.java | 99 ++++-------------------------------------- 1 file changed, 8 insertions(+), 91 deletions(-) (limited to 'libjava/java/lang/Runtime.java') diff --git a/libjava/java/lang/Runtime.java b/libjava/java/lang/Runtime.java index 1094720404d..858b331c62b 100644 --- a/libjava/java/lang/Runtime.java +++ b/libjava/java/lang/Runtime.java @@ -1,5 +1,5 @@ /* Runtime.java -- access to the VM process - Copyright (C) 1998, 2002, 2003, 2004 Free Software Foundation + Copyright (C) 1998, 2002, 2003, 2004, 2005 Free Software Foundation This file is part of GNU Classpath. @@ -38,13 +38,14 @@ exception statement from your version. */ package java.lang; +import gnu.classpath.SystemProperties; + import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.HashSet; import java.util.Iterator; -import java.util.Properties; import java.util.Set; import java.util.StringTokenizer; @@ -72,47 +73,9 @@ public class Runtime */ static SecurityManager securityManager; - /** - * The default properties defined by the system. This is likewise located - * here instead of in Runtime, to avoid bootstrap issues; it is package - * visible to avoid overhead in java.lang. Note that System will add a - * few more properties to this collection, but that after that, it is - * treated as read-only. - * - * No matter what class you start initialization with, it defers to the - * superclass, therefore Object.<clinit> will be the first Java code - * executed. From there, the bootstrap sequence, up to the point that - * native libraries are loaded (as of March 24, when I traced this - * manually) is as follows: - * - * Object.<clinit> uses a String literal, possibly triggering initialization - * String.<clinit> calls WeakHashMap.<init>, triggering initialization - * AbstractMap, WeakHashMap, WeakHashMap$1 have no dependencies - * String.<clinit> calls CaseInsensitiveComparator.<init>, triggering - * initialization - * CaseInsensitiveComparator has no dependencies - * Object.<clinit> calls System.loadLibrary, triggering initialization - * System.<clinit> calls System.loadLibrary - * System.loadLibrary calls Runtime.getRuntime, triggering initialization - * Runtime.<clinit> calls Properties.<init>, triggering initialization - * Dictionary, Hashtable, and Properties have no dependencies - * Runtime.<clinit> calls VMRuntime.insertSystemProperties, triggering - * initialization of VMRuntime; the VM must make sure that there are - * not any harmful dependencies - * Runtime.<clinit> calls Runtime.<init> - * Runtime.<init> calls StringTokenizer.<init>, triggering initialization - * StringTokenizer has no dependencies - * System.loadLibrary calls Runtime.loadLibrary - * Runtime.loadLibrary should be able to load the library, although it - * will probably set off another string of initializations from - * ClassLoader first - */ - static Properties defaultProperties = new Properties(); - static { init(); - insertSystemProperties(defaultProperties); } /** @@ -134,8 +97,7 @@ public class Runtime private boolean finalizeOnExit; /** - * The one and only runtime instance. This must appear after the default - * properties have been initialized by the VM. + * The one and only runtime instance. */ private static final Runtime current = new Runtime(); @@ -146,12 +108,11 @@ public class Runtime { if (current != null) throw new InternalError("Attempt to recreate Runtime"); - + // We don't use libpath in the libgcj implementation. We still // set it to something to allow the various synchronizations to // work. libpath = new String[0]; - } /** @@ -322,15 +283,15 @@ public class Runtime if (sm != null) sm.checkPermission(new RuntimePermission("shutdownHooks")); if (hook.isAlive() || hook.getThreadGroup() == null) - throw new IllegalArgumentException(); + throw new IllegalArgumentException("The hook thread " + hook + " must not have been already run or started"); synchronized (libpath) { if (exitSequence != null) - throw new IllegalStateException(); + throw new IllegalStateException("The Virtual Machine is exiting. It is not possible anymore to add any hooks"); if (shutdownHooks == null) shutdownHooks = new HashSet(); // Lazy initialization. if (! shutdownHooks.add(hook)) - throw new IllegalArgumentException(); + throw new IllegalArgumentException(hook.toString() + " had already been inserted"); } } @@ -740,48 +701,4 @@ public class Runtime */ native Process execInternal(String[] cmd, String[] env, File dir) throws IOException; - - - /** - * Get the system properties. This is done here, instead of in System, - * because of the bootstrap sequence. Note that the native code should - * not try to use the Java I/O classes yet, as they rely on the properties - * already existing. The only safe method to use to insert these default - * system properties is {@link Properties#setProperty(String, String)}. - * - *

These properties MUST include: - *

- *
java.version
Java version number - *
java.vendor
Java vendor specific string - *
java.vendor.url
Java vendor URL - *
java.home
Java installation directory - *
java.vm.specification.version
VM Spec version - *
java.vm.specification.vendor
VM Spec vendor - *
java.vm.specification.name
VM Spec name - *
java.vm.version
VM implementation version - *
java.vm.vendor
VM implementation vendor - *
java.vm.name
VM implementation name - *
java.specification.version
Java Runtime Environment version - *
java.specification.vendor
Java Runtime Environment vendor - *
java.specification.name
Java Runtime Environment name - *
java.class.version
Java class version number - *
java.class.path
Java classpath - *
java.library.path
Path for finding Java libraries - *
java.io.tmpdir
Default temp file path - *
java.compiler
Name of JIT to use - *
java.ext.dirs
Java extension path - *
os.name
Operating System Name - *
os.arch
Operating System Architecture - *
os.version
Operating System Version - *
file.separator
File separator ("/" on Unix) - *
path.separator
Path separator (":" on Unix) - *
line.separator
Line separator ("\n" on Unix) - *
user.name
User account name - *
user.home
User home directory - *
user.dir
User's current working directory - *
- * - * @param p the Properties object to insert the system properties into - */ - static native void insertSystemProperties(Properties p); } // class Runtime -- cgit v1.2.3