8367237: Thread-Safety Usage Warning for java.text.Collator Classes

Reviewed-by: iris, naoto
This commit is contained in:
Justin Lu 2025-09-15 21:10:26 +00:00
parent 729f4f9b16
commit 64155dfac0
2 changed files with 13 additions and 7 deletions

View File

@ -111,8 +111,13 @@ import sun.util.locale.provider.LocaleServiceProviderPool;
* <br>
* @apiNote {@code CollationKey}s from different
* {@code Collator}s can not be compared. See the class description
* for {@link CollationKey}
* for an example using {@code CollationKey}s.
* for {@link CollationKey} for an example using {@code CollationKey}s.
*
* @implNote Significant thread contention may occur during concurrent usage
* of the JDK Reference Implementation's {@link RuleBasedCollator}, which is the
* subtype returned by the default provider of the {@link #getInstance()} factory
* methods. As such, users should consider retrieving a separate instance for
* each thread when used in multithreaded environments.
*
* @see RuleBasedCollator
* @see CollationKey

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -38,10 +38,6 @@
package java.text;
import java.text.Normalizer;
import java.util.Vector;
import java.util.Locale;
/**
* The {@code RuleBasedCollator} class is a concrete subclass of
* {@code Collator} that provides a simple, data-driven, table
@ -239,6 +235,11 @@ import java.util.Locale;
* </pre>
* </blockquote>
*
* @implNote For this implementation, concurrent usage of this class may
* lead to significant thread contention since {@code synchronized} is employed
* to ensure thread-safety. As such, users of this class should consider creating
* a separate instance for each thread when used in multithreaded environments.
*
* @see Collator
* @see CollationElementIterator
* @author Helena Shih, Laura Werner, Richard Gillam