summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2005-01-02 22:20:07 +0000
committerTom Tromey <tromey@redhat.com>2005-01-02 22:20:07 +0000
commit80d061c1ae348fa1e4cdb5cfc0527a455f8d6bcc (patch)
treec834aaca4b3d32c0d50c1029ccfe2f58e948e24e
parentf57a3cd6cf088e0bcf3e15ee3f4438b496b32562 (diff)
downloadclasspath-80d061c1ae348fa1e4cdb5cfc0527a455f8d6bcc.tar.gz
* java/lang/System.java (getenv(String)): Rewrote.
(getenv): New method. * vm/reference/java/lang/VMSystem.java (getenv): New methods.
-rw-r--r--ChangeLog6
-rw-r--r--java/lang/System.java20
-rw-r--r--vm/reference/java/lang/VMSystem.java18
3 files changed, 40 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 9c96c19af..2cccd37dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-01-02 Tom Tromey <tromey@redhat.com>
+
+ * java/lang/System.java (getenv(String)): Rewrote.
+ (getenv): New method.
+ * vm/reference/java/lang/VMSystem.java (getenv): New methods.
+
2004-12-18 Tom Tromey <tromey@redhat.com>
* java/lang/String.java (String(StringBuilder)): Rewrote.
diff --git a/java/lang/System.java b/java/lang/System.java
index 31397d8c1..b9e05c95c 100644
--- a/java/lang/System.java
+++ b/java/lang/System.java
@@ -1,5 +1,5 @@
/* System.java -- useful methods to interface with the system
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.classpath.Configuration;
import java.io.InputStream;
import java.io.PrintStream;
+import java.util.Map;
import java.util.Properties;
import java.util.PropertyPermission;
@@ -625,8 +626,21 @@ public final class System
*/
public static String getenv(String name)
{
- throw new Error("getenv no longer supported, use properties instead: "
- + name);
+ SecurityManager sm = Runtime.securityManager; // Be thread-safe.
+ if (sm != null)
+ sm.checkPermission(new RuntimePermission("getenv." + name));
+ return VMSystem.getenv(name);
+ }
+
+ /**
+ * FIXME: document
+ */
+ public static Map<String, String> getenv()
+ {
+ SecurityManager sm = Runtime.securityManager; // Be thread-safe.
+ if (sm != null)
+ sm.checkPermission(new RuntimePermission("getenv.*"));
+ return VMSystem.getenv();
}
/**
diff --git a/vm/reference/java/lang/VMSystem.java b/vm/reference/java/lang/VMSystem.java
index 858ebb111..d3f4f0290 100644
--- a/vm/reference/java/lang/VMSystem.java
+++ b/vm/reference/java/lang/VMSystem.java
@@ -1,5 +1,5 @@
/* VMSystem.java -- helper for java.lang.system
- Copyright (C) 1998, 2002 Free Software Foundation
+ Copyright (C) 1998, 2002, 2005 Free Software Foundation
This file is part of GNU Classpath.
@@ -37,6 +37,7 @@ exception statement from your version. */
package java.lang;
+import java.util.Map;
import java.util.Properties;
import java.io.*;
@@ -138,6 +139,21 @@ final class VMSystem
public static native long currentTimeMillis();
/**
+ * Return an unmodifiable Map representing the current environment.
+ */
+ static native Map<String, String> getenv();
+
+ /**
+ * Return a single element from the current environment.
+ */
+ static String getenv(String k)
+ {
+ // Inefficient but portable default implementation.
+ Map<String, String> m = getenv();
+ return m.get(k);
+ }
+
+ /**
* 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