Skip to content

Commit 0015376

Browse files
Replace ICU4J UCharacter methods with standard Java Character class
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)
1 parent e6afc7d commit 0015376

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/nu/validator/htmlparser/extra/NormalizationChecker.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.xml.sax.SAXException;
3131
import org.xml.sax.SAXParseException;
3232

33-
import com.ibm.icu.lang.UCharacter;
3433
import com.ibm.icu.text.Normalizer;
3534
import com.ibm.icu.text.UnicodeSet;
3635

@@ -103,7 +102,7 @@ public void err(String message) throws SAXException {
103102
* or a surrogate and <code>false</code> otherwise
104103
*/
105104
private static boolean isComposingCharOrSurrogate(char c) {
106-
if (UCharacter.isHighSurrogate(c) || UCharacter.isLowSurrogate(c)) {
105+
if (Character.isHighSurrogate(c) || Character.isLowSurrogate(c)) {
107106
return true;
108107
}
109108
return isComposingChar(c);
@@ -153,18 +152,18 @@ public void characters(char[] ch, int start, int length)
153152
char c = ch[start];
154153
if (pos == 1) {
155154
// there's a single high surrogate in buf
156-
if (isComposingChar(UCharacter.getCodePoint(buf[0], c))) {
155+
if (isComposingChar(Character.toCodePoint(buf[0], c))) {
157156
err("Text run starts with a composing character.");
158157
}
159158
atStartOfRun = false;
160159
} else {
161-
if (length == 1 && UCharacter.isHighSurrogate(c)) {
160+
if (length == 1 && Character.isHighSurrogate(c)) {
162161
buf[0] = c;
163162
pos = 1;
164163
return;
165164
} else {
166-
if (UCharacter.isHighSurrogate(c)) {
167-
if (isComposingChar(UCharacter.getCodePoint(c,
165+
if (Character.isHighSurrogate(c)) {
166+
if (isComposingChar(Character.toCodePoint(c,
168167
ch[start + 1]))) {
169168
err("Text run starts with a composing character.");
170169
}

0 commit comments

Comments
 (0)