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 -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
if (failures > 0 ) {
40
46
throw new RuntimeException (failures + " tests failed" );
41
47
}
42
48
}
43
49
44
- private static void testLatin1 () {
50
+ private static void testLatin1 (boolean isCompact ) {
45
51
try {
52
+ int divisor = isCompact ? 2 : 4 ;
46
53
StringBuilder sb = new StringBuilder ();
47
- sb .ensureCapacity (Integer .MAX_VALUE / 2 );
48
- sb .ensureCapacity (Integer .MAX_VALUE / 2 + 1 );
54
+ sb .ensureCapacity (Integer .MAX_VALUE / divisor );
55
+ sb .ensureCapacity (Integer .MAX_VALUE / divisor + 1 );
49
56
} catch (OutOfMemoryError oom ) {
50
57
oom .printStackTrace ();
51
58
failures ++;
You can’t perform that action at this time.
0 commit comments