diff options
author | doko <doko@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-10-22 18:19:29 +0000 |
---|---|---|
committer | doko <doko@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-10-22 18:19:29 +0000 |
commit | c9197a91e180703238925902f4ec0203cf2d6da4 (patch) | |
tree | 577596282d00bf61e1bf433dc5d7aa0a417f5c5c /libjava/classpath/java/lang | |
parent | b7860e648ee8150622ae3c006b183b76defa12cb (diff) | |
download | gcc-c9197a91e180703238925902f4ec0203cf2d6da4.tar.gz |
2008-10-22 Matthias Klose <doko@ubuntu.com>
Import GNU Classpath (libgcj-import-20081021).
* Regenerate class and header files.
* Regenerate auto* files.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141302 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/java/lang')
-rw-r--r-- | libjava/classpath/java/lang/System.java | 28 | ||||
-rw-r--r-- | libjava/classpath/java/lang/ThreadLocal.java | 7 |
2 files changed, 22 insertions, 13 deletions
diff --git a/libjava/classpath/java/lang/System.java b/libjava/classpath/java/lang/System.java index 9fd6bfe12cd..58b1bbad3d1 100644 --- a/libjava/classpath/java/lang/System.java +++ b/libjava/classpath/java/lang/System.java @@ -546,20 +546,28 @@ public final class System SecurityManager sm = SecurityManager.current; // Be thread-safe. if (sm != null) sm.checkPermission(new RuntimePermission("getenv.*")); + if (environmentMap == null) { - List<String> environ = (List<String>)VMSystem.environ(); Map<String,String> variables = new EnvironmentMap(); - for (String pair : environ) - { - String[] parts = pair.split("="); - if (parts.length == 2) - variables.put(parts[0], parts[1]); - else - variables.put(parts[0], ""); - } - environmentMap = Collections.unmodifiableMap(variables); + List<String> environ = (List<String>)VMSystem.environ(); + for (String envEntry : environ) + { + // avoid broken and null entries + if (envEntry != null && !envEntry.endsWith("=")) + { + // it's perfectly legal that some entries may be in the form + // key=value=value=value + int equalSignIndex = envEntry.indexOf('='); + String key = envEntry.substring(0, equalSignIndex); + String value = envEntry.substring(equalSignIndex + 1); + variables.put(key, value); + } + } + + environmentMap = Collections.unmodifiableMap(variables); } + return environmentMap; } diff --git a/libjava/classpath/java/lang/ThreadLocal.java b/libjava/classpath/java/lang/ThreadLocal.java index 14778c65c2f..1f60a55539b 100644 --- a/libjava/classpath/java/lang/ThreadLocal.java +++ b/libjava/classpath/java/lang/ThreadLocal.java @@ -90,7 +90,7 @@ public class ThreadLocal<T> * user. Do not expose this to the public. Package visible for use by * InheritableThreadLocal */ - static final Object notFound = new Object(); + static final Object sentinel = new Object(); /** * The base for the computation of the next hash for a thread local. @@ -100,7 +100,8 @@ public class ThreadLocal<T> /** * Allocate a new hash. */ - private synchronized int computeNextHash() { + private synchronized int computeNextHash() + { return nextHashBase++ * 6709; } @@ -144,7 +145,7 @@ public class ThreadLocal<T> // Note that we don't have to synchronize, as only this thread will // ever modify the map. T value = (T) map.get(this); - if (value == notFound) + if (value == sentinel) { value = initialValue(); map.set(this, value); |