21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8022865
27 * @summary Tests for the -XX:CompressedClassSpaceSize command line option
28 * @requires vm.bits == 64 & vm.opt.final.UseCompressedOops == true
29 * @requires vm.flagless
30 * @library /test/lib
31 * @modules java.base/jdk.internal.misc
32 * java.management
33 * @run driver CompressedClassSpaceSize
34 */
35
36 import jdk.test.lib.process.ProcessTools;
37 import jdk.test.lib.process.OutputAnalyzer;
38
39 public class CompressedClassSpaceSize {
40
41 public static void main(String[] args) throws Exception {
42 ProcessBuilder pb;
43 OutputAnalyzer output;
44 // Minimum size is 1MB
45 pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=0",
46 "-version");
47 output = new OutputAnalyzer(pb.start());
48 output.shouldContain("outside the allowed range")
49 .shouldHaveExitValue(1);
50
51 // Invalid size of -1 should be handled correctly
52 pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=-1",
53 "-version");
54 output = new OutputAnalyzer(pb.start());
55 output.shouldContain("Improperly specified VM option 'CompressedClassSpaceSize=-1'")
56 .shouldHaveExitValue(1);
57
58
59 // Maximum size is 3GB
60 pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=4g",
61 "-version");
62 output = new OutputAnalyzer(pb.start());
63 output.shouldContain("outside the allowed range")
64 .shouldHaveExitValue(1);
65
66
67 // Make sure the minimum size is set correctly and printed
68 // (Note: ccs size shall be rounded up to the minimum size of 4m since metaspace reservations
69 // are done in a 4m granularity. Note that this is **reserved** size and does not affect rss.
70 pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
71 "-XX:CompressedClassSpaceSize=1m",
72 "-Xlog:gc+metaspace=trace",
73 "-version");
74 output = new OutputAnalyzer(pb.start());
75 output.shouldMatch("Compressed class space.*4194304")
76 .shouldHaveExitValue(0);
77
78
79 // Make sure the maximum size is set correctly and printed
80 pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
81 "-XX:CompressedClassSpaceSize=3g",
82 "-Xlog:gc+metaspace=trace",
83 "-version");
84 output = new OutputAnalyzer(pb.start());
85 output.shouldMatch("Compressed class space.*3221225472")
86 .shouldHaveExitValue(0);
87
88
89 pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedClassPointers",
90 "-XX:CompressedClassSpaceSize=1m",
91 "-version");
92 output = new OutputAnalyzer(pb.start());
93 output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")
94 .shouldHaveExitValue(0);
95 }
96 }
|
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8022865
27 * @summary Tests for the -XX:CompressedClassSpaceSize command line option
28 * @requires vm.bits == 64 & vm.opt.final.UseCompressedOops == true
29 * @requires vm.flagless
30 * @library /test/lib
31 * @modules java.base/jdk.internal.misc
32 * java.management
33 * @run driver CompressedClassSpaceSize
34 */
35
36 import jdk.test.lib.process.ProcessTools;
37 import jdk.test.lib.process.OutputAnalyzer;
38
39 public class CompressedClassSpaceSize {
40
41 // Sizes beyond this will be rejected by hotspot arg parsing
42 // (Lilliput: see Metaspace::max_class_space_size() for details)
43 static final long max_class_space_size = 2013265920;
44
45 // Below this size class space will be silently enlarged to a multiple of this size
46 static final long min_class_space_size = 4194304;
47
48 public static void main(String[] args) throws Exception {
49 ProcessBuilder pb;
50 OutputAnalyzer output;
51
52 // Invalid size of -1 should be handled correctly
53 pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=-1",
54 "-version");
55 output = new OutputAnalyzer(pb.start());
56 output.shouldContain("Improperly specified VM option 'CompressedClassSpaceSize=-1'")
57 .shouldHaveExitValue(1);
58
59 ///////////
60
61 // Going below the minimum size for class space (one root chunk size = atm 4M) should be transparently
62 // handled by the hotspot, which should round up class space size and not report an error.
63 pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=1m",
64 "-Xlog:gc+metaspace=trace",
65 "-version");
66 output = new OutputAnalyzer(pb.start());
67 output.shouldMatch("Compressed class space.*" + min_class_space_size)
68 .shouldHaveExitValue(0);
69
70 ///////////
71
72 // Try 0. Same result expected.
73 pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=0",
74 "-Xlog:gc+metaspace=trace",
75 "-version");
76 output = new OutputAnalyzer(pb.start());
77 output.shouldMatch("Compressed class space.*" + min_class_space_size)
78 .shouldHaveExitValue(0);
79
80 ///////////
81
82 // Try max allowed size, which should be accepted
83 pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
84 "-XX:CompressedClassSpaceSize=" + max_class_space_size,
85 "-Xlog:gc+metaspace=trace",
86 "-version");
87 output = new OutputAnalyzer(pb.start());
88 output.shouldMatch("Compressed class space.*" + max_class_space_size)
89 .shouldHaveExitValue(0);
90
91 ///////////
92
93 // Set max allowed size + 1, which should graciously fail
94 pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
95 "-XX:CompressedClassSpaceSize=" + (max_class_space_size + 1),
96 "-Xlog:gc+metaspace=trace",
97 "-version");
98 output = new OutputAnalyzer(pb.start());
99 output.shouldContain("CompressedClassSpaceSize " + (max_class_space_size + 1) + " too large (max: " + max_class_space_size)
100 .shouldHaveExitValue(1);
101
102 }
103 }
|