8260934: java/lang/StringBuilder/HugeCapacity.java fails without Compact Strings
Reviewed-by: iklam
This commit is contained in:
parent
752f92bc10
commit
ad54d8dd83
@ -27,14 +27,20 @@
|
|||||||
* @summary Capacity should not get close to Integer.MAX_VALUE unless
|
* @summary Capacity should not get close to Integer.MAX_VALUE unless
|
||||||
* necessary
|
* necessary
|
||||||
* @requires (sun.arch.data.model == "64" & os.maxMemory >= 6G)
|
* @requires (sun.arch.data.model == "64" & os.maxMemory >= 6G)
|
||||||
* @run main/othervm -Xms5G -Xmx5G HugeCapacity
|
* @run main/othervm -Xms5G -Xmx5G -XX:+CompactStrings HugeCapacity true
|
||||||
|
* @run main/othervm -Xms5G -Xmx5G -XX:-CompactStrings HugeCapacity false
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class HugeCapacity {
|
public class HugeCapacity {
|
||||||
private static int failures = 0;
|
private static int failures = 0;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
testLatin1();
|
if (args.length == 0) {
|
||||||
|
throw new IllegalArgumentException("Need the argument");
|
||||||
|
}
|
||||||
|
boolean isCompact = Boolean.parseBoolean(args[0]);
|
||||||
|
|
||||||
|
testLatin1(isCompact);
|
||||||
testUtf16();
|
testUtf16();
|
||||||
testHugeInitialString();
|
testHugeInitialString();
|
||||||
testHugeInitialCharSequence();
|
testHugeInitialCharSequence();
|
||||||
@ -43,11 +49,12 @@ public class HugeCapacity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void testLatin1() {
|
private static void testLatin1(boolean isCompact) {
|
||||||
try {
|
try {
|
||||||
|
int divisor = isCompact ? 2 : 4;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.ensureCapacity(Integer.MAX_VALUE / 2);
|
sb.ensureCapacity(Integer.MAX_VALUE / divisor);
|
||||||
sb.ensureCapacity(Integer.MAX_VALUE / 2 + 1);
|
sb.ensureCapacity(Integer.MAX_VALUE / divisor + 1);
|
||||||
} catch (OutOfMemoryError oom) {
|
} catch (OutOfMemoryError oom) {
|
||||||
oom.printStackTrace();
|
oom.printStackTrace();
|
||||||
failures++;
|
failures++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user