57 /*
58 * @test id=valid_large_cds
59 * @bug 8022865
60 * @summary Tests for the -XX:CompressedClassSpaceSize command line option
61 * @requires vm.bits == 64 & vm.opt.final.UseCompressedOops == true & vm.cds
62 * @requires vm.flagless
63 * @library /test/lib
64 * @modules java.base/jdk.internal.misc java.management
65 * @run driver CompressedClassSpaceSize valid_large_cds
66 */
67
68 import jdk.test.lib.process.ProcessTools;
69 import jdk.test.lib.process.OutputAnalyzer;
70
71 public class CompressedClassSpaceSize {
72
73 final static long MB = 1024 * 1024;
74
75 final static long minAllowedClassSpaceSize = MB;
76 final static long minRealClassSpaceSize = 16 * MB;
77 final static long maxClassSpaceSize = 4096 * MB;
78
79 // For the valid_large_cds sub test: we need to have a notion of what archive size to
80 // maximally expect, with a generous fudge factor to avoid having to tweak this test
81 // ofent. Note: today's default archives are around 16-20 MB.
82 final static long maxExpectedArchiveSize = 512 * MB;
83
84 public static void main(String[] args) throws Exception {
85 ProcessBuilder pb;
86 OutputAnalyzer output;
87
88 switch (args[0]) {
89 case "invalid": {
90 // < Minimum size
91 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=0",
92 "-version");
93 output = new OutputAnalyzer(pb.start());
94 output.shouldContain("outside the allowed range")
95 .shouldHaveExitValue(1);
96
97 // Invalid size of -1 should be handled correctly
122 // Note that this is **reserved** size and does not affect rss.
123 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
124 "-XX:CompressedClassSpaceSize=" + minAllowedClassSpaceSize,
125 "-Xlog:gc+metaspace",
126 "-version");
127 output = new OutputAnalyzer(pb.start());
128 output.shouldMatch("Compressed class space.*" + minRealClassSpaceSize)
129 .shouldHaveExitValue(0);
130 }
131 break;
132 case "valid_large_nocds": {
133 // Without CDS, we should get 4G
134 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=" + maxClassSpaceSize,
135 "-Xshare:off", "-Xlog:metaspace*", "-version");
136 output = new OutputAnalyzer(pb.start());
137 output.shouldMatch("Compressed class space.*" + maxClassSpaceSize)
138 .shouldHaveExitValue(0);
139 }
140 break;
141 case "valid_large_cds": {
142 // Create archive
143 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
144 "-XX:SharedArchiveFile=./abc.jsa", "-Xshare:dump", "-version");
145 output = new OutputAnalyzer(pb.start());
146 output.shouldHaveExitValue(0);
147
148 // With CDS, class space should fill whatever the CDS archive leaves us (modulo alignment)
149 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=" + maxClassSpaceSize,
150 "-XX:SharedArchiveFile=./abc.jsa", "-Xshare:on", "-Xlog:metaspace*", "-version");
151 output = new OutputAnalyzer(pb.start());
152 output.shouldHaveExitValue(0);
153 long reducedSize = Long.parseLong(
154 output.firstMatch("reducing class space size from " + maxClassSpaceSize + " to (\\d+)", 1));
155 if (reducedSize < (maxClassSpaceSize - maxExpectedArchiveSize)) {
156 output.reportDiagnosticSummary();
157 throw new RuntimeException("Class space size too small?");
158 }
159 output.shouldMatch("Compressed class space.*" + reducedSize);
160 }
161 break;
162 default:
163 throw new RuntimeException("invalid sub test " + args[0]);
164 }
165 }
166 }
|
57 /*
58 * @test id=valid_large_cds
59 * @bug 8022865
60 * @summary Tests for the -XX:CompressedClassSpaceSize command line option
61 * @requires vm.bits == 64 & vm.opt.final.UseCompressedOops == true & vm.cds
62 * @requires vm.flagless
63 * @library /test/lib
64 * @modules java.base/jdk.internal.misc java.management
65 * @run driver CompressedClassSpaceSize valid_large_cds
66 */
67
68 import jdk.test.lib.process.ProcessTools;
69 import jdk.test.lib.process.OutputAnalyzer;
70
71 public class CompressedClassSpaceSize {
72
73 final static long MB = 1024 * 1024;
74
75 final static long minAllowedClassSpaceSize = MB;
76 final static long minRealClassSpaceSize = 16 * MB;
77 final static long maxClassSpaceSize = 512 * MB;
78
79 // For the valid_large_cds sub test: we need to have a notion of what archive size to
80 // maximally expect, with a generous fudge factor to avoid having to tweak this test
81 // ofent. Note: today's default archives are around 16-20 MB.
82 final static long maxExpectedArchiveSize = 512 * MB;
83
84 public static void main(String[] args) throws Exception {
85 ProcessBuilder pb;
86 OutputAnalyzer output;
87
88 switch (args[0]) {
89 case "invalid": {
90 // < Minimum size
91 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=0",
92 "-version");
93 output = new OutputAnalyzer(pb.start());
94 output.shouldContain("outside the allowed range")
95 .shouldHaveExitValue(1);
96
97 // Invalid size of -1 should be handled correctly
122 // Note that this is **reserved** size and does not affect rss.
123 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
124 "-XX:CompressedClassSpaceSize=" + minAllowedClassSpaceSize,
125 "-Xlog:gc+metaspace",
126 "-version");
127 output = new OutputAnalyzer(pb.start());
128 output.shouldMatch("Compressed class space.*" + minRealClassSpaceSize)
129 .shouldHaveExitValue(0);
130 }
131 break;
132 case "valid_large_nocds": {
133 // Without CDS, we should get 4G
134 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=" + maxClassSpaceSize,
135 "-Xshare:off", "-Xlog:metaspace*", "-version");
136 output = new OutputAnalyzer(pb.start());
137 output.shouldMatch("Compressed class space.*" + maxClassSpaceSize)
138 .shouldHaveExitValue(0);
139 }
140 break;
141 case "valid_large_cds": {
142 // TODO: Does not currently work with +UseCompactObjectHeaders.
143 // // Create archive
144 // pb = ProcessTools.createLimitedTestJavaProcessBuilder(
145 // "-XX:SharedArchiveFile=./abc.jsa", "-Xshare:dump", "-version");
146 // output = new OutputAnalyzer(pb.start());
147 // output.shouldHaveExitValue(0);
148
149 // // With CDS, class space should fill whatever the CDS archive leaves us (modulo alignment)
150 // pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=" + maxClassSpaceSize,
151 // "-XX:SharedArchiveFile=./abc.jsa", "-Xshare:on", "-Xlog:metaspace*", "-version");
152 // output = new OutputAnalyzer(pb.start());
153 // output.shouldHaveExitValue(0);
154 // long reducedSize = Long.parseLong(
155 // output.firstMatch("reducing class space size from " + maxClassSpaceSize + " to (\\d+)", 1));
156 // if (reducedSize < (maxClassSpaceSize - maxExpectedArchiveSize)) {
157 // output.reportDiagnosticSummary();
158 // throw new RuntimeException("Class space size too small?");
159 // }
160 // output.shouldMatch("Compressed class space.*" + reducedSize);
161 }
162 break;
163 default:
164 throw new RuntimeException("invalid sub test " + args[0]);
165 }
166 }
167 }
|