JDK 9 RFR of JDK-8151393: Revert changes for JDK-8087104

joe darcy joe.darcy at oracle.com
Mon Mar 7 19:25:39 UTC 2016


Hello,

The changes for JDK-8087104 introduced some test failures which have not 
yet been addressed (JDK-8151310). In order to get a clean snapshot for 
the next integration, if the fix for JDK-8151310 doesn't arrive in time, 
the changes for JDK-8087104 should be reverted until they can be 
otherwise corrected.

In case the fix doesn't arrive, I patch -R'ed the changset for 
JDK-8087104. The (anti)diff to DateFormatSymbols.java is below; the 
newly-introduced failing test file from the previous changeset

     test/java/text/Format/DateFormat/DFSConstructorCloneTest.java

is deleted.

Thanks,

-Joe

--- a/src/java.base/share/classes/java/text/DateFormatSymbols.java Fri 
Mar 04 10:09:54 2016 -0800
+++ b/src/java.base/share/classes/java/text/DateFormatSymbols.java Mon 
Mar 07 11:20:50 2016 -0800
@@ -1,5 +1,5 @@
  /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights 
reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights 
reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
@@ -606,7 +606,7 @@
          try
          {
              DateFormatSymbols other = (DateFormatSymbols)super.clone();
-            copyMembers(new SymbolsCacheEntry(locale), other);
+            copyMembers(this, other);
              return other;
          } catch (CloneNotSupportedException e) {
              throw new InternalError(e);
@@ -669,7 +669,7 @@
      /**
       * Cache to hold DateFormatSymbols instances per Locale.
       */
-    private static final ConcurrentMap<Locale, 
SoftReference<SymbolsCacheEntry>> cachedInstances
+    private static final ConcurrentMap<Locale, 
SoftReference<DateFormatSymbols>> cachedInstances
          = new ConcurrentHashMap<>(3);

      private transient int lastZoneIndex;
@@ -683,10 +683,10 @@
          locale = desiredLocale;

          // Copy values of a cached instance if any.
-        SoftReference<SymbolsCacheEntry> ref = cachedInstances.get(locale);
-        SymbolsCacheEntry sce;
-        if (ref != null && (sce = ref.get()) != null) {
-            copyMembers(sce, this);
+        SoftReference<DateFormatSymbols> ref = cachedInstances.get(locale);
+        DateFormatSymbols dfs;
+        if (ref != null && (dfs = ref.get()) != null) {
+            copyMembers(dfs, this);
              return;
          }

@@ -717,11 +717,11 @@
          weekdays = toOneBasedArray(resource.getStringArray("DayNames"));
          shortWeekdays = 
toOneBasedArray(resource.getStringArray("DayAbbreviations"));

-        sce = new SymbolsCacheEntry(locale);
-        ref = new SoftReference<>(sce);
-        SoftReference<SymbolsCacheEntry> x = 
cachedInstances.putIfAbsent(locale, ref);
+        // Put a clone in the cache
+        ref = new SoftReference<>((DateFormatSymbols)this.clone());
+        SoftReference<DateFormatSymbols> x = 
cachedInstances.putIfAbsent(locale, ref);
          if (x != null) {
-            SymbolsCacheEntry y = x.get();
+            DateFormatSymbols y = x.get();
              if (y == null) {
                  // Replace the empty SoftReference with ref.
                  cachedInstances.put(locale, ref);
@@ -812,7 +812,7 @@
       * @param src the source DateFormatSymbols.
       * @param dst the target DateFormatSymbols.
       */
-    private void copyMembers(SymbolsCacheEntry src, DateFormatSymbols dst)
+    private void copyMembers(DateFormatSymbols src, DateFormatSymbols dst)
      {
          dst.eras = Arrays.copyOf(src.eras, src.eras.length);
          dst.months = Arrays.copyOf(src.months, src.months.length);
@@ -821,7 +821,7 @@
          dst.shortWeekdays = Arrays.copyOf(src.shortWeekdays, 
src.shortWeekdays.length);
          dst.ampms = Arrays.copyOf(src.ampms, src.ampms.length);
          if (src.zoneStrings != null) {
-            dst.zoneStrings = getZoneStringsImpl(true);
+            dst.zoneStrings = src.getZoneStringsImpl(true);
          } else {
              dst.zoneStrings = null;
          }
@@ -842,43 +842,4 @@
          }
          stream.defaultWriteObject();
      }
-
-    private static class SymbolsCacheEntry {
-
-        final String eras[];
-        final String months[];
-        final String shortMonths[];
-        final String weekdays[];
-        final String shortWeekdays[];
-        final String ampms[];
-        final String zoneStrings[][];
-        final String localPatternChars;
-
-        SymbolsCacheEntry(Locale locale) {
-            // Initialize the fields from the ResourceBundle for locale.
-            LocaleProviderAdapter adapter = 
LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale);
-            // Avoid any potential recursions
-            if (!(adapter instanceof ResourceBundleBasedAdapter)) {
-                adapter = LocaleProviderAdapter.getResourceBundleBased();
-            }
-            ResourceBundle resource = ((ResourceBundleBasedAdapter) 
adapter).getLocaleData().getDateFormatData(locale);
-            if (resource.containsKey("Eras")) {
-                this.eras = resource.getStringArray("Eras");
-            } else if (resource.containsKey("long.Eras")) {
-                this.eras = resource.getStringArray("long.Eras");
-            } else if (resource.containsKey("short.Eras")) {
-                this.eras = resource.getStringArray("short.Eras");
-            } else {
-                this.eras = null;
-            }
-            this.months = resource.getStringArray("MonthNames");
-            this.shortMonths = 
resource.getStringArray("MonthAbbreviations");
-            this.weekdays = 
toOneBasedArray(resource.getStringArray("DayNames"));
-            this.shortWeekdays = 
toOneBasedArray(resource.getStringArray("DayAbbreviations"));
-            this.ampms = resource.getStringArray("AmPmMarkers");
-            this.zoneStrings = TimeZoneNameUtility.getZoneStrings(locale);
-            this.localPatternChars = 
resource.getString("DateTimePatternChars");
-
-        }
-    }
  }




More information about the core-libs-dev mailing list