Mihai Nita created PHOENIX-7579:
-----------------------------------

             Summary: ICU4J Will drop icu4j-localespi in next release
                 Key: PHOENIX-7579
                 URL: https://issues.apache.org/jira/browse/PHOENIX-7579
             Project: Phoenix
          Issue Type: Task
          Components: core
            Reporter: Mihai Nita


_"WARNING: Please note that for ICU 78 (2025-oct) we are planning to remove the 
ICU4J Locale Service Provider. See the ICU 77 page for details."_

[https://unicode-org.github.io/icu/userguide/icu4j/locale-service-provider.html]

---

I am part of the ICU team, and this is a "courtesy ticket" :)

 

It looks like the only thing used from {{icu4j-localespi}} is the 
{{com.ibm.icu.impl.jdkadapter.CollatorICU}} class, not the Locale Service 
Provider mechanism.
See 
[https://github.com/apache/phoenix/blob/master/phoenix-core-client/src/main/java/org/apache/phoenix/util/i18n/LinguisticSort.java#L522]

 

The easiest fix is to make the collator a {{Comparator<Object>}} which both the 
ICU4J and the JDK {{{}Collator{}}}(s) implement.

And change the initialization to something like this:

 
{code:java}
// Line 416
private final Comparator<Object> collator;

// ...
// ...
// Line 520
if (LinguisticSort.Icu4jCollatorOverrides.OVERRIDES.containsKey(this.locale)) {
  // Force ICU4J collators for specific locales so they match Oracle sort
  com.ibm.icu.text.Collator icuCollator =
      com.ibm.icu.text.Collator.getInstance(
          LinguisticSort
              .Icu4jCollatorOverrides.OVERRIDES.get(this.locale));
  icuCollator.setStrength(com.ibm.icu.text.Collator.SECONDARY);
  this.collator = icuCollator;
} else if (this.locale.getVariant().length() > 0) {
  // If there's a variant, use ICU4J to figure it out.
  com.ibm.icu.text.Collator icuCollator =
      com.ibm.icu.text.Collator.getInstance(
          ULocale.forLocale(this.locale)));
  icuCollator.setStrength(com.ibm.icu.text.Collator.SECONDARY);
  this.collator = icuCollator;
} else {
  Collator jdkCollator = Collator.getInstance(this.locale);
  jdkCollator.setStrength(Collator.SECONDARY);
  this.collator = jdkCollator;
}{code}
 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to