mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8349493: Replace sun.util.locale.ParseStatus usage with java.text.ParsePosition
Reviewed-by: naoto
This commit is contained in:
parent
7cd5cb2916
commit
fb847bb2af
3 changed files with 59 additions and 125 deletions
|
@ -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
|
||||
|
@ -47,6 +47,7 @@ import java.io.ObjectStreamField;
|
|||
import java.io.Serializable;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.spi.LocaleNameProvider;
|
||||
|
@ -63,7 +64,6 @@ import sun.util.locale.LocaleExtensions;
|
|||
import sun.util.locale.LocaleMatcher;
|
||||
import sun.util.locale.LocaleSyntaxException;
|
||||
import sun.util.locale.LocaleUtils;
|
||||
import sun.util.locale.ParseStatus;
|
||||
import sun.util.locale.provider.LocaleProviderAdapter;
|
||||
import sun.util.locale.provider.LocaleResources;
|
||||
import sun.util.locale.provider.LocaleServiceProviderPool;
|
||||
|
@ -1919,7 +1919,8 @@ public final class Locale implements Cloneable, Serializable {
|
|||
* @since 1.7
|
||||
*/
|
||||
public static Locale forLanguageTag(String languageTag) {
|
||||
LanguageTag tag = LanguageTag.parse(languageTag, null);
|
||||
LanguageTag tag = LanguageTag.parse(
|
||||
languageTag, new ParsePosition(0), true);
|
||||
InternalLocaleBuilder bldr = new InternalLocaleBuilder();
|
||||
bldr.setLanguageTag(tag);
|
||||
BaseLocale base = bldr.getBaseLocale();
|
||||
|
@ -2789,11 +2790,8 @@ public final class Locale implements Cloneable, Serializable {
|
|||
* @see Locale#forLanguageTag(String)
|
||||
*/
|
||||
public Builder setLanguageTag(String languageTag) {
|
||||
ParseStatus sts = new ParseStatus();
|
||||
LanguageTag tag = LanguageTag.parse(languageTag, sts);
|
||||
if (sts.isError()) {
|
||||
throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
|
||||
}
|
||||
LanguageTag tag = LanguageTag.parse(
|
||||
languageTag, new ParsePosition(0), false);
|
||||
localeBuilder.setLanguageTag(tag);
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue