ResourceBundle.java (resourceBundleCache): Not final.
authorMark Wielaard <mark@klomp.org>
Sun, 8 Dec 2002 23:38:02 +0000 (23:38 +0000)
committerMark Wielaard <mark@gcc.gnu.org>
Sun, 8 Dec 2002 23:38:02 +0000 (23:38 +0000)
* java/util/ResourceBundle.java (resourceBundleCache): Not final.
(lastDefaultLocale): New field.
(getBundle): When Locale.getDefault != lastDefaultLocale reset
resourceBundleCache.

From-SVN: r59948

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

index 3bc286641a9aec5c3048ab7921dd528bc24742b2..9e255b2cd57a4550fe1a8ab8133ad969aa9c88b2 100644 (file)
@@ -1,3 +1,10 @@
+2002-12-08  Mark Wielaard  <mark@klomp.org>
+
+       * java/util/ResourceBundle.java (resourceBundleCache): Not final.
+       (lastDefaultLocale): New field.
+       (getBundle): When Locale.getDefault != lastDefaultLocale reset
+       resourceBundleCache.
+
 2002-12-06  Mark Wielaard  <mark@klomp.org>
 
        * java/net/InetAddress.java (toString): Use hostname when not null,
index ecc63af2596b9dbf9aac771d21a0bc7b7650799c..2a4e34887c46e60a0ebaf61eeec5b31e904c0fb2 100644 (file)
@@ -111,7 +111,13 @@ public abstract class ResourceBundle
    * second hash map is the localized name, the value is a soft
    * references to the resource bundle.
    */
-  private static final Map resourceBundleCache = new HashMap();
+  private static Map resourceBundleCache;
+
+  /**
+   * The last default Locale we saw. If this ever changes then we have to
+   * reset our caches.
+   */
+  private static Locale lastDefaultLocale;
 
   /**
    * The `empty' locale is created once in order to optimize
@@ -312,6 +318,12 @@ public abstract class ResourceBundle
   {
     // This implementation searches the bundle in the reverse direction
     // and builds the parent chain on the fly.
+    Locale defaultLocale = Locale.getDefault();
+    if (defaultLocale != lastDefaultLocale)
+      {
+       resourceBundleCache = new HashMap();
+       lastDefaultLocale = defaultLocale;
+      }
     HashMap cache = (HashMap) resourceBundleCache.get(classLoader);
     StringBuffer sb = new StringBuffer(60);
     sb.append(baseName).append('_').append(locale);
@@ -359,9 +371,9 @@ public abstract class ResourceBundle
     // bundle.
     ResourceBundle bundle = tryLocalBundle(baseName, locale,
                                            classLoader, baseBundle, cache);
-    if (bundle == baseBundle && !locale.equals(Locale.getDefault()))
+    if (bundle == baseBundle && !locale.equals(defaultLocale))
       {
-       bundle = tryLocalBundle(baseName, Locale.getDefault(),
+       bundle = tryLocalBundle(baseName, defaultLocale,
                                classLoader, baseBundle, cache);
        // We need to record that the argument locale maps to the
        // bundle we just found.  If we didn't find a bundle, record