PropertyPermission.java: New version from classpath
authorMichael Koch <konqueror@gmx.de>
Tue, 29 Apr 2003 11:36:34 +0000 (11:36 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Tue, 29 Apr 2003 11:36:34 +0000 (11:36 +0000)
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

libjava/ChangeLog
libjava/java/util/PropertyPermission.java
libjava/java/util/ResourceBundle.java

index 930212c7bb630a9c5b725fd28af3874151946482..189d9967fcc49f82a80d9a1f58b59d014ed508d8 100644 (file)
@@ -1,3 +1,12 @@
+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.
+
 2003-04-29  Michael Koch  <konqueror@gmx.de>
 
        * javax/swing/AbstractListModel.java,
index bb03e45f3624ba950eef40d26126825cf8e767b6..0d439d888a78af279ed6224e5c9e57605bf3fbd6 100644 (file)
@@ -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);
+    }
   }
 
   /**
index 2a4e34887c46e60a0ebaf61eeec5b31e904c0fb2..7a4a282e773e5da5bf5ecec830ab66a811cbbce7 100644 (file)
@@ -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)
       {