From 6699f5c946ce8abc8e8f93863008438fe48839c2 Mon Sep 17 00:00:00 2001 From: sideshowbarker Date: Tue, 12 May 2026 17:01:25 +0900 Subject: [PATCH] Replace ICU4J UCharacter methods with standard Java Character class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../htmlparser/extra/NormalizationChecker.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/nu/validator/htmlparser/extra/NormalizationChecker.java b/src/nu/validator/htmlparser/extra/NormalizationChecker.java index 45df62fb..9a9fb647 100644 --- a/src/nu/validator/htmlparser/extra/NormalizationChecker.java +++ b/src/nu/validator/htmlparser/extra/NormalizationChecker.java @@ -30,7 +30,6 @@ import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; -import com.ibm.icu.lang.UCharacter; import com.ibm.icu.text.Normalizer; import com.ibm.icu.text.UnicodeSet; @@ -103,7 +102,7 @@ public void err(String message) throws SAXException { * or a surrogate and false otherwise */ private static boolean isComposingCharOrSurrogate(char c) { - if (UCharacter.isHighSurrogate(c) || UCharacter.isLowSurrogate(c)) { + if (Character.isHighSurrogate(c) || Character.isLowSurrogate(c)) { return true; } return isComposingChar(c); @@ -153,18 +152,18 @@ public void characters(char[] ch, int start, int length) char c = ch[start]; if (pos == 1) { // there's a single high surrogate in buf - if (isComposingChar(UCharacter.getCodePoint(buf[0], c))) { + if (isComposingChar(Character.toCodePoint(buf[0], c))) { err("Text run starts with a composing character."); } atStartOfRun = false; } else { - if (length == 1 && UCharacter.isHighSurrogate(c)) { + if (length == 1 && Character.isHighSurrogate(c)) { buf[0] = c; pos = 1; return; } else { - if (UCharacter.isHighSurrogate(c)) { - if (isComposingChar(UCharacter.getCodePoint(c, + if (Character.isHighSurrogate(c)) { + if (isComposingChar(Character.toCodePoint(c, ch[start + 1]))) { err("Text run starts with a composing character."); }