Skip to content

Commit e5828fa

Browse files
eregonansalond
authored andcommitted
Avoid using ICU4J at image build time since it is configured to be initialized at run time
1 parent f9851f1 commit e5828fa

File tree

1 file changed

+19
-4
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str

1 file changed

+19
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringUtils.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,21 +320,36 @@ static boolean doString(TruffleString str,
320320
}
321321
TruffleStringIterator it = createCodePointIteratorNode.execute(str, TS_ENCODING);
322322
int c = nextNode.execute(it);
323-
if (c != '_' && !hasProperty(c, UProperty.XID_START)) {
323+
if (c != '_' && !isIdentifierStart(c)) {
324324
return false;
325325
}
326326
while (it.hasNext()) {
327327
c = nextNode.execute(it);
328-
if (!hasProperty(c, UProperty.XID_CONTINUE)) {
328+
if (!isIdentifierPart(c)) {
329329
return false;
330330
}
331331
}
332332
return true;
333333
}
334334

335335
@TruffleBoundary
336-
static boolean hasProperty(int codePoint, int property) {
337-
return UCharacter.hasBinaryProperty(codePoint, property);
336+
static boolean isIdentifierStart(int codePoint) {
337+
if (ImageInfo.inImageBuildtimeCode()) {
338+
// Avoid initializing ICU4J at image build time
339+
return Character.isUnicodeIdentifierStart(codePoint);
340+
} else {
341+
return UCharacter.hasBinaryProperty(codePoint, UProperty.XID_START);
342+
}
343+
}
344+
345+
@TruffleBoundary
346+
static boolean isIdentifierPart(int codePoint) {
347+
if (ImageInfo.inImageBuildtimeCode()) {
348+
// Avoid initializing ICU4J at image build time
349+
return Character.isUnicodeIdentifierPart(codePoint);
350+
} else {
351+
return UCharacter.hasBinaryProperty(codePoint, UProperty.XID_CONTINUE);
352+
}
338353
}
339354
}
340355

0 commit comments

Comments
 (0)