< prev index next > test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java
Print this page
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
public class CompressedClassSpaceSize {
public static void main(String[] args) throws Exception {
ProcessBuilder pb;
OutputAnalyzer output;
- // Minimum size is 1MB
- pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=0",
- "-version");
- output = new OutputAnalyzer(pb.start());
- output.shouldContain("outside the allowed range")
- .shouldHaveExitValue(1);
// Invalid size of -1 should be handled correctly
pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=-1",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Improperly specified VM option 'CompressedClassSpaceSize=-1'")
.shouldHaveExitValue(1);
! // Maximum size is 3GB
! pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=4g",
"-version");
output = new OutputAnalyzer(pb.start());
! output.shouldContain("outside the allowed range")
! .shouldHaveExitValue(1);
! // Make sure the minimum size is set correctly and printed
! // (Note: ccs size shall be rounded up to the minimum size of 4m since metaspace reservations
! // are done in a 4m granularity. Note that this is **reserved** size and does not affect rss.
! pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
- "-XX:CompressedClassSpaceSize=1m",
- "-Xlog:gc+metaspace=trace",
- "-version");
output = new OutputAnalyzer(pb.start());
! output.shouldMatch("Compressed class space.*4194304")
! .shouldHaveExitValue(0);
! // Make sure the maximum size is set correctly and printed
pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
! "-XX:CompressedClassSpaceSize=3g",
"-Xlog:gc+metaspace=trace",
"-version");
output = new OutputAnalyzer(pb.start());
! output.shouldMatch("Compressed class space.*3221225472")
.shouldHaveExitValue(0);
! pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedClassPointers",
! "-XX:CompressedClassSpaceSize=1m",
! "-version");
output = new OutputAnalyzer(pb.start());
! output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")
! .shouldHaveExitValue(0);
}
}
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
public class CompressedClassSpaceSize {
+ // Sizes beyond this will be rejected by hotspot arg parsing
+ // (Lilliput: see Metaspace::max_class_space_size() for details)
+ static final long max_class_space_size = 2013265920;
+
+ // Below this size class space will be silently enlarged to a multiple of this size
+ static final long min_class_space_size = 4194304;
+
public static void main(String[] args) throws Exception {
ProcessBuilder pb;
OutputAnalyzer output;
// Invalid size of -1 should be handled correctly
pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=-1",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Improperly specified VM option 'CompressedClassSpaceSize=-1'")
.shouldHaveExitValue(1);
+ ///////////
! // Going below the minimum size for class space (one root chunk size = atm 4M) should be transparently
! // handled by the hotspot, which should round up class space size and not report an error.
+ pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=1m",
+ "-Xlog:gc+metaspace=trace",
"-version");
output = new OutputAnalyzer(pb.start());
! output.shouldMatch("Compressed class space.*" + min_class_space_size)
! .shouldHaveExitValue(0);
+ ///////////
! // Try 0. Same result expected.
! pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=0",
! "-Xlog:gc+metaspace=trace",
! "-version");
output = new OutputAnalyzer(pb.start());
! output.shouldMatch("Compressed class space.*" + min_class_space_size)
! .shouldHaveExitValue(0);
+ ///////////
! // Try max allowed size, which should be accepted
pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
! "-XX:CompressedClassSpaceSize=" + max_class_space_size,
"-Xlog:gc+metaspace=trace",
"-version");
output = new OutputAnalyzer(pb.start());
! output.shouldMatch("Compressed class space.*" + max_class_space_size)
.shouldHaveExitValue(0);
+ ///////////
! // Set max allowed size + 1, which should graciously fail
! pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
! "-XX:CompressedClassSpaceSize=" + (max_class_space_size + 1),
+ "-Xlog:gc+metaspace=trace",
+ "-version");
output = new OutputAnalyzer(pb.start());
! output.shouldContain("CompressedClassSpaceSize " + (max_class_space_size + 1) + " too large (max: " + max_class_space_size)
! .shouldHaveExitValue(1);
+
}
}
< prev index next >