diff options
author | Michael Koch <konqueror@gmx.de> | 2003-04-29 11:36:34 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2003-04-29 11:36:34 +0000 |
commit | fbba7d685098eb2173db34b4e2dab4118cd47edb (patch) | |
tree | 627f67833f4cfa61711be0c631b952ae3de6e5ed /libjava/java/util | |
parent | cac9b0bcb14159dc05310d74adad4378a0e339bf (diff) | |
download | gcc-fbba7d685098eb2173db34b4e2dab4118cd47edb.zip gcc-fbba7d685098eb2173db34b4e2dab4118cd47edb.tar.gz gcc-fbba7d685098eb2173db34b4e2dab4118cd47edb.tar.bz2 |
PropertyPermission.java: New version from classpath
2003-04-29 Michael Koch <konqueror@gmx.de>
* java/util/PropertyPermission.java:
New version from classpath
* java/util/ResourceBundle.java:
Partly merged from classpath
(getObject): Reformated.
(tryBundle): Set foundBundle = null if no bundle found.
From-SVN: r66214
Diffstat (limited to 'libjava/java/util')
-rw-r--r-- | libjava/java/util/PropertyPermission.java | 29 | ||||
-rw-r--r-- | libjava/java/util/ResourceBundle.java | 8 |
2 files changed, 31 insertions, 6 deletions
diff --git a/libjava/java/util/PropertyPermission.java b/libjava/java/util/PropertyPermission.java index bb03e45..0d439d8 100644 --- a/libjava/java/util/PropertyPermission.java +++ b/libjava/java/util/PropertyPermission.java @@ -121,7 +121,7 @@ public final class PropertyPermission extends BasicPermission super(name); if (actions == null) throw new IllegalArgumentException(); - setActions(actions.toLowerCase()); + setActions(actions); } /** @@ -134,14 +134,37 @@ public final class PropertyPermission extends BasicPermission */ private void setActions(String str) { + // Initialising the class java.util.Locale ... + // tries to initialise the Locale.defaultLocale static + // which calls System.getProperty, + // which calls SecurityManager.checkPropertiesAccess, + // which creates a PropertyPermission with action "read,write", + // which calls setActions("read,write"). + // If we now were to call toLowerCase on 'str', + // this would call Locale.getDefault() which returns null + // because Locale.defaultLocale hasn't been set yet + // then toLowerCase will fail with a null pointer exception. + // + // The solution is to take a punt on 'str' being lower case, and + // test accordingly. If that fails, we convert 'str' to lower case + // and try the tests again. if ("read".equals(str)) actions = READ; else if ("write".equals(str)) actions = WRITE; else if ("read,write".equals(str) || "write,read".equals(str)) actions = READ | WRITE; - else - throw new IllegalArgumentException("illegal action " + str); + else { + String lstr = str.toLowerCase(); + if ("read".equals(lstr)) + actions = READ; + else if ("write".equals(lstr)) + actions = WRITE; + else if ("read,write".equals(lstr) || "write,read".equals(lstr)) + actions = READ | WRITE; + else + throw new IllegalArgumentException("illegal action " + str); + } } /** diff --git a/libjava/java/util/ResourceBundle.java b/libjava/java/util/ResourceBundle.java index 2a4e348..7a4a282 100644 --- a/libjava/java/util/ResourceBundle.java +++ b/libjava/java/util/ResourceBundle.java @@ -1,5 +1,5 @@ /* ResourceBundle -- aids in loading resource bundles - Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -182,8 +182,9 @@ public abstract class ResourceBundle catch (MissingResourceException ex) { } - throw new MissingResourceException("Key not found", - getClass().getName(), key); + + throw new MissingResourceException("Key not found", getClass().getName(), + key); } /** @@ -470,6 +471,7 @@ public abstract class ResourceBundle catch (Exception ex) { // ignore them all + foundBundle = null; } if (foundBundle == null) { |