8344898: SM cleanup of java.base sun/util calendar, locale, cldr, and resources
Reviewed-by: naoto
This commit is contained in:
parent
4d898aa451
commit
df2d4c1575
@ -33,8 +33,6 @@ import java.io.File;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StreamCorruptedException;
|
import java.io.StreamCorruptedException;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
@ -212,23 +210,17 @@ public final class ZoneInfoFile {
|
|||||||
loadTZDB();
|
loadTZDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static void loadTZDB() {
|
private static void loadTZDB() {
|
||||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
try {
|
||||||
public Void run() {
|
String libDir = StaticProperty.javaHome() + File.separator + "lib";
|
||||||
try {
|
try (DataInputStream dis = new DataInputStream(
|
||||||
String libDir = StaticProperty.javaHome() + File.separator + "lib";
|
new BufferedInputStream(new FileInputStream(
|
||||||
try (DataInputStream dis = new DataInputStream(
|
new File(libDir, "tzdb.dat"))))) {
|
||||||
new BufferedInputStream(new FileInputStream(
|
load(dis);
|
||||||
new File(libDir, "tzdb.dat"))))) {
|
|
||||||
load(dis);
|
|
||||||
}
|
|
||||||
} catch (Exception x) {
|
|
||||||
throw new Error(x);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
});
|
} catch (Exception x) {
|
||||||
|
throw new Error(x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,10 +25,6 @@
|
|||||||
|
|
||||||
package sun.util.cldr;
|
package sun.util.cldr;
|
||||||
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.security.PrivilegedActionException;
|
|
||||||
import java.security.PrivilegedExceptionAction;
|
|
||||||
import java.text.spi.BreakIteratorProvider;
|
import java.text.spi.BreakIteratorProvider;
|
||||||
import java.text.spi.CollatorProvider;
|
import java.text.spi.CollatorProvider;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -75,24 +71,14 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter {
|
|||||||
parentLocalesMap.put(Locale.US, Locale.US);
|
parentLocalesMap.put(Locale.US, Locale.US);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public CLDRLocaleProviderAdapter() {
|
public CLDRLocaleProviderAdapter() {
|
||||||
LocaleDataMetaInfo nbmi;
|
for (LocaleDataMetaInfo ldmi : ServiceLoader.loadInstalled(LocaleDataMetaInfo.class)) {
|
||||||
|
if (ldmi.getType() == Type.CLDR) {
|
||||||
try {
|
nonBaseMetaInfo = ldmi;
|
||||||
nbmi = AccessController.doPrivileged((PrivilegedExceptionAction<LocaleDataMetaInfo>) () -> {
|
return;
|
||||||
for (LocaleDataMetaInfo ldmi : ServiceLoader.loadInstalled(LocaleDataMetaInfo.class)) {
|
}
|
||||||
if (ldmi.getType() == Type.CLDR) {
|
|
||||||
return ldmi;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
} catch (PrivilegedActionException pae) {
|
|
||||||
throw new InternalError(pae.getCause());
|
|
||||||
}
|
}
|
||||||
|
nonBaseMetaInfo = null;
|
||||||
nonBaseMetaInfo = nbmi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,12 +98,9 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public CalendarDataProvider getCalendarDataProvider() {
|
public CalendarDataProvider getCalendarDataProvider() {
|
||||||
if (calendarDataProvider == null) {
|
if (calendarDataProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
CalendarDataProvider provider = new CLDRCalendarDataProviderImpl(
|
||||||
CalendarDataProvider provider = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<CalendarDataProvider>) () ->
|
|
||||||
new CLDRCalendarDataProviderImpl(
|
|
||||||
getAdapterType(),
|
getAdapterType(),
|
||||||
getLanguageTagSet("CalendarData")));
|
getLanguageTagSet("CalendarData"));
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (calendarDataProvider == null) {
|
if (calendarDataProvider == null) {
|
||||||
@ -131,12 +114,9 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public CalendarNameProvider getCalendarNameProvider() {
|
public CalendarNameProvider getCalendarNameProvider() {
|
||||||
if (calendarNameProvider == null) {
|
if (calendarNameProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
CalendarNameProvider provider = new CLDRCalendarNameProviderImpl(
|
||||||
CalendarNameProvider provider = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<CalendarNameProvider>) ()
|
|
||||||
-> new CLDRCalendarNameProviderImpl(
|
|
||||||
getAdapterType(),
|
getAdapterType(),
|
||||||
getLanguageTagSet("FormatData")));
|
getLanguageTagSet("FormatData"));
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (calendarNameProvider == null) {
|
if (calendarNameProvider == null) {
|
||||||
@ -155,12 +135,9 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public TimeZoneNameProvider getTimeZoneNameProvider() {
|
public TimeZoneNameProvider getTimeZoneNameProvider() {
|
||||||
if (timeZoneNameProvider == null) {
|
if (timeZoneNameProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
TimeZoneNameProvider provider = new CLDRTimeZoneNameProviderImpl(
|
||||||
TimeZoneNameProvider provider = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<TimeZoneNameProvider>) () ->
|
|
||||||
new CLDRTimeZoneNameProviderImpl(
|
|
||||||
getAdapterType(),
|
getAdapterType(),
|
||||||
getLanguageTagSet("TimeZoneNames")));
|
getLanguageTagSet("TimeZoneNames"));
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (timeZoneNameProvider == null) {
|
if (timeZoneNameProvider == null) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2024, 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,8 +25,6 @@
|
|||||||
|
|
||||||
package sun.util.locale.provider;
|
package sun.util.locale.provider;
|
||||||
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.text.spi.BreakIteratorProvider;
|
import java.text.spi.BreakIteratorProvider;
|
||||||
import java.text.spi.CollatorProvider;
|
import java.text.spi.CollatorProvider;
|
||||||
import java.text.spi.DateFormatProvider;
|
import java.text.spi.DateFormatProvider;
|
||||||
@ -186,9 +184,7 @@ public abstract class AuxLocaleProviderAdapter extends LocaleProviderAdapter {
|
|||||||
* A dummy locale service provider that indicates there is no
|
* A dummy locale service provider that indicates there is no
|
||||||
* provider available
|
* provider available
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
private static final NullProvider NULL_PROVIDER = new NullProvider();
|
||||||
private static final NullProvider NULL_PROVIDER = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<NullProvider>) () -> new NullProvider());
|
|
||||||
|
|
||||||
private static class NullProvider extends LocaleServiceProvider {
|
private static class NullProvider extends LocaleServiceProvider {
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
package sun.util.locale.provider;
|
package sun.util.locale.provider;
|
||||||
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.text.spi.BreakIteratorProvider;
|
import java.text.spi.BreakIteratorProvider;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -85,12 +83,9 @@ public class FallbackLocaleProviderAdapter extends JRELocaleProviderAdapter {
|
|||||||
// In order to correctly report supported locales
|
// In order to correctly report supported locales
|
||||||
public BreakIteratorProvider getBreakIteratorProvider() {
|
public BreakIteratorProvider getBreakIteratorProvider() {
|
||||||
if (breakIteratorProvider == null) {
|
if (breakIteratorProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
BreakIteratorProvider provider = new BreakIteratorProviderImpl(
|
||||||
BreakIteratorProvider provider = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<BreakIteratorProvider>) () ->
|
|
||||||
new BreakIteratorProviderImpl(
|
|
||||||
getAdapterType(),
|
getAdapterType(),
|
||||||
getLanguageTagSet("BreakIteratorRules")));
|
getLanguageTagSet("BreakIteratorRules"));
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (breakIteratorProvider == null) {
|
if (breakIteratorProvider == null) {
|
||||||
|
@ -25,10 +25,6 @@
|
|||||||
|
|
||||||
package sun.util.locale.provider;
|
package sun.util.locale.provider;
|
||||||
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.security.PrivilegedActionException;
|
|
||||||
import java.security.PrivilegedExceptionAction;
|
|
||||||
import java.text.spi.BreakIteratorProvider;
|
import java.text.spi.BreakIteratorProvider;
|
||||||
import java.text.spi.CollatorProvider;
|
import java.text.spi.CollatorProvider;
|
||||||
import java.text.spi.DateFormatProvider;
|
import java.text.spi.DateFormatProvider;
|
||||||
@ -139,12 +135,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
@Override
|
@Override
|
||||||
public BreakIteratorProvider getBreakIteratorProvider() {
|
public BreakIteratorProvider getBreakIteratorProvider() {
|
||||||
if (breakIteratorProvider == null) {
|
if (breakIteratorProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
BreakIteratorProvider provider = new BreakIteratorProviderImpl(
|
||||||
BreakIteratorProvider provider = AccessController.doPrivileged(
|
getAdapterType(),
|
||||||
(PrivilegedAction<BreakIteratorProvider>) () ->
|
getLanguageTagSet("FormatData"));
|
||||||
new BreakIteratorProviderImpl(
|
|
||||||
getAdapterType(),
|
|
||||||
getLanguageTagSet("FormatData")));
|
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (breakIteratorProvider == null) {
|
if (breakIteratorProvider == null) {
|
||||||
@ -158,12 +151,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
@Override
|
@Override
|
||||||
public CollatorProvider getCollatorProvider() {
|
public CollatorProvider getCollatorProvider() {
|
||||||
if (collatorProvider == null) {
|
if (collatorProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
CollatorProvider provider = new CollatorProviderImpl(
|
||||||
CollatorProvider provider = AccessController.doPrivileged(
|
getAdapterType(),
|
||||||
(PrivilegedAction<CollatorProvider>) () ->
|
getLanguageTagSet("CollationData"));
|
||||||
new CollatorProviderImpl(
|
|
||||||
getAdapterType(),
|
|
||||||
getLanguageTagSet("CollationData")));
|
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (collatorProvider == null) {
|
if (collatorProvider == null) {
|
||||||
@ -177,12 +167,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
@Override
|
@Override
|
||||||
public DateFormatProvider getDateFormatProvider() {
|
public DateFormatProvider getDateFormatProvider() {
|
||||||
if (dateFormatProvider == null) {
|
if (dateFormatProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
DateFormatProvider provider = new DateFormatProviderImpl(
|
||||||
DateFormatProvider provider = AccessController.doPrivileged(
|
getAdapterType(),
|
||||||
(PrivilegedAction<DateFormatProvider>) () ->
|
getLanguageTagSet("FormatData"));
|
||||||
new DateFormatProviderImpl(
|
|
||||||
getAdapterType(),
|
|
||||||
getLanguageTagSet("FormatData")));
|
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (dateFormatProvider == null) {
|
if (dateFormatProvider == null) {
|
||||||
@ -196,12 +183,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
@Override
|
@Override
|
||||||
public DateFormatSymbolsProvider getDateFormatSymbolsProvider() {
|
public DateFormatSymbolsProvider getDateFormatSymbolsProvider() {
|
||||||
if (dateFormatSymbolsProvider == null) {
|
if (dateFormatSymbolsProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
DateFormatSymbolsProvider provider = new DateFormatSymbolsProviderImpl(
|
||||||
DateFormatSymbolsProvider provider = AccessController.doPrivileged(
|
getAdapterType(),
|
||||||
(PrivilegedAction<DateFormatSymbolsProvider>) () ->
|
getLanguageTagSet("FormatData"));
|
||||||
new DateFormatSymbolsProviderImpl(
|
|
||||||
getAdapterType(),
|
|
||||||
getLanguageTagSet("FormatData")));
|
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (dateFormatSymbolsProvider == null) {
|
if (dateFormatSymbolsProvider == null) {
|
||||||
@ -215,12 +199,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
@Override
|
@Override
|
||||||
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
|
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
|
||||||
if (decimalFormatSymbolsProvider == null) {
|
if (decimalFormatSymbolsProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
DecimalFormatSymbolsProvider provider = new DecimalFormatSymbolsProviderImpl(
|
||||||
DecimalFormatSymbolsProvider provider = AccessController.doPrivileged(
|
getAdapterType(),
|
||||||
(PrivilegedAction<DecimalFormatSymbolsProvider>) () ->
|
getLanguageTagSet("FormatData"));
|
||||||
new DecimalFormatSymbolsProviderImpl(
|
|
||||||
getAdapterType(),
|
|
||||||
getLanguageTagSet("FormatData")));
|
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (decimalFormatSymbolsProvider == null) {
|
if (decimalFormatSymbolsProvider == null) {
|
||||||
@ -234,12 +215,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
@Override
|
@Override
|
||||||
public NumberFormatProvider getNumberFormatProvider() {
|
public NumberFormatProvider getNumberFormatProvider() {
|
||||||
if (numberFormatProvider == null) {
|
if (numberFormatProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
NumberFormatProvider provider = new NumberFormatProviderImpl(
|
||||||
NumberFormatProvider provider = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<NumberFormatProvider>) () ->
|
|
||||||
new NumberFormatProviderImpl(
|
|
||||||
getAdapterType(),
|
getAdapterType(),
|
||||||
getLanguageTagSet("FormatData")));
|
getLanguageTagSet("FormatData"));
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (numberFormatProvider == null) {
|
if (numberFormatProvider == null) {
|
||||||
@ -256,12 +234,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
@Override
|
@Override
|
||||||
public CurrencyNameProvider getCurrencyNameProvider() {
|
public CurrencyNameProvider getCurrencyNameProvider() {
|
||||||
if (currencyNameProvider == null) {
|
if (currencyNameProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
CurrencyNameProvider provider = new CurrencyNameProviderImpl(
|
||||||
CurrencyNameProvider provider = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<CurrencyNameProvider>) () ->
|
|
||||||
new CurrencyNameProviderImpl(
|
|
||||||
getAdapterType(),
|
getAdapterType(),
|
||||||
getLanguageTagSet("CurrencyNames")));
|
getLanguageTagSet("CurrencyNames"));
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (currencyNameProvider == null) {
|
if (currencyNameProvider == null) {
|
||||||
@ -275,12 +250,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
@Override
|
@Override
|
||||||
public LocaleNameProvider getLocaleNameProvider() {
|
public LocaleNameProvider getLocaleNameProvider() {
|
||||||
if (localeNameProvider == null) {
|
if (localeNameProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
LocaleNameProvider provider = new LocaleNameProviderImpl(
|
||||||
LocaleNameProvider provider = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<LocaleNameProvider>) () ->
|
|
||||||
new LocaleNameProviderImpl(
|
|
||||||
getAdapterType(),
|
getAdapterType(),
|
||||||
getLanguageTagSet("LocaleNames")));
|
getLanguageTagSet("LocaleNames"));
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (localeNameProvider == null) {
|
if (localeNameProvider == null) {
|
||||||
@ -294,12 +266,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
@Override
|
@Override
|
||||||
public TimeZoneNameProvider getTimeZoneNameProvider() {
|
public TimeZoneNameProvider getTimeZoneNameProvider() {
|
||||||
if (timeZoneNameProvider == null) {
|
if (timeZoneNameProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
TimeZoneNameProvider provider = new TimeZoneNameProviderImpl(
|
||||||
TimeZoneNameProvider provider = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<TimeZoneNameProvider>) () ->
|
|
||||||
new TimeZoneNameProviderImpl(
|
|
||||||
getAdapterType(),
|
getAdapterType(),
|
||||||
getLanguageTagSet("TimeZoneNames")));
|
getLanguageTagSet("TimeZoneNames"));
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (timeZoneNameProvider == null) {
|
if (timeZoneNameProvider == null) {
|
||||||
@ -313,12 +282,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
@Override
|
@Override
|
||||||
public CalendarDataProvider getCalendarDataProvider() {
|
public CalendarDataProvider getCalendarDataProvider() {
|
||||||
if (calendarDataProvider == null) {
|
if (calendarDataProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
CalendarDataProvider provider = new CalendarDataProviderImpl(
|
||||||
CalendarDataProvider provider = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<CalendarDataProvider>) () ->
|
|
||||||
new CalendarDataProviderImpl(
|
|
||||||
getAdapterType(),
|
getAdapterType(),
|
||||||
getLanguageTagSet("CalendarData")));
|
getLanguageTagSet("CalendarData"));
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (calendarDataProvider == null) {
|
if (calendarDataProvider == null) {
|
||||||
@ -332,12 +298,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
@Override
|
@Override
|
||||||
public CalendarNameProvider getCalendarNameProvider() {
|
public CalendarNameProvider getCalendarNameProvider() {
|
||||||
if (calendarNameProvider == null) {
|
if (calendarNameProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
CalendarNameProvider provider = new CalendarNameProviderImpl(
|
||||||
CalendarNameProvider provider = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<CalendarNameProvider>) () ->
|
|
||||||
new CalendarNameProviderImpl(
|
|
||||||
getAdapterType(),
|
getAdapterType(),
|
||||||
getLanguageTagSet("FormatData")));
|
getLanguageTagSet("FormatData"));
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (calendarNameProvider == null) {
|
if (calendarNameProvider == null) {
|
||||||
@ -354,12 +317,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
@Override
|
@Override
|
||||||
public CalendarProvider getCalendarProvider() {
|
public CalendarProvider getCalendarProvider() {
|
||||||
if (calendarProvider == null) {
|
if (calendarProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
CalendarProvider provider = new CalendarProviderImpl(
|
||||||
CalendarProvider provider = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<CalendarProvider>) () ->
|
|
||||||
new CalendarProviderImpl(
|
|
||||||
getAdapterType(),
|
getAdapterType(),
|
||||||
getLanguageTagSet("CalendarData")));
|
getLanguageTagSet("CalendarData"));
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (calendarProvider == null) {
|
if (calendarProvider == null) {
|
||||||
@ -376,12 +336,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
@Override
|
@Override
|
||||||
public JavaTimeDateTimePatternProvider getJavaTimeDateTimePatternProvider() {
|
public JavaTimeDateTimePatternProvider getJavaTimeDateTimePatternProvider() {
|
||||||
if (javaTimeDateTimePatternProvider == null) {
|
if (javaTimeDateTimePatternProvider == null) {
|
||||||
@SuppressWarnings("removal")
|
JavaTimeDateTimePatternProvider provider = new JavaTimeDateTimePatternImpl(
|
||||||
JavaTimeDateTimePatternProvider provider = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<JavaTimeDateTimePatternProvider>) ()
|
|
||||||
-> new JavaTimeDateTimePatternImpl(
|
|
||||||
getAdapterType(),
|
getAdapterType(),
|
||||||
getLanguageTagSet("FormatData")));
|
getLanguageTagSet("FormatData"));
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (javaTimeDateTimePatternProvider == null) {
|
if (javaTimeDateTimePatternProvider == null) {
|
||||||
@ -461,30 +418,23 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||||||
String supportedLocaleString = BaseLocaleDataMetaInfo.getSupportedLocaleString(category);
|
String supportedLocaleString = BaseLocaleDataMetaInfo.getSupportedLocaleString(category);
|
||||||
|
|
||||||
// Use ServiceLoader to dynamically acquire installed locales' tags.
|
// Use ServiceLoader to dynamically acquire installed locales' tags.
|
||||||
try {
|
StringBuilder tags = new StringBuilder();
|
||||||
@SuppressWarnings("removal")
|
for (LocaleDataMetaInfo ldmi :
|
||||||
String nonBaseTags = AccessController.doPrivileged((PrivilegedExceptionAction<String>) () -> {
|
ServiceLoader.loadInstalled(LocaleDataMetaInfo.class)) {
|
||||||
StringBuilder tags = new StringBuilder();
|
if (ldmi.getType() == LocaleProviderAdapter.Type.JRE) {
|
||||||
for (LocaleDataMetaInfo ldmi :
|
String t = ldmi.availableLanguageTags(category);
|
||||||
ServiceLoader.loadInstalled(LocaleDataMetaInfo.class)) {
|
if (t != null) {
|
||||||
if (ldmi.getType() == LocaleProviderAdapter.Type.JRE) {
|
if (!tags.isEmpty()) {
|
||||||
String t = ldmi.availableLanguageTags(category);
|
tags.append(' ');
|
||||||
if (t != null) {
|
|
||||||
if (!tags.isEmpty()) {
|
|
||||||
tags.append(' ');
|
|
||||||
}
|
|
||||||
tags.append(t);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
tags.append(t);
|
||||||
}
|
}
|
||||||
return tags.toString();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (nonBaseTags != null) {
|
|
||||||
supportedLocaleString += " " + nonBaseTags;
|
|
||||||
}
|
}
|
||||||
} catch (PrivilegedActionException pae) {
|
}
|
||||||
throw new InternalError(pae.getCause());
|
String nonBaseTags = tags.toString();
|
||||||
|
|
||||||
|
if (nonBaseTags != null) {
|
||||||
|
supportedLocaleString += " " + nonBaseTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
return supportedLocaleString;
|
return supportedLocaleString;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2024, 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,6 @@
|
|||||||
|
|
||||||
package sun.util.locale.provider;
|
package sun.util.locale.provider;
|
||||||
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedActionException;
|
|
||||||
import java.security.PrivilegedExceptionAction;
|
|
||||||
import java.text.BreakIterator;
|
import java.text.BreakIterator;
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
@ -69,43 +66,31 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
|
|||||||
return LocaleProviderAdapter.Type.SPI;
|
return LocaleProviderAdapter.Type.SPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings(value={"unchecked", "deprecation"})
|
||||||
protected <P extends LocaleServiceProvider> P findInstalledProvider(final Class<P> c) {
|
protected <P extends LocaleServiceProvider> P findInstalledProvider(final Class<P> c) {
|
||||||
try {
|
P delegate = null;
|
||||||
return AccessController.doPrivileged(new PrivilegedExceptionAction<>() {
|
for (LocaleServiceProvider provider :
|
||||||
@Override
|
ServiceLoader.load(c, ClassLoader.getSystemClassLoader())) {
|
||||||
@SuppressWarnings(value={"unchecked", "deprecation"})
|
if (delegate == null) {
|
||||||
public P run() {
|
try {
|
||||||
P delegate = null;
|
delegate =
|
||||||
|
(P) Class.forName(SPILocaleProviderAdapter.class.getCanonicalName() +
|
||||||
for (LocaleServiceProvider provider :
|
"$" +
|
||||||
ServiceLoader.load(c, ClassLoader.getSystemClassLoader())) {
|
c.getSimpleName() +
|
||||||
if (delegate == null) {
|
"Delegate")
|
||||||
try {
|
.newInstance();
|
||||||
delegate =
|
} catch (ClassNotFoundException |
|
||||||
(P) Class.forName(SPILocaleProviderAdapter.class.getCanonicalName() +
|
InstantiationException |
|
||||||
"$" +
|
IllegalAccessException e) {
|
||||||
c.getSimpleName() +
|
throw new ServiceConfigurationError(
|
||||||
"Delegate")
|
"SPI locale provider cannot be instantiated.", e);
|
||||||
.newInstance();
|
|
||||||
} catch (ClassNotFoundException |
|
|
||||||
InstantiationException |
|
|
||||||
IllegalAccessException e) {
|
|
||||||
throw new ServiceConfigurationError(
|
|
||||||
"SPI locale provider cannot be instantiated.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
((Delegate)delegate).addImpl(provider);
|
|
||||||
}
|
|
||||||
return delegate;
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
} catch (PrivilegedActionException e) {
|
|
||||||
throw new ServiceConfigurationError(
|
((Delegate)delegate).addImpl(provider);
|
||||||
"SPI locale provider cannot be instantiated.", e);
|
|
||||||
}
|
}
|
||||||
|
return delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2024, 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
|
||||||
@ -26,9 +26,6 @@
|
|||||||
package sun.util.resources;
|
package sun.util.resources;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedActionException;
|
|
||||||
import java.security.PrivilegedExceptionAction;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
@ -72,7 +69,7 @@ public abstract class BreakIteratorResourceBundle extends ResourceBundle {
|
|||||||
String path = getClass().getPackageName().replace('.', '/')
|
String path = getClass().getPackageName().replace('.', '/')
|
||||||
+ '/' + info.getString(key);
|
+ '/' + info.getString(key);
|
||||||
byte[] data;
|
byte[] data;
|
||||||
try (InputStream is = getResourceAsStream(path)) {
|
try (InputStream is = getClass().getModule().getResourceAsStream(path)) {
|
||||||
data = is.readAllBytes();
|
data = is.readAllBytes();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new InternalError("Can't load " + path, e);
|
throw new InternalError("Can't load " + path, e);
|
||||||
@ -80,19 +77,6 @@ public abstract class BreakIteratorResourceBundle extends ResourceBundle {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private InputStream getResourceAsStream(String path) throws Exception {
|
|
||||||
PrivilegedExceptionAction<InputStream> pa;
|
|
||||||
pa = () -> getClass().getModule().getResourceAsStream(path);
|
|
||||||
InputStream is;
|
|
||||||
try {
|
|
||||||
is = AccessController.doPrivileged(pa);
|
|
||||||
} catch (PrivilegedActionException e) {
|
|
||||||
throw e.getException();
|
|
||||||
}
|
|
||||||
return is;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Enumeration<String> getKeys() {
|
public Enumeration<String> getKeys() {
|
||||||
return Collections.enumeration(keySet());
|
return Collections.enumeration(keySet());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2024, 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
|
||||||
@ -42,8 +42,6 @@ package sun.util.resources;
|
|||||||
|
|
||||||
import java.lang.ref.ReferenceQueue;
|
import java.lang.ref.ReferenceQueue;
|
||||||
import java.lang.ref.SoftReference;
|
import java.lang.ref.SoftReference;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -255,32 +253,25 @@ public abstract class Bundles {
|
|||||||
/**
|
/**
|
||||||
* Loads ResourceBundle from service providers.
|
* Loads ResourceBundle from service providers.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static ResourceBundle loadBundleFromProviders(String baseName,
|
private static ResourceBundle loadBundleFromProviders(String baseName,
|
||||||
Locale locale,
|
Locale locale,
|
||||||
ServiceLoader<ResourceBundleProvider> providers,
|
ServiceLoader<ResourceBundleProvider> providers,
|
||||||
CacheKey cacheKey)
|
CacheKey cacheKey)
|
||||||
{
|
{
|
||||||
return AccessController.doPrivileged(
|
for (Iterator<ResourceBundleProvider> itr = providers.iterator(); itr.hasNext(); ) {
|
||||||
new PrivilegedAction<>() {
|
try {
|
||||||
public ResourceBundle run() {
|
ResourceBundleProvider provider = itr.next();
|
||||||
for (Iterator<ResourceBundleProvider> itr = providers.iterator(); itr.hasNext(); ) {
|
ResourceBundle bundle = provider.getBundle(baseName, locale);
|
||||||
try {
|
if (bundle != null) {
|
||||||
ResourceBundleProvider provider = itr.next();
|
return bundle;
|
||||||
ResourceBundle bundle = provider.getBundle(baseName, locale);
|
}
|
||||||
if (bundle != null) {
|
} catch (ServiceConfigurationError e) {
|
||||||
return bundle;
|
if (cacheKey != null) {
|
||||||
}
|
cacheKey.setCause(e);
|
||||||
} catch (ServiceConfigurationError | SecurityException e) {
|
}
|
||||||
if (cacheKey != null) {
|
}
|
||||||
cacheKey.setCause(e);
|
}
|
||||||
}
|
return null;
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isValidBundle(ResourceBundle bundle) {
|
private static boolean isValidBundle(ResourceBundle bundle) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2024, 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
|
||||||
@ -40,8 +40,6 @@
|
|||||||
|
|
||||||
package sun.util.resources;
|
package sun.util.resources;
|
||||||
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -177,31 +175,19 @@ public class LocaleData {
|
|||||||
return getBundle(type.getTextResourcesPackage() + ".FormatData", locale);
|
return getBundle(type.getTextResourcesPackage() + ".FormatData", locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public static ResourceBundle getBundle(final String baseName, final Locale locale) {
|
public static ResourceBundle getBundle(final String baseName, final Locale locale) {
|
||||||
return AccessController.doPrivileged(new PrivilegedAction<>() {
|
return Bundles.of(baseName, locale, LocaleDataStrategy.INSTANCE);
|
||||||
@Override
|
|
||||||
public ResourceBundle run() {
|
|
||||||
return Bundles.of(baseName, locale, LocaleDataStrategy.INSTANCE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static OpenListResourceBundle getSupplementary(final String baseName, final Locale locale) {
|
private static OpenListResourceBundle getSupplementary(final String baseName, final Locale locale) {
|
||||||
return AccessController.doPrivileged(new PrivilegedAction<>() {
|
OpenListResourceBundle rb = null;
|
||||||
@Override
|
try {
|
||||||
public OpenListResourceBundle run() {
|
rb = (OpenListResourceBundle) Bundles.of(baseName, locale,
|
||||||
OpenListResourceBundle rb = null;
|
SupplementaryStrategy.INSTANCE);
|
||||||
try {
|
} catch (MissingResourceException e) {
|
||||||
rb = (OpenListResourceBundle) Bundles.of(baseName, locale,
|
// return null if no supplementary is available
|
||||||
SupplementaryStrategy.INSTANCE);
|
}
|
||||||
} catch (MissingResourceException e) {
|
return rb;
|
||||||
// return null if no supplementary is available
|
|
||||||
}
|
|
||||||
return rb;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private abstract static class LocaleDataResourceBundleProvider
|
private abstract static class LocaleDataResourceBundleProvider
|
||||||
|
Loading…
Reference in New Issue
Block a user