RFR: 8260934: java/lang/StringBuilder/HugeCapacity.java fails without Compact Strings

Aleksey Shipilev shade at openjdk.java.net
Tue Feb 2 15:42:52 UTC 2021


$ CONF=linux-x86_64-server-fastdebug make run-test TEST=java/lang/StringBuilder/HugeCapacity.java TEST_VM_OPTS=-XX:-CompactStrings

STDERR:
java.lang.OutOfMemoryError: Required length exceeds implementation limit
at java.base/java.lang.AbstractStringBuilder.newCapacity(AbstractStringBuilder.java:259)
at java.base/java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:229)
at java.base/java.lang.AbstractStringBuilder.ensureCapacity(AbstractStringBuilder.java:213)
at java.base/java.lang.StringBuilder.ensureCapacity(StringBuilder.java:87)
at HugeCapacity.testLatin1(HugeCapacity.java:49)
at HugeCapacity.main(HugeCapacity.java:37)

I went back and forth in fixing this test, and I think the best we can do is sense the current setting on `CompactStrings` and choose the test configuration based on that. The alternative is to use `WhiteBox` within the test (tried, it is quite a bit ugly). Note that this test deliberately does not run `-XX:-CompactStrings` even when `vm.opt.final.CompactStrings` returns true (= "available"), because that might mean `TEST_VM_OPTS=-XX:+CompactStrings` is in effect, and we have the VM option conflict.

Additional testing:
 - [x] Linux x86_64, affected test (default), passes
 - [x] Linux x86_64, affected test (`-XX:-CompactStrings`), passes
 - [x] Linux x86_64, affected test (`-XX:+CompactStrings`), passes

-------------

Commit messages:
 - 8260934: java/lang/StringBuilder/HugeCapacity.java fails without Compact Strings

Changes: https://git.openjdk.java.net/jdk/pull/2355/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2355&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8260934
  Stats: 26 lines in 2 files changed: 20 ins; 0 del; 6 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2355.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2355/head:pull/2355

PR: https://git.openjdk.java.net/jdk/pull/2355


More information about the core-libs-dev mailing list