File tree Expand file tree Collapse file tree 4 files changed +25
-5
lines changed
src/java.base/share/classes/java/text
test/jdk/java/text/Format Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -145,10 +145,12 @@ public DateFormatSymbols()
145145 * @throws java.util.MissingResourceException
146146 * if the resources for the specified locale cannot be
147147 * found or cannot be loaded.
148+ * @throws NullPointerException if {@code locale} is null
148149 */
149150 public DateFormatSymbols (Locale locale )
150151 {
151- initializeData (locale );
152+ initializeData (Objects .requireNonNull (locale ,
153+ "locale should not be null" ));
152154 }
153155
154156 /**
@@ -344,6 +346,7 @@ public static final DateFormatSymbols getInstance() {
344346 * @since 1.6
345347 */
346348 public static final DateFormatSymbols getInstance (Locale locale ) {
349+ Objects .requireNonNull (locale , "locale should not be null" );
347350 DateFormatSymbols dfs = getProviderInstance (locale );
348351 if (dfs != null ) {
349352 return dfs ;
Original file line number Diff line number Diff line change @@ -115,7 +115,8 @@ public DecimalFormatSymbols() {
115115 * @throws NullPointerException if {@code locale} is null
116116 */
117117 public DecimalFormatSymbols (Locale locale ) {
118- initialize (locale );
118+ initialize (Objects .requireNonNull (locale ,
119+ "locale should not be null" ));
119120 }
120121
121122 /**
@@ -180,6 +181,7 @@ public static final DecimalFormatSymbols getInstance() {
180181 * @since 1.6
181182 */
182183 public static final DecimalFormatSymbols getInstance (Locale locale ) {
184+ Objects .requireNonNull (locale , "locale should not be null" );
183185 LocaleProviderAdapter adapter ;
184186 adapter = LocaleProviderAdapter .getAdapter (DecimalFormatSymbolsProvider .class , locale );
185187 DecimalFormatSymbolsProvider provider = adapter .getDecimalFormatSymbolsProvider ();
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 1998, 2023 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1998, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
2424/*
2525 * @test
2626 * @summary test International Date Format Symbols
27+ * @bug 8366517
2728 * @run junit IntlTestDateFormatSymbols
2829 */
2930/*
4344
4445import org .junit .jupiter .api .Test ;
4546
47+ import static org .junit .jupiter .api .Assertions .assertThrows ;
4648import static org .junit .jupiter .api .Assertions .fail ;
4749
4850public class IntlTestDateFormatSymbols
@@ -205,4 +207,10 @@ public void TestSymbols()
205207 fail ("ERROR: Clone failed" );
206208 }
207209 }
210+
211+ @ Test
212+ void nullLocaleTest () {
213+ assertThrows (NullPointerException .class , () -> new DateFormatSymbols (null ));
214+ assertThrows (NullPointerException .class , () -> DateFormatSymbols .getInstance (null ));
215+ }
208216}
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 1998, 2023 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1998, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
2323
2424/*
2525 * @test
26- * @bug 8282625
26+ * @bug 8282625 8366517
2727 * @summary test International Decimal Format Symbols
2828 * @run junit IntlTestDecimalFormatSymbols
2929 */
4444
4545import org .junit .jupiter .api .Test ;
4646
47+ import static org .junit .jupiter .api .Assertions .assertThrows ;
4748import static org .junit .jupiter .api .Assertions .fail ;
4849
4950public class IntlTestDecimalFormatSymbols
@@ -146,4 +147,10 @@ public void TestSymbols()
146147 fail ("ERROR: Clone failed" );
147148 }
148149 }
150+
151+ @ Test
152+ void nullLocaleTest () {
153+ assertThrows (NullPointerException .class , () -> new DecimalFormatSymbols (null ));
154+ assertThrows (NullPointerException .class , () -> DecimalFormatSymbols .getInstance (null ));
155+ }
149156}
You can’t perform that action at this time.
0 commit comments