--- /home/cpdev/src/classpath/java/util/Locale.java	2005-07-02 21:03:47.000000000 +0000
+++ java/util/Locale.java	2005-06-30 05:34:50.000000000 +0000
@@ -193,18 +193,6 @@
   private transient int hashcode;
 
   /**
-   * Array storing all available locales.
-   */
-  private static transient Locale[] availableLocales;
-
-  /**
-   * Locale cache. Only created locale objects are stored.
-   * Contains all supported locales when getAvailableLocales()
-   * got called.
-   */
-  private static transient HashMap localeMap;
-  
-  /**
    * The default locale. Except for during bootstrapping, this should never be
    * null. Note the logic in the main constructor, to detect when
    * bootstrapping has completed.
@@ -215,16 +203,6 @@
               SystemProperties.getProperty("user.variant", ""));
 
   /**
-   * Array storing all the available two-letter ISO639 languages.
-   */
-  private static transient String[] languageCache;
-
-  /**
-   * Array storing all the available two-letter ISO3166 country codes.
-   */
-  private static transient String[] countryCache;
-
-  /**
    * Retrieves the locale with the specified language from the cache.
    *
    * @param language the language of the locale to retrieve.
@@ -259,19 +237,7 @@
    */ 
   private static Locale getLocale(String language, String region, String variant)
   {
-    if (localeMap == null)
-      localeMap = new HashMap(256);
-
-    String name = language + "_" + region + "_" + variant;
-    Locale locale = (Locale) localeMap.get(name);
-
-    if (locale == null)
-      {
-	locale = new Locale(language, region, variant);
-	localeMap.put(name, locale);
-      }
-
-    return locale;
+    return new Locale(language, region, variant);
   }
   
   /**
@@ -380,37 +346,17 @@
    *
    * @return the installed locales
    */
-  public static synchronized Locale[] getAvailableLocales()
+  public static Locale[] getAvailableLocales()
   {
-    if (availableLocales == null)
-      {
-	String[] localeNames = LocaleData.localeNames;
-        availableLocales = new Locale[localeNames.length];
-
-        for (int i = 0; i < localeNames.length; i++)
-          {
-            String language;
-            String region = "";
-            String variant = "";
-            String name = localeNames[i];
-
-            language = name.substring(0, 2);
-
-            if (name.length() > 2)
-              region = name.substring(3);
-
-	    int index = region.indexOf("_");
-	    if (index > 0)
-	      {
-		variant = region.substring(index + 1);
-		region = region.substring(0, index - 1);
-	      }
-
-            availableLocales[i] = getLocale(language, region, variant);
-          }
-      }
-    
-    return availableLocales;
+    /* I only return those for which localized language
+     * or country information exists.
+     * XXX - remove hard coded list, and implement more locales (Sun's JDK 1.4
+     * has 148 installed locales!).
+     */
+    return new Locale[]
+    {
+      ENGLISH, FRENCH, GERMAN, new Locale("ga", "")
+    };
   }
 
   /**
@@ -421,12 +367,29 @@
    */
   public static String[] getISOCountries()
   {
-    if (countryCache == null)
-      {
-	countryCache = getISOStrings("territories");
-      }
-
-    return countryCache;
+    return new String[]
+    {
+      "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", "AO", "AQ", "AR", "AS",
+      "AT", "AU", "AW", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI",
+      "BJ", "BM", "BN", "BO", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA",
+      "CC", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU",
+      "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE",
+      "EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "FX",
+      "GA", "GB", "GD", "GE", "GF", "GH", "GI", "GL", "GM", "GN", "GP", "GQ",
+      "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU",
+      "ID", "IE", "IL", "IN", "IO", "IQ", "IR", "IS", "IT", "JM", "JO", "JP",
+      "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA",
+      "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC",
+      "MD", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS",
+      "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG",
+      "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG",
+      "PH", "PK", "PL", "PM", "PN", "PR", "PT", "PW", "PY", "QA", "RE", "RO",
+      "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK",
+      "SL", "SM", "SN", "SO", "SR", "ST", "SV", "SY", "SZ", "TC", "TD", "TF",
+      "TG", "TH", "TJ", "TK", "TM", "TN", "TO", "TP", "TR", "TT", "TV", "TW",
+      "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI",
+      "VN", "VU", "WF", "WS", "YE", "YT", "YU", "ZA", "ZM", "ZR", "ZW"
+    };
   }
 
   /**
@@ -437,52 +400,21 @@
    */
   public static String[] getISOLanguages()
   {
-    if (languageCache == null)
-      {
-	languageCache = getISOStrings("languages");
-      }
-    return languageCache;
-  }
-
-  /**
-   * Returns the set of keys from the specified resource hashtable, filtered
-   * so that only two letter strings are returned.
-   *
-   * @param tableName the name of the table from which to retrieve the keys.
-   * @return an array of two-letter strings.
-   */
-  private static String[] getISOStrings(String tableName)
-  {
-    int count = 0;
-    ResourceBundle bundle =
-      ResourceBundle.getBundle("gnu.java.locale.LocaleInformation");
-    Enumeration e = bundle.getKeys();
-    ArrayList tempList = new ArrayList();
-
-    while (e.hasMoreElements())
-      {
-	String key = (String) e.nextElement();
-	
-	if (key.startsWith(tableName + "."))
-	  {
-	    String str = key.substring(tableName.length() + 1);
-
-	    if (str.length() == 2
-		&& Character.isLetter(str.charAt(0))
-		&& Character.isLetter(str.charAt(1)))
-	      {
-		tempList.add(str);
-		++count;
-	      }
-	  }
-      }
-
-    String[] strings = new String[count];
-    
-    for (int a = 0; a < count; ++a)
-      strings[a] = (String) tempList.get(a);
-    
-    return strings;
+    return new String[]
+    {
+      "aa", "ab", "af", "am", "ar", "as", "ay", "az", "ba", "be", "bg", "bh",
+      "bi", "bn", "bo", "br", "ca", "co", "cs", "cy", "da", "de", "dz", "el",
+      "en", "eo", "es", "et", "eu", "fa", "fi", "fj", "fo", "fr", "fy", "ga",
+      "gd", "gl", "gn", "gu", "ha", "he", "hi", "hr", "hu", "hy", "ia", "id",
+      "ie", "ik", "in", "is", "it", "iu", "iw", "ja", "ji", "jw", "ka", "kk",
+      "kl", "km", "kn", "ko", "ks", "ku", "ky", "la", "ln", "lo", "lt", "lv",
+      "mg", "mi", "mk", "ml", "mn", "mo", "mr", "ms", "mt", "my", "na", "ne",
+      "nl", "no", "oc", "om", "or", "pa", "pl", "ps", "pt", "qu", "rm", "rn",
+      "ro", "ru", "rw", "sa", "sd", "sg", "sh", "si", "sk", "sl", "sm", "sn",
+      "so", "sq", "sr", "ss", "st", "su", "sv", "sw", "ta", "te", "tg", "th",
+      "ti", "tk", "tl", "tn", "to", "tr", "ts", "tt", "tw", "ug", "uk", "ur",
+      "uz", "vi", "vo", "wo", "xh", "yi", "yo", "za", "zh", "zu"
+    };
   }
 
   /**
@@ -666,16 +598,13 @@
   {
     try
       {
-	ResourceBundle res =
-          ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
-                                   inLocale,
-                                   ClassLoader.getSystemClassLoader());
-
-        return res.getString("languages." + language);
+        ResourceBundle bundle
+          = ResourceBundle.getBundle("gnu.java.locale.iso639", inLocale);
+        return bundle.getString(language);
       }
-    catch (MissingResourceException e)
+    catch (MissingResourceException ex)
       {
-	return language;
+        return language;
       }
   }
 
@@ -724,14 +653,11 @@
   {
     try
       {
-        ResourceBundle res =
-          ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
-                                   inLocale,
-                                   ClassLoader.getSystemClassLoader());
-    
-        return res.getString("territories." + country);
+        ResourceBundle bundle =
+          ResourceBundle.getBundle("gnu.java.locale.iso3166", inLocale);
+        return bundle.getString(country);
       }
-    catch (MissingResourceException e)
+    catch (MissingResourceException ex)
       {
         return country;
       }
@@ -753,7 +679,6 @@
     return getDisplayVariant(defaultLocale);
   }
 
-
   /**
    * <p>
    * Gets the name of the variant specified by this locale, in a form suitable
@@ -781,19 +706,8 @@
    */
   public String getDisplayVariant(Locale inLocale)
   {
-    try
-      {
-        ResourceBundle res =
-          ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
-                                   inLocale,
-                                   ClassLoader.getSystemClassLoader());
-    
-        return res.getString("variants." + variant);
-      }
-    catch (MissingResourceException e)
-      {
-        return variant;
-      }
+    // XXX - load a bundle?
+    return variant;
   }
 
   /**
