Commit ad54d8d 1 parent 752f92b commit ad54d8d Copy full SHA for ad54d8d
File tree 1 file changed +12
-5
lines changed
test/jdk/java/lang/StringBuilder
1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 27
27
* @summary Capacity should not get close to Integer.MAX_VALUE unless
28
28
* necessary
29
29
* @requires (sun.arch.data.model == "64" & os.maxMemory >= 6G)
30
- * @run main/othervm -Xms5G -Xmx5G HugeCapacity
30
+ * @run main/othervm -Xms5G -Xmx5G -XX:+CompactStrings HugeCapacity true
31
+ * @run main/othervm -Xms5G -Xmx5G -XX:-CompactStrings HugeCapacity false
31
32
*/
32
33
33
34
public class HugeCapacity {
34
35
private static int failures = 0 ;
35
36
36
37
public static void main (String [] args ) {
37
- testLatin1 ();
38
+ if (args .length == 0 ) {
39
+ throw new IllegalArgumentException ("Need the argument" );
40
+ }
41
+ boolean isCompact = Boolean .parseBoolean (args [0 ]);
42
+
43
+ testLatin1 (isCompact );
38
44
testUtf16 ();
39
45
testHugeInitialString ();
40
46
testHugeInitialCharSequence ();
@@ -43,11 +49,12 @@ public static void main(String[] args) {
43
49
}
44
50
}
45
51
46
- private static void testLatin1 () {
52
+ private static void testLatin1 (boolean isCompact ) {
47
53
try {
54
+ int divisor = isCompact ? 2 : 4 ;
48
55
StringBuilder sb = new StringBuilder ();
49
- sb .ensureCapacity (Integer .MAX_VALUE / 2 );
50
- sb .ensureCapacity (Integer .MAX_VALUE / 2 + 1 );
56
+ sb .ensureCapacity (Integer .MAX_VALUE / divisor );
57
+ sb .ensureCapacity (Integer .MAX_VALUE / divisor + 1 );
51
58
} catch (OutOfMemoryError oom ) {
52
59
oom .printStackTrace ();
53
60
failures ++;
You can’t perform that action at this time.
0 commit comments