From e9216efefc12b04c372a0a7f47167c984be544b7 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Wed, 11 Jun 2025 16:04:26 +0000 Subject: [PATCH] 8358734: Remove JavaTimeSupplementary resource bundles Reviewed-by: jlu, joehw, iris --- src/java.base/share/classes/module-info.java | 3 +- .../sun/text/resources/FormatData.java | 349 +++++++++++++---- .../text/resources/JavaTimeSupplementary.java | 353 ------------------ .../JavaTimeSupplementaryProvider.java | 35 -- .../util/locale/provider/LocaleResources.java | 9 +- .../sun/util/resources/LocaleData.java | 101 +---- .../resources/ParallelListResourceBundle.java | 259 ------------- .../share/classes/module-info.java | 4 +- .../sun/text/resources/ext/FormatData.java | 6 +- .../sun/text/resources/ext/FormatData_ja.java | 8 +- .../provider/LocaleDataProvider.java | 4 +- 11 files changed, 301 insertions(+), 830 deletions(-) delete mode 100644 src/java.base/share/classes/sun/text/resources/JavaTimeSupplementary.java delete mode 100644 src/java.base/share/classes/sun/text/resources/JavaTimeSupplementaryProvider.java delete mode 100644 src/java.base/share/classes/sun/util/resources/ParallelListResourceBundle.java diff --git a/src/java.base/share/classes/module-info.java b/src/java.base/share/classes/module-info.java index 07de3f2c57f..fe043dadab5 100644 --- a/src/java.base/share/classes/module-info.java +++ b/src/java.base/share/classes/module-info.java @@ -402,8 +402,7 @@ module java.base { uses sun.text.spi.JavaTimeDateTimePatternProvider; uses sun.util.spi.CalendarProvider; uses sun.util.locale.provider.LocaleDataMetaInfo; - uses sun.util.resources.LocaleData.CommonResourceBundleProvider; - uses sun.util.resources.LocaleData.SupplementaryResourceBundleProvider; + uses sun.util.resources.LocaleData.LocaleDataResourceBundleProvider; // Built-in service providers that are located via ServiceLoader diff --git a/src/java.base/share/classes/sun/text/resources/FormatData.java b/src/java.base/share/classes/sun/text/resources/FormatData.java index f90317ee69f..541cb63fff9 100644 --- a/src/java.base/share/classes/sun/text/resources/FormatData.java +++ b/src/java.base/share/classes/sun/text/resources/FormatData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2025, 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 @@ -23,9 +23,6 @@ * questions. */ -/* - */ - /* * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved * (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved @@ -79,11 +76,11 @@ package sun.text.resources; -import sun.util.resources.ParallelListResourceBundle; +import sun.util.resources.OpenListResourceBundle; -public class FormatData extends ParallelListResourceBundle { +public class FormatData extends OpenListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides OpenListResourceBundle */ @Override protected final Object[][] getContents() { @@ -119,6 +116,109 @@ public class FormatData extends ParallelListResourceBundle { "Reiwa", }; + // Moved from JavaTimeSupplementary + final String[] sharedQuarterNames = { + "Q1", + "Q2", + "Q3", + "Q4", + }; + + final String[] sharedQuarterNarrows = { + "1", + "2", + "3", + "4", + }; + + final String[] sharedDatePatterns = { + "GGGG y MMMM d, EEEE", + "GGGG y MMMM d", + "GGGG y MMM d", + "G y-MM-dd", + }; + + final String[] sharedDayAbbrs = { + "Sun", + "Mon", + "Tue", + "Wed", + "Thu", + "Fri", + "Sat", + }; + + final String[] sharedDayNarrows = { + "S", + "M", + "T", + "W", + "T", + "F", + "S", + }; + + final String[] sharedEras = { + "", + "AH", + }; + + final String[] sharedMonthNarrows = { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + }; + + final String[] sharedTimePatterns = { + "HH:mm:ss zzzz", + "HH:mm:ss z", + "HH:mm:ss", + "HH:mm", + }; + + final String[] sharedAmPmMarkers = { + "AM", + "PM", + }; + + final String[] sharedJavaTimeDatePatterns = { + "G y MMMM d, EEEE", + "G y MMMM d", + "G y MMM d", + "GGGGG y-MM-dd", + }; + + final String[] sharedShortEras = { + "Before R.O.C.", + "R.O.C.", + }; + + final String[] sharedMonthAbbrs = { + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec", + "", + }; + return new Object[][] { { "MonthNames", new String[] { @@ -138,39 +238,9 @@ public class FormatData extends ParallelListResourceBundle { } }, { "MonthAbbreviations", - new String[] { - "Jan", // abb january - "Feb", // abb february - "Mar", // abb march - "Apr", // abb april - "May", // abb may - "Jun", // abb june - "Jul", // abb july - "Aug", // abb august - "Sep", // abb september - "Oct", // abb october - "Nov", // abb november - "Dec", // abb december - "" // abb month 13 if applicable - } - }, + sharedMonthAbbrs }, { "MonthNarrows", - new String[] { - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "10", - "11", - "12", - "", - } - }, + sharedMonthNarrows }, { "DayNames", new String[] { "Sunday", // Sunday @@ -183,33 +253,11 @@ public class FormatData extends ParallelListResourceBundle { } }, { "DayAbbreviations", - new String[] { - "Sun", // abb Sunday - "Mon", // abb Monday - "Tue", // abb Tuesday - "Wed", // abb Wednesday - "Thu", // abb Thursday - "Fri", // abb Friday - "Sat" // abb Saturday - } - }, + sharedDayAbbrs }, { "DayNarrows", - new String[] { - "S", - "M", - "T", - "W", - "T", - "F", - "S", - } - }, + sharedDayNarrows }, { "AmPmMarkers", - new String[] { - "AM", // am marker - "PM" // pm marker - } - }, + sharedAmPmMarkers }, { "narrow.AmPmMarkers", new String[] { "a", // am marker @@ -227,22 +275,17 @@ public class FormatData extends ParallelListResourceBundle { } }, { "buddhist.Eras", - buddhistEras - }, + buddhistEras }, { "buddhist.short.Eras", - buddhistEras - }, + buddhistEras }, { "buddhist.narrow.Eras", - buddhistEras - }, + buddhistEras }, { "japanese.Eras", japaneseEras }, { "japanese.short.Eras", - japaneseEraAbbrs - }, + japaneseEraAbbrs }, { "japanese.narrow.Eras", - japaneseEraAbbrs - }, + japaneseEraAbbrs }, { "japanese.FirstYear", new String[] { // Japanese imperial calendar year name // empty in English @@ -898,6 +941,164 @@ public class FormatData extends ParallelListResourceBundle { } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, + + // Moved from JavaTimeSupplementary + { "QuarterAbbreviations", + sharedQuarterNames }, + { "QuarterNames", + sharedQuarterNames }, + { "QuarterNarrows", + sharedQuarterNarrows }, + { "field.dayperiod", + "Dayperiod" }, + { "field.era", + "Era" }, + { "field.hour", + "Hour" }, + { "field.minute", + "Minute" }, + { "field.month", + "Month" }, + { "field.second", + "Second" }, + { "field.week", + "Week" }, + { "field.weekday", + "Day of the Week" }, + { "field.year", + "Year" }, + { "field.zone", + "Zone" }, + { "islamic.DatePatterns", + sharedDatePatterns }, + { "islamic.DayAbbreviations", + sharedDayAbbrs }, + { "islamic.DayNames", + sharedDayAbbrs }, + { "islamic.DayNarrows", + sharedDayNarrows }, + { "islamic.Eras", + sharedEras }, + { "islamic.MonthAbbreviations", + new String[] { + "Muh.", + "Saf.", + "Rab. I", + "Rab. II", + "Jum. I", + "Jum. II", + "Raj.", + "Sha.", + "Ram.", + "Shaw.", + "Dhuʻl-Q.", + "Dhuʻl-H.", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "Muharram", + "Safar", + "Rabiʻ I", + "Rabiʻ II", + "Jumada I", + "Jumada II", + "Rajab", + "Shaʻban", + "Ramadan", + "Shawwal", + "Dhuʻl-Qiʻdah", + "Dhuʻl-Hijjah", + "", + } + }, + { "islamic.MonthNarrows", + sharedMonthNarrows }, + { "islamic.QuarterNames", + sharedQuarterNames }, + { "islamic.QuarterNarrows", + sharedQuarterNarrows }, + { "islamic.TimePatterns", + sharedTimePatterns }, + { "islamic.abbreviated.AmPmMarkers", + sharedAmPmMarkers }, + { "islamic.long.Eras", + sharedEras }, + { "islamic.narrow.Eras", + sharedEras }, + { "islamic.short.Eras", + sharedEras }, + { "java.time.buddhist.DatePatterns", + sharedJavaTimeDatePatterns }, + { "java.time.buddhist.long.Eras", + new String[] { + "BC", + "BE", + } + }, + { "java.time.buddhist.short.Eras", + buddhistEras }, + { "java.time.islamic.DatePatterns", + sharedJavaTimeDatePatterns }, + { "java.time.japanese.DatePatterns", + new String[] { + "G y MMMM d (EEEE)", + "G y MMMM d", + "G y MMM d", + "GGGGGy.MM.dd", + } + }, + { "java.time.japanese.long.Eras", + japaneseEras }, + { "java.time.japanese.short.Eras", + japaneseEras }, + { "java.time.long.Eras", + new String[] { + "BCE", + "CE", + } + }, + { "java.time.roc.DatePatterns", + sharedJavaTimeDatePatterns }, + { "java.time.short.Eras", + julianEras }, + { "roc.AmPmMarkers", + sharedAmPmMarkers }, + { "roc.DatePatterns", + sharedDatePatterns }, + { "roc.DayNames", + sharedDayAbbrs }, + { "roc.DayNarrows", + sharedDayNarrows }, + { "roc.Eras", + sharedShortEras }, + { "roc.MonthAbbreviations", + sharedMonthAbbrs }, + { "roc.MonthNames", + sharedMonthAbbrs }, + { "roc.MonthNarrows", + sharedMonthNarrows }, + { "roc.QuarterNames", + sharedQuarterNames }, + { "roc.QuarterNarrows", + sharedQuarterNarrows }, + { "roc.TimePatterns", + sharedTimePatterns }, + { "roc.abbreviated.AmPmMarkers", + sharedAmPmMarkers }, + { "roc.long.Eras", + sharedShortEras }, + { "roc.narrow.AmPmMarkers", + sharedAmPmMarkers }, + { "roc.narrow.Eras", + sharedShortEras }, + { "roc.short.Eras", + sharedShortEras }, + { "timezone.gmtFormat", + "GMT{0}" }, + { "timezone.hourFormat", + "+HH:mm;-HH:mm" }, }; } } diff --git a/src/java.base/share/classes/sun/text/resources/JavaTimeSupplementary.java b/src/java.base/share/classes/sun/text/resources/JavaTimeSupplementary.java deleted file mode 100644 index cbcb724d258..00000000000 --- a/src/java.base/share/classes/sun/text/resources/JavaTimeSupplementary.java +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (c) 2013, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * COPYRIGHT AND PERMISSION NOTICE - * - * Copyright (C) 1991-2016 Unicode, Inc. All rights reserved. - * Distributed under the Terms of Use in - * http://www.unicode.org/copyright.html. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of the Unicode data files and any associated documentation - * (the "Data Files") or Unicode software and any associated documentation - * (the "Software") to deal in the Data Files or Software - * without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, and/or sell copies of - * the Data Files or Software, and to permit persons to whom the Data Files - * or Software are furnished to do so, provided that - * (a) this copyright and permission notice appear with all copies - * of the Data Files or Software, - * (b) this copyright and permission notice appear in associated - * documentation, and - * (c) there is clear notice in each modified Data File or in the Software - * as well as in the documentation associated with the Data File(s) or - * Software that the data or software has been modified. - * - * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF - * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT OF THIRD PARTY RIGHTS. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS - * NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL - * DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THE DATA FILES OR SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in these Data Files or Software without prior - * written authorization of the copyright holder. - */ - -// Note: this file has been generated by a tool. - -package sun.text.resources; - -import sun.util.resources.OpenListResourceBundle; - -public class JavaTimeSupplementary extends OpenListResourceBundle { - @Override - protected final Object[][] getContents() { - final String[] sharedQuarterNames = { - "Q1", - "Q2", - "Q3", - "Q4", - }; - - final String[] sharedQuarterNarrows = { - "1", - "2", - "3", - "4", - }; - - final String[] sharedDatePatterns = { - "GGGG y MMMM d, EEEE", - "GGGG y MMMM d", - "GGGG y MMM d", - "G y-MM-dd", - }; - - final String[] sharedDayNames = { - "Sun", - "Mon", - "Tue", - "Wed", - "Thu", - "Fri", - "Sat", - }; - - final String[] sharedDayNarrows = { - "S", - "M", - "T", - "W", - "T", - "F", - "S", - }; - - final String[] sharedEras = { - "", - "AH", - }; - - final String[] sharedMonthNarrows = { - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "10", - "11", - "12", - "", - }; - - final String[] sharedTimePatterns = { - "HH:mm:ss zzzz", - "HH:mm:ss z", - "HH:mm:ss", - "HH:mm", - }; - - final String[] sharedAmPmMarkers = { - "AM", - "PM", - }; - - final String[] sharedJavaTimeDatePatterns = { - "G y MMMM d, EEEE", - "G y MMMM d", - "G y MMM d", - "GGGGG y-MM-dd", - }; - - final String[] sharedJavaTimeLongEras = { - "", - "Meiji", - "Taisho", - "Showa", - "Heisei", - "Reiwa", - }; - - final String[] sharedShortEras = { - "Before R.O.C.", - "R.O.C.", - }; - - final String[] sharedMonthNames = { - "Jan", - "Feb", - "Mar", - "Apr", - "May", - "Jun", - "Jul", - "Aug", - "Sep", - "Oct", - "Nov", - "Dec", - "", - }; - - return new Object[][] { - { "QuarterAbbreviations", - sharedQuarterNames }, - { "QuarterNames", - sharedQuarterNames }, - { "QuarterNarrows", - sharedQuarterNarrows }, - { "field.dayperiod", - "Dayperiod" }, - { "field.era", - "Era" }, - { "field.hour", - "Hour" }, - { "field.minute", - "Minute" }, - { "field.month", - "Month" }, - { "field.second", - "Second" }, - { "field.week", - "Week" }, - { "field.weekday", - "Day of the Week" }, - { "field.year", - "Year" }, - { "field.zone", - "Zone" }, - { "islamic.DatePatterns", - sharedDatePatterns }, - { "islamic.DayAbbreviations", - sharedDayNames }, - { "islamic.DayNames", - sharedDayNames }, - { "islamic.DayNarrows", - sharedDayNarrows }, - { "islamic.Eras", - sharedEras }, - { "islamic.MonthAbbreviations", - new String[] { - "Muh.", - "Saf.", - "Rab. I", - "Rab. II", - "Jum. I", - "Jum. II", - "Raj.", - "Sha.", - "Ram.", - "Shaw.", - "Dhuʻl-Q.", - "Dhuʻl-H.", - "", - } - }, - { "islamic.MonthNames", - new String[] { - "Muharram", - "Safar", - "Rabiʻ I", - "Rabiʻ II", - "Jumada I", - "Jumada II", - "Rajab", - "Shaʻban", - "Ramadan", - "Shawwal", - "Dhuʻl-Qiʻdah", - "Dhuʻl-Hijjah", - "", - } - }, - { "islamic.MonthNarrows", - sharedMonthNarrows }, - { "islamic.QuarterNames", - sharedQuarterNames }, - { "islamic.QuarterNarrows", - sharedQuarterNarrows }, - { "islamic.TimePatterns", - sharedTimePatterns }, - { "islamic.abbreviated.AmPmMarkers", - sharedAmPmMarkers }, - { "islamic.long.Eras", - sharedEras }, - { "islamic.narrow.Eras", - sharedEras }, - { "islamic.short.Eras", - sharedEras }, - { "java.time.buddhist.DatePatterns", - sharedJavaTimeDatePatterns }, - { "java.time.buddhist.long.Eras", - new String[] { - "BC", - "BE", - } - }, - { "java.time.buddhist.short.Eras", - new String[] { - "BC", - "B.E.", - } - }, - { "java.time.islamic.DatePatterns", - sharedJavaTimeDatePatterns }, - { "java.time.japanese.DatePatterns", - new String[] { - "G y MMMM d (EEEE)", - "G y MMMM d", - "G y MMM d", - "GGGGGy.MM.dd", - } - }, - { "java.time.japanese.long.Eras", - sharedJavaTimeLongEras }, - { "java.time.japanese.short.Eras", - sharedJavaTimeLongEras }, - { "java.time.long.Eras", - new String[] { - "BCE", - "CE", - } - }, - { "java.time.roc.DatePatterns", - sharedJavaTimeDatePatterns }, - { "java.time.short.Eras", - new String[] { - "BC", - "AD", - } - }, - { "roc.AmPmMarkers", - sharedAmPmMarkers }, - { "roc.DatePatterns", - sharedDatePatterns }, - { "roc.DayNames", - sharedDayNames }, - { "roc.DayNarrows", - sharedDayNarrows }, - { "roc.Eras", - sharedShortEras }, - { "roc.MonthAbbreviations", - sharedMonthNames }, - { "roc.MonthNames", - sharedMonthNames }, - { "roc.MonthNarrows", - sharedMonthNarrows }, - { "roc.QuarterNames", - sharedQuarterNames }, - { "roc.QuarterNarrows", - sharedQuarterNarrows }, - { "roc.TimePatterns", - sharedTimePatterns }, - { "roc.abbreviated.AmPmMarkers", - sharedAmPmMarkers }, - { "roc.long.Eras", - sharedShortEras }, - { "roc.narrow.AmPmMarkers", - sharedAmPmMarkers }, - { "roc.narrow.Eras", - sharedShortEras }, - { "roc.short.Eras", - sharedShortEras }, - { "timezone.gmtFormat", - "GMT{0}" }, - { "timezone.hourFormat", - "+HH:mm;-HH:mm" }, - }; - } -} diff --git a/src/java.base/share/classes/sun/text/resources/JavaTimeSupplementaryProvider.java b/src/java.base/share/classes/sun/text/resources/JavaTimeSupplementaryProvider.java deleted file mode 100644 index 261e9803015..00000000000 --- a/src/java.base/share/classes/sun/text/resources/JavaTimeSupplementaryProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.text.resources; - -import java.util.spi.ResourceBundleProvider; - -/** - * An interface for the internal locale data provider for which {@code ResourceBundle} - * searches. - */ -public interface JavaTimeSupplementaryProvider extends ResourceBundleProvider { -} diff --git a/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java b/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java index 4ae0275fdda..c539f57141e 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java +++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, 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 @@ -65,7 +65,6 @@ import java.util.stream.Stream; import jdk.internal.util.StaticProperty; import sun.util.resources.LocaleData; import sun.util.resources.OpenListResourceBundle; -import sun.util.resources.ParallelListResourceBundle; import sun.util.resources.TimeZoneNamesBundle; /** @@ -579,11 +578,7 @@ public class LocaleResources { * resources required by JSR 310. */ public ResourceBundle getJavaTimeFormatData() { - ResourceBundle rb = localeData.getDateFormatData(locale); - if (rb instanceof ParallelListResourceBundle) { - localeData.setSupplementary((ParallelListResourceBundle) rb); - } - return rb; + return localeData.getDateFormatData(locale); } /** diff --git a/src/java.base/share/classes/sun/util/resources/LocaleData.java b/src/java.base/share/classes/sun/util/resources/LocaleData.java index 7bf14343531..20e8e0f8fe9 100644 --- a/src/java.base/share/classes/sun/util/resources/LocaleData.java +++ b/src/java.base/share/classes/sun/util/resources/LocaleData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2025, 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 @@ -44,7 +44,6 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.MissingResourceException; import java.util.ResourceBundle; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -143,30 +142,6 @@ public class LocaleData { return getBundle(type.getTextResourcesPackage() + ".FormatData", locale); } - public void setSupplementary(ParallelListResourceBundle formatData) { - if (!formatData.areParallelContentsComplete()) { - String suppName = type.getTextResourcesPackage() + ".JavaTimeSupplementary"; - setSupplementary(suppName, formatData); - } - } - - private boolean setSupplementary(String suppName, ParallelListResourceBundle formatData) { - ParallelListResourceBundle parent = (ParallelListResourceBundle) formatData.getParent(); - boolean resetKeySet = false; - if (parent != null) { - resetKeySet = setSupplementary(suppName, parent); - } - OpenListResourceBundle supp = getSupplementary(suppName, formatData.getLocale()); - formatData.setParallelContents(supp); - resetKeySet |= supp != null; - // If any parents or this bundle has parallel data, reset keyset to create - // a new keyset with the data. - if (resetKeySet) { - formatData.resetKeySet(); - } - return resetKeySet; - } - /** * Gets a number format data resource bundle, using privileges * to allow accessing a sun.* package. @@ -179,18 +154,7 @@ public class LocaleData { return Bundles.of(baseName, locale, LocaleDataStrategy.INSTANCE); } - private static OpenListResourceBundle getSupplementary(final String baseName, final Locale locale) { - OpenListResourceBundle rb = null; - try { - rb = (OpenListResourceBundle) Bundles.of(baseName, locale, - SupplementaryStrategy.INSTANCE); - } catch (MissingResourceException e) { - // return null if no supplementary is available - } - return rb; - } - - private abstract static class LocaleDataResourceBundleProvider + public abstract static class LocaleDataResourceBundleProvider implements ResourceBundleProvider { /** * Changes baseName to its module dependent package name and @@ -212,20 +176,6 @@ public class LocaleData { } } - /** - * A ResourceBundleProvider implementation for loading locale data - * resource bundles except for the java.time supplementary data. - */ - public abstract static class CommonResourceBundleProvider extends LocaleDataResourceBundleProvider { - } - - /** - * A ResourceBundleProvider implementation for loading supplementary - * resource bundles for java.time. - */ - public abstract static class SupplementaryResourceBundleProvider extends LocaleDataResourceBundleProvider { - } - // Bundles.Strategy implementations private static class LocaleDataStrategy implements Bundles.Strategy { @@ -254,18 +204,20 @@ public class LocaleData { if (candidates == null) { LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE; LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type); - candidates = adapter instanceof ResourceBundleBasedAdapter ? - ((ResourceBundleBasedAdapter)adapter).getCandidateLocales(baseName, locale) : + candidates = adapter instanceof ResourceBundleBasedAdapter rbba ? + rbba.getCandidateLocales(baseName, locale) : defaultControl.getCandidateLocales(baseName, locale); // Weed out Locales which are known to have no resource bundles int lastDot = baseName.lastIndexOf('.'); String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName; - Set langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category); - if (!langtags.isEmpty()) { - for (Iterator itr = candidates.iterator(); itr.hasNext();) { - if (!adapter.isSupportedProviderLocale(itr.next(), langtags)) { - itr.remove(); + if (adapter instanceof JRELocaleProviderAdapter jlpa) { + var langtags = jlpa.getLanguageTagSet(category); + if (!langtags.isEmpty()) { + for (Iterator itr = candidates.iterator(); itr.hasNext();) { + if (!jlpa.isSupportedProviderLocale(itr.next(), langtags)) { + itr.remove(); + } } } } @@ -302,36 +254,7 @@ public class LocaleData { public Class getResourceBundleProviderType(String baseName, Locale locale) { return inJavaBaseModule(baseName, locale) ? - null : CommonResourceBundleProvider.class; - } - } - - private static class SupplementaryStrategy extends LocaleDataStrategy { - private static final SupplementaryStrategy INSTANCE - = new SupplementaryStrategy(); - // TODO: avoid hard-coded Locales - private static final Set JAVA_BASE_LOCALES - = Set.of(Locale.ROOT, Locale.ENGLISH, Locale.US); - - private SupplementaryStrategy() { - } - - @Override - public List getCandidateLocales(String baseName, Locale locale) { - // Specify only the given locale - return List.of(locale); - } - - @Override - public Class getResourceBundleProviderType(String baseName, - Locale locale) { - return inJavaBaseModule(baseName, locale) ? - null : SupplementaryResourceBundleProvider.class; - } - - @Override - boolean inJavaBaseModule(String baseName, Locale locale) { - return JAVA_BASE_LOCALES.contains(locale); + null : LocaleDataResourceBundleProvider.class; } } } diff --git a/src/java.base/share/classes/sun/util/resources/ParallelListResourceBundle.java b/src/java.base/share/classes/sun/util/resources/ParallelListResourceBundle.java deleted file mode 100644 index 35319575010..00000000000 --- a/src/java.base/share/classes/sun/util/resources/ParallelListResourceBundle.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (c) 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.util.resources; - -import java.util.AbstractSet; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.ResourceBundle; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicMarkableReference; - -/** - * ParallelListResourceBundle is another variant of ListResourceBundle - * supporting "parallel" contents provided by another resource bundle - * (OpenListResourceBundle). Parallel contents, if any, are added into this - * bundle on demand. - * - * @author Masayoshi Okutsu - */ -public abstract class ParallelListResourceBundle extends ResourceBundle { - private volatile ConcurrentMap lookup; - private volatile Set keyset; - private final AtomicMarkableReference parallelContents - = new AtomicMarkableReference<>(null, false); - - /** - * Sole constructor. (For invocation by subclass constructors, typically - * implicit.) - */ - protected ParallelListResourceBundle() { - } - - /** - * Returns an array in which each item is a pair of objects in an - * Object array. The first element of each pair is the key, which - * must be a String, and the second element is the value - * associated with that key. See the class description for - * details. - * - * @return an array of an Object array representing a key-value pair. - */ - protected abstract Object[][] getContents(); - - /** - * Returns the parent of this resource bundle or null if there's no parent. - * - * @return the parent or null if no parent - */ - ResourceBundle getParent() { - return parent; - } - - /** - * Sets the parallel contents to the data given by rb. If rb is null, this - * bundle will be marked as `complete'. - * - * @param rb an OpenResourceBundle for parallel contents, or null indicating - * there are no parallel contents for this bundle - */ - public void setParallelContents(OpenListResourceBundle rb) { - if (rb == null) { - parallelContents.compareAndSet(null, null, false, true); - } else { - parallelContents.compareAndSet(null, rb.getContents(), false, false); - } - } - - /** - * Returns true if any parallel contents have been set or if this bundle is - * marked as complete. - * - * @return true if any parallel contents have been processed - */ - boolean areParallelContentsComplete() { - // Quick check for `complete' - if (parallelContents.isMarked()) { - return true; - } - boolean[] done = new boolean[1]; - Object[][] data = parallelContents.get(done); - return data != null || done[0]; - } - - @Override - protected Object handleGetObject(String key) { - if (key == null) { - throw new NullPointerException(); - } - - loadLookupTablesIfNecessary(); - return lookup.get(key); - } - - @Override - public Enumeration getKeys() { - return Collections.enumeration(keySet()); - } - - @Override - public boolean containsKey(String key) { - return keySet().contains(key); - } - - @Override - protected Set handleKeySet() { - loadLookupTablesIfNecessary(); - return lookup.keySet(); - } - - @Override - @SuppressWarnings("UnusedAssignment") - public Set keySet() { - Set ks; - while ((ks = keyset) == null) { - ks = new KeySet(handleKeySet(), parent); - synchronized (this) { - if (keyset == null) { - keyset = ks; - } - } - } - return ks; - } - - /** - * Discards any cached keyset value. This method is called from - * LocaleData for re-creating a KeySet. - */ - synchronized void resetKeySet() { - keyset = null; - } - - /** - * Loads the lookup table if they haven't been loaded already. - */ - void loadLookupTablesIfNecessary() { - ConcurrentMap map = lookup; - if (map == null) { - map = new ConcurrentHashMap<>(); - for (Object[] item : getContents()) { - map.put((String) item[0], item[1]); - } - } - - // If there's any parallel contents data, merge the data into map. - Object[][] data = parallelContents.getReference(); - if (data != null) { - for (Object[] item : data) { - map.putIfAbsent((String) item[0], item[1]); - } - parallelContents.set(null, true); - } - if (lookup == null) { - synchronized (this) { - if (lookup == null) { - lookup = map; - } - } - } - } - - /** - * This class implements the Set interface for - * ParallelListResourceBundle methods. - */ - private static class KeySet extends AbstractSet { - private final Set set; - private final ResourceBundle parent; - - private KeySet(Set set, ResourceBundle parent) { - this.set = set; - this.parent = parent; - } - - @Override - public boolean contains(Object o) { - if (set.contains(o)) { - return true; - } - return (parent != null) ? parent.containsKey((String) o) : false; - } - - @Override - public Iterator iterator() { - if (parent == null) { - return set.iterator(); - } - return new Iterator<>() { - private Iterator itr = set.iterator(); - private boolean usingParent; - - @Override - public boolean hasNext() { - if (itr.hasNext()) { - return true; - } - if (!usingParent) { - Set nextset = new HashSet<>(parent.keySet()); - nextset.removeAll(set); - itr = nextset.iterator(); - usingParent = true; - } - return itr.hasNext(); - } - - @Override - public String next() { - if (hasNext()) { - return itr.next(); - } - throw new NoSuchElementException(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - - @Override - public int size() { - if (parent == null) { - return set.size(); - } - Set allset = new HashSet<>(set); - allset.addAll(parent.keySet()); - return allset.size(); - } - } -} diff --git a/src/jdk.localedata/share/classes/module-info.java b/src/jdk.localedata/share/classes/module-info.java index 3705cf3137e..a04cf2f6f63 100644 --- a/src/jdk.localedata/share/classes/module-info.java +++ b/src/jdk.localedata/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, 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 @@ -33,6 +33,6 @@ module jdk.localedata { provides sun.util.locale.provider.LocaleDataMetaInfo with sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo, sun.util.resources.provider.NonBaseLocaleDataMetaInfo; - provides sun.util.resources.LocaleData.CommonResourceBundleProvider with + provides sun.util.resources.LocaleData.LocaleDataResourceBundleProvider with sun.util.resources.provider.LocaleDataProvider; } diff --git a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData.java b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData.java index 0bbbd735f48..f393d5fd041 100644 --- a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData.java +++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -25,9 +25,9 @@ package sun.text.resources.ext; -import sun.util.resources.ParallelListResourceBundle; +import sun.util.resources.OpenListResourceBundle; -public class FormatData extends ParallelListResourceBundle { +public class FormatData extends OpenListResourceBundle { /** * Exists to keep sun.text.resources.ext package alive * with IncludeLocales jlink plugin diff --git a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_ja.java b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_ja.java index d9a3ebafe14..4ae7bf08a0a 100644 --- a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_ja.java +++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_ja.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2025, 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 @@ -76,11 +76,11 @@ package sun.text.resources.ext; -import sun.util.resources.ParallelListResourceBundle; +import sun.util.resources.OpenListResourceBundle; -public class FormatData_ja extends ParallelListResourceBundle { +public class FormatData_ja extends OpenListResourceBundle { /** - * Overrides ParallelListResourceBundle + * Overrides OpenListResourceBundle */ @Override protected final Object[][] getContents() { diff --git a/src/jdk.localedata/share/classes/sun/util/resources/provider/LocaleDataProvider.java b/src/jdk.localedata/share/classes/sun/util/resources/provider/LocaleDataProvider.java index 96041fea03f..c901af3a41b 100644 --- a/src/jdk.localedata/share/classes/sun/util/resources/provider/LocaleDataProvider.java +++ b/src/jdk.localedata/share/classes/sun/util/resources/provider/LocaleDataProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, 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 @@ -32,7 +32,7 @@ import sun.util.resources.LocaleData; /** * Service Provider for loading locale data resource bundles in jdk.localedata */ -public class LocaleDataProvider extends LocaleData.CommonResourceBundleProvider { +public class LocaleDataProvider extends LocaleData.LocaleDataResourceBundleProvider { @Override public ResourceBundle getBundle(String baseName, Locale locale) { var bundleName = toBundleName(baseName, locale);