8358734: Remove JavaTimeSupplementary resource bundles

Reviewed-by: jlu, joehw, iris
This commit is contained in:
Naoto Sato 2025-06-11 16:04:26 +00:00
parent e5196fc24d
commit e9216efefc
11 changed files with 301 additions and 830 deletions

View File

@ -402,8 +402,7 @@ module java.base {
uses sun.text.spi.JavaTimeDateTimePatternProvider; uses sun.text.spi.JavaTimeDateTimePatternProvider;
uses sun.util.spi.CalendarProvider; uses sun.util.spi.CalendarProvider;
uses sun.util.locale.provider.LocaleDataMetaInfo; uses sun.util.locale.provider.LocaleDataMetaInfo;
uses sun.util.resources.LocaleData.CommonResourceBundleProvider; uses sun.util.resources.LocaleData.LocaleDataResourceBundleProvider;
uses sun.util.resources.LocaleData.SupplementaryResourceBundleProvider;
// Built-in service providers that are located via ServiceLoader // Built-in service providers that are located via ServiceLoader

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,9 +23,6 @@
* questions. * questions.
*/ */
/*
*/
/* /*
* (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
* (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved * (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
@ -79,11 +76,11 @@
package sun.text.resources; 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 @Override
protected final Object[][] getContents() { protected final Object[][] getContents() {
@ -119,6 +116,109 @@ public class FormatData extends ParallelListResourceBundle {
"Reiwa", "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[][] { return new Object[][] {
{ "MonthNames", { "MonthNames",
new String[] { new String[] {
@ -138,39 +238,9 @@ public class FormatData extends ParallelListResourceBundle {
} }
}, },
{ "MonthAbbreviations", { "MonthAbbreviations",
new String[] { sharedMonthAbbrs },
"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
}
},
{ "MonthNarrows", { "MonthNarrows",
new String[] { sharedMonthNarrows },
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"",
}
},
{ "DayNames", { "DayNames",
new String[] { new String[] {
"Sunday", // Sunday "Sunday", // Sunday
@ -183,33 +253,11 @@ public class FormatData extends ParallelListResourceBundle {
} }
}, },
{ "DayAbbreviations", { "DayAbbreviations",
new String[] { sharedDayAbbrs },
"Sun", // abb Sunday
"Mon", // abb Monday
"Tue", // abb Tuesday
"Wed", // abb Wednesday
"Thu", // abb Thursday
"Fri", // abb Friday
"Sat" // abb Saturday
}
},
{ "DayNarrows", { "DayNarrows",
new String[] { sharedDayNarrows },
"S",
"M",
"T",
"W",
"T",
"F",
"S",
}
},
{ "AmPmMarkers", { "AmPmMarkers",
new String[] { sharedAmPmMarkers },
"AM", // am marker
"PM" // pm marker
}
},
{ "narrow.AmPmMarkers", { "narrow.AmPmMarkers",
new String[] { new String[] {
"a", // am marker "a", // am marker
@ -227,22 +275,17 @@ public class FormatData extends ParallelListResourceBundle {
} }
}, },
{ "buddhist.Eras", { "buddhist.Eras",
buddhistEras buddhistEras },
},
{ "buddhist.short.Eras", { "buddhist.short.Eras",
buddhistEras buddhistEras },
},
{ "buddhist.narrow.Eras", { "buddhist.narrow.Eras",
buddhistEras buddhistEras },
},
{ "japanese.Eras", { "japanese.Eras",
japaneseEras }, japaneseEras },
{ "japanese.short.Eras", { "japanese.short.Eras",
japaneseEraAbbrs japaneseEraAbbrs },
},
{ "japanese.narrow.Eras", { "japanese.narrow.Eras",
japaneseEraAbbrs japaneseEraAbbrs },
},
{ "japanese.FirstYear", { "japanese.FirstYear",
new String[] { // Japanese imperial calendar year name new String[] { // Japanese imperial calendar year name
// empty in English // empty in English
@ -898,6 +941,164 @@ public class FormatData extends ParallelListResourceBundle {
} }
}, },
{ "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, { "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" },
}; };
} }
} }

View File

@ -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" },
};
}
}

View File

@ -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 {
}

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 jdk.internal.util.StaticProperty;
import sun.util.resources.LocaleData; import sun.util.resources.LocaleData;
import sun.util.resources.OpenListResourceBundle; import sun.util.resources.OpenListResourceBundle;
import sun.util.resources.ParallelListResourceBundle;
import sun.util.resources.TimeZoneNamesBundle; import sun.util.resources.TimeZoneNamesBundle;
/** /**
@ -579,11 +578,7 @@ public class LocaleResources {
* resources required by JSR 310. * resources required by JSR 310.
*/ */
public ResourceBundle getJavaTimeFormatData() { public ResourceBundle getJavaTimeFormatData() {
ResourceBundle rb = localeData.getDateFormatData(locale); return localeData.getDateFormatData(locale);
if (rb instanceof ParallelListResourceBundle) {
localeData.setSupplementary((ParallelListResourceBundle) rb);
}
return rb;
} }
/** /**

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -143,30 +142,6 @@ public class LocaleData {
return getBundle(type.getTextResourcesPackage() + ".FormatData", locale); 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 * Gets a number format data resource bundle, using privileges
* to allow accessing a sun.* package. * to allow accessing a sun.* package.
@ -179,18 +154,7 @@ public class LocaleData {
return Bundles.of(baseName, locale, LocaleDataStrategy.INSTANCE); return Bundles.of(baseName, locale, LocaleDataStrategy.INSTANCE);
} }
private static OpenListResourceBundle getSupplementary(final String baseName, final Locale locale) { public abstract static class LocaleDataResourceBundleProvider
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
implements ResourceBundleProvider { implements ResourceBundleProvider {
/** /**
* Changes baseName to its module dependent package name and * 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 // Bundles.Strategy implementations
private static class LocaleDataStrategy implements Bundles.Strategy { private static class LocaleDataStrategy implements Bundles.Strategy {
@ -254,18 +204,20 @@ public class LocaleData {
if (candidates == null) { if (candidates == null) {
LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE; LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type); LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
candidates = adapter instanceof ResourceBundleBasedAdapter ? candidates = adapter instanceof ResourceBundleBasedAdapter rbba ?
((ResourceBundleBasedAdapter)adapter).getCandidateLocales(baseName, locale) : rbba.getCandidateLocales(baseName, locale) :
defaultControl.getCandidateLocales(baseName, locale); defaultControl.getCandidateLocales(baseName, locale);
// Weed out Locales which are known to have no resource bundles // Weed out Locales which are known to have no resource bundles
int lastDot = baseName.lastIndexOf('.'); int lastDot = baseName.lastIndexOf('.');
String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName; String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category); if (adapter instanceof JRELocaleProviderAdapter jlpa) {
if (!langtags.isEmpty()) { var langtags = jlpa.getLanguageTagSet(category);
for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) { if (!langtags.isEmpty()) {
if (!adapter.isSupportedProviderLocale(itr.next(), langtags)) { for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
itr.remove(); if (!jlpa.isSupportedProviderLocale(itr.next(), langtags)) {
itr.remove();
}
} }
} }
} }
@ -302,36 +254,7 @@ public class LocaleData {
public Class<? extends ResourceBundleProvider> getResourceBundleProviderType(String baseName, public Class<? extends ResourceBundleProvider> getResourceBundleProviderType(String baseName,
Locale locale) { Locale locale) {
return inJavaBaseModule(baseName, locale) ? return inJavaBaseModule(baseName, locale) ?
null : CommonResourceBundleProvider.class; null : LocaleDataResourceBundleProvider.class;
}
}
private static class SupplementaryStrategy extends LocaleDataStrategy {
private static final SupplementaryStrategy INSTANCE
= new SupplementaryStrategy();
// TODO: avoid hard-coded Locales
private static final Set<Locale> JAVA_BASE_LOCALES
= Set.of(Locale.ROOT, Locale.ENGLISH, Locale.US);
private SupplementaryStrategy() {
}
@Override
public List<Locale> getCandidateLocales(String baseName, Locale locale) {
// Specify only the given locale
return List.of(locale);
}
@Override
public Class<? extends ResourceBundleProvider> 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);
} }
} }
} }

View File

@ -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<String, Object> lookup;
private volatile Set<String> keyset;
private final AtomicMarkableReference<Object[][]> 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<String> getKeys() {
return Collections.enumeration(keySet());
}
@Override
public boolean containsKey(String key) {
return keySet().contains(key);
}
@Override
protected Set<String> handleKeySet() {
loadLookupTablesIfNecessary();
return lookup.keySet();
}
@Override
@SuppressWarnings("UnusedAssignment")
public Set<String> keySet() {
Set<String> 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<String, Object> 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<String> {
private final Set<String> set;
private final ResourceBundle parent;
private KeySet(Set<String> 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<String> iterator() {
if (parent == null) {
return set.iterator();
}
return new Iterator<>() {
private Iterator<String> itr = set.iterator();
private boolean usingParent;
@Override
public boolean hasNext() {
if (itr.hasNext()) {
return true;
}
if (!usingParent) {
Set<String> 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<String> allset = new HashSet<>(set);
allset.addAll(parent.keySet());
return allset.size();
}
}
}

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 provides sun.util.locale.provider.LocaleDataMetaInfo with
sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo, sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo,
sun.util.resources.provider.NonBaseLocaleDataMetaInfo; sun.util.resources.provider.NonBaseLocaleDataMetaInfo;
provides sun.util.resources.LocaleData.CommonResourceBundleProvider with provides sun.util.resources.LocaleData.LocaleDataResourceBundleProvider with
sun.util.resources.provider.LocaleDataProvider; sun.util.resources.provider.LocaleDataProvider;
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,9 +25,9 @@
package sun.text.resources.ext; 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 * Exists to keep sun.text.resources.ext package alive
* with IncludeLocales jlink plugin * with IncludeLocales jlink plugin

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -76,11 +76,11 @@
package sun.text.resources.ext; 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 @Override
protected final Object[][] getContents() { protected final Object[][] getContents() {

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 * Service Provider for loading locale data resource bundles in jdk.localedata
*/ */
public class LocaleDataProvider extends LocaleData.CommonResourceBundleProvider { public class LocaleDataProvider extends LocaleData.LocaleDataResourceBundleProvider {
@Override @Override
public ResourceBundle getBundle(String baseName, Locale locale) { public ResourceBundle getBundle(String baseName, Locale locale) {
var bundleName = toBundleName(baseName, locale); var bundleName = toBundleName(baseName, locale);