Re: [PR] Enable SurrogatePairLengthTest in a separate forked JVM [xerces-j]
elharo (via GitHub) <[email protected]> Fri, 17 Jul 2026 15:20:53 -0000
| Newsgroups | gmane.text.xml.xerces-j.devel |
|---|---|
| Message-ID | <PR_kwDOLzdO6M7zCP5r-5c5c8f54-5ee9-4517-aaf5-1d2f4157cc8e@gitbox.apache.org> |
elharo commented on PR #116:
URL: https://github.com/apache/xerces-j/pull/116#issuecomment-5004756319
An alternative approach that avoids the separate forked JVM: instead of reading the system property once in a `static final` field, change `TypeValidator.getDataLength()` to call `Boolean.getBoolean(...)` directly. The system property is the public API — no new setter needed. The performance impact of reading a system property on each string-length check is negligible for a rarely-used debug flag.
```java
// TypeValidator.java
public int getDataLength(Object value) {
if (value instanceof String) {
final String str = (String)value;
if (!isCodePointCountEnabled()) {
return str.length();
}
return getCodePointLength(str);
}
return -1;
}
private static boolean isCodePointCountEnabled() {
return AccessController.doPrivileged((PrivilegedAction<Boolean>) () ->
Boolean.getBoolean("org.apache.xerces.impl.dv.xs.useCodePointCountForStringLength")
);
}
```
Then `SurrogatePairLengthTest` would work in the shared JVM — just set the property via `System.setProperty()` and let it be read lazily.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]