Skip to content

Replace ICU4J UCharacter methods with standard Java Character class#118

Merged
sideshowbarker merged 1 commit into
masterfrom
ICU4J-UCharacter-replace-with-standard-Java-Character
May 12, 2026
Merged

Replace ICU4J UCharacter methods with standard Java Character class#118
sideshowbarker merged 1 commit into
masterfrom
ICU4J-UCharacter-replace-with-standard-Java-Character

Conversation

@sideshowbarker
Copy link
Copy Markdown
Member

@sideshowbarker sideshowbarker commented May 12, 2026

ICU4J 75.1 removed the char-taking overloads of UCharacter methods:

  • isHighSurrogate(char) — removed (only isHighSurrogate(int) remains)
  • isLowSurrogate(char) — removed (only isLowSurrogate(int) remains)
  • getCodePoint(char, char) — removed (only getCodePoint(int, int) remains)

When code compiled against an older ICU4J (which had those methods) runs with ICU4J 75.1, it throws NoSuchMethodError — because the bytecode contains direct references to the removed method signatures.

Note: Code compiled against ICU4J 75.1 happens to work because Java’s implicit widening conversion (char → int) binds to the int versions at compile time. But that doesn’t help users of pre-compiled artifacts.

This change replaces all uses of those ICU4J methods with equivalent methods from Java’s standard Character class (available since Java 5):

  • UCharacter.isHighSurrogate(c) → Character.isHighSurrogate(c)
  • UCharacter.isLowSurrogate(c) → Character.isLowSurrogate(c)
  • UCharacter.getCodePoint(c1, c2) → Character.toCodePoint(c1, c2)

@sideshowbarker sideshowbarker requested a review from hsivonen May 12, 2026 08:07
ICU4J 75.1 removed the char-taking overloads of UCharacter methods:

- isHighSurrogate(char)    — removed (only isHighSurrogate(int) remains)
- isLowSurrogate(char)     — removed (only isLowSurrogate(int) remains)
- getCodePoint(char, char) — removed (only getCodePoint(int, int) remains)

When code compiled against an older ICU4J (which had those methods) runs
with ICU4J 75.1, it throws NoSuchMethodError — because the bytecode
contains direct references to the removed method signatures.

Note: Code compiled against ICU4J 75.1 happens to work because Java’s
implicit widening conversion (char → int) binds to the int versions
at compile time. But that doesn’t help users of pre-compiled artifacts.

This change replaces all uses of those ICU4J methods with equivalent
methods from Java’s standard Character class (available since Java 5):

- UCharacter.isHighSurrogate(c)   → Character.isHighSurrogate(c)
- UCharacter.isLowSurrogate(c)    → Character.isLowSurrogate(c)
- UCharacter.getCodePoint(c1, c2) → Character.toCodePoint(c1, c2)
@sideshowbarker sideshowbarker force-pushed the ICU4J-UCharacter-replace-with-standard-Java-Character branch from 919b5fb to 6699f5c Compare May 12, 2026 08:10
Copy link
Copy Markdown
Member

@hsivonen hsivonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@sideshowbarker sideshowbarker merged commit 0015376 into master May 12, 2026
12 checks passed
@sideshowbarker sideshowbarker deleted the ICU4J-UCharacter-replace-with-standard-Java-Character branch May 12, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants