Print this page
rev 5615 : 6336885: RFE: Locale Data Deployment Enhancements
4609153: Provide locale data for Indic locales
5104387: Support for gl_ES locale (galician language)
6337471: desktop/system locale preferences support
7056139: (cal) SPI support for locale-dependent Calendar parameters
7058206: Provide CalendarData SPI for week params and display field value names
7073852: Support multiple scripts for digits and decimal symbols per locale
7079560: [Fmt-Da] Context dependent month names support in SimpleDateFormat
7171324: getAvailableLocales() of locale sensitive services should return the actual availability of locales
7151414: (cal) Support calendar type identification
7168528: LocaleServiceProvider needs to be aware of Locale extensions
7171372: (cal) locale's default Calendar should be created if unknown calendar is specified
Summary: JEP 127: Improve Locale Data Packaging and Adopt Unicode CLDR Data (part 1 w/o Jigsaw. by Naoto Sato and Masayoshi Okutsu)

Split Close
Expand all
Collapse all
          --- old/src/share/classes/sun/util/resources/OpenListResourceBundle.java
          +++ new/src/share/classes/sun/util/resources/OpenListResourceBundle.java
↓ open down ↓ 34 lines elided ↑ open up ↑
  35   35   *
  36   36   * This notice and attribution to Taligent may not be removed.
  37   37   * Taligent is a registered trademark of Taligent, Inc.
  38   38   *
  39   39   */
  40   40  
  41   41  package sun.util.resources;
  42   42  
  43   43  import java.util.Enumeration;
  44   44  import java.util.HashMap;
       45 +import java.util.HashSet;
  45   46  import java.util.Map;
  46   47  import java.util.ResourceBundle;
  47   48  import java.util.Set;
  48   49  import sun.util.ResourceBundleEnumeration;
  49   50  
  50   51  /**
  51   52   * Subclass of <code>ResourceBundle</code> which mimics
  52   53   * <code>ListResourceBundle</code>, but provides more hooks
  53   54   * for specialized subclass behavior. For general description,
  54   55   * see {@link java.util.ListResourceBundle}.
↓ open down ↓ 31 lines elided ↑ open up ↑
  86   87  
  87   88      /**
  88   89       * Returns a set of keys provided in this resource bundle
  89   90       */
  90   91      public Set<String> handleGetKeys() {
  91   92          loadLookupTablesIfNecessary();
  92   93  
  93   94          return lookup.keySet();
  94   95      }
  95   96  
       97 +    @Override
       98 +    public Set<String> keySet() {
       99 +        if (keyset != null) {
      100 +            return keyset;
      101 +        }
      102 +        Set<String> ks = new HashSet<>();
      103 +        ks.addAll(handleGetKeys());
      104 +        if (parent != null) {
      105 +            ks.addAll(parent.keySet());
      106 +        }
      107 +        synchronized (this) {
      108 +            if (keyset == null) {
      109 +                keyset = ks;
      110 +            }
      111 +        }
      112 +        return keyset;
      113 +    }
      114 +
  96  115      /**
  97  116       * Returns the parent bundle
  98  117       */
  99  118      public OpenListResourceBundle getParent() {
 100  119          return (OpenListResourceBundle)parent;
 101  120      }
 102  121  
 103  122      /**
 104  123       * See ListResourceBundle class description.
 105  124       */
↓ open down ↓ 5 lines elided ↑ open up ↑
 111  130      void loadLookupTablesIfNecessary() {
 112  131          if (lookup == null) {
 113  132              loadLookup();
 114  133          }
 115  134      }
 116  135  
 117  136      /**
 118  137       * We lazily load the lookup hashtable.  This function does the
 119  138       * loading.
 120  139       */
 121      -    private synchronized void loadLookup() {
 122      -        if (lookup != null) {
 123      -            return;
 124      -        }
 125      -
      140 +    private void loadLookup() {
 126  141          Object[][] contents = getContents();
 127  142          Map<String, Object> temp = createMap(contents.length);
 128  143          for (int i = 0; i < contents.length; ++i) {
 129  144              // key must be non-null String, value must be non-null
 130  145              String key = (String) contents[i][0];
 131  146              Object value = contents[i][1];
 132  147              if (key == null || value == null) {
 133  148                  throw new NullPointerException();
 134  149              }
 135  150              temp.put(key, value);
 136  151          }
 137      -        lookup = temp;
      152 +        synchronized (this) {
      153 +            if (lookup == null) {
      154 +                lookup = temp;
      155 +            }
      156 +        }
 138  157      }
 139  158  
 140  159      /**
 141  160       * Lets subclasses provide specialized Map implementations.
 142  161       * Default uses HashMap.
 143  162       */
 144  163      protected Map<String, Object> createMap(int size) {
 145  164          return new HashMap<>(size);
 146  165      }
 147  166  
 148      -    private Map<String, Object> lookup = null;
      167 +    private volatile Map<String, Object> lookup = null;
      168 +    private volatile Set<String> keyset;
 149  169  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX