From 10186ff48fe67aeb83c028b47f6b7e5105513cf3 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Wed, 17 Jul 2024 16:25:36 +0000 Subject: [PATCH] 8336300: DateFormatSymbols#getInstanceRef returns non-cached instance Reviewed-by: joehw, iris, jlu, aturbanov --- .../classes/java/text/DateFormatSymbols.java | 16 +--------------- .../classes/java/text/SimpleDateFormat.java | 4 ++-- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/java.base/share/classes/java/text/DateFormatSymbols.java b/src/java.base/share/classes/java/text/DateFormatSymbols.java index 372752bf737..f08f5e78338 100644 --- a/src/java.base/share/classes/java/text/DateFormatSymbols.java +++ b/src/java.base/share/classes/java/text/DateFormatSymbols.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2023, 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. * * This code is free software; you can redistribute it and/or modify it @@ -351,20 +351,6 @@ public class DateFormatSymbols implements Serializable, Cloneable { throw new RuntimeException("DateFormatSymbols instance creation failed."); } - /** - * Returns a DateFormatSymbols provided by a provider or found in - * the cache. Note that this method returns a cached instance, - * not its clone. Therefore, the instance should never be given to - * an application. - */ - static final DateFormatSymbols getInstanceRef(Locale locale) { - DateFormatSymbols dfs = getProviderInstance(locale); - if (dfs != null) { - return dfs; - } - throw new RuntimeException("DateFormatSymbols instance creation failed."); - } - private static DateFormatSymbols getProviderInstance(Locale locale) { LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale); DateFormatSymbolsProvider provider = adapter.getDateFormatSymbolsProvider(); diff --git a/src/java.base/share/classes/java/text/SimpleDateFormat.java b/src/java.base/share/classes/java/text/SimpleDateFormat.java index 6f4aa130a41..dbc7235cbc4 100644 --- a/src/java.base/share/classes/java/text/SimpleDateFormat.java +++ b/src/java.base/share/classes/java/text/SimpleDateFormat.java @@ -623,7 +623,7 @@ public class SimpleDateFormat extends DateFormat { initializeCalendar(locale); this.pattern = pattern; - this.formatData = DateFormatSymbols.getInstanceRef(locale); + formatData = DateFormatSymbols.getInstance(locale); this.locale = locale; initialize(locale); } @@ -644,7 +644,7 @@ public class SimpleDateFormat extends DateFormat { } this.pattern = pattern; - this.formatData = (DateFormatSymbols) formatSymbols.clone(); + formatData = (DateFormatSymbols) formatSymbols.clone(); this.locale = Locale.getDefault(Locale.Category.FORMAT); initializeCalendar(this.locale); initialize(this.locale);