Path: blob/master/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java
40943 views
/*1* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 802286526* @summary Tests for the -XX:CompressedClassSpaceSize command line option27* @requires vm.bits == 64 & vm.opt.final.UseCompressedOops == true28* @library /test/lib29* @modules java.base/jdk.internal.misc30* java.management31* @run driver CompressedClassSpaceSize32*/3334import jdk.test.lib.process.ProcessTools;35import jdk.test.lib.process.OutputAnalyzer;3637public class CompressedClassSpaceSize {3839public static void main(String[] args) throws Exception {40ProcessBuilder pb;41OutputAnalyzer output;42// Minimum size is 1MB43pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=0",44"-version");45output = new OutputAnalyzer(pb.start());46output.shouldContain("outside the allowed range")47.shouldHaveExitValue(1);4849// Invalid size of -1 should be handled correctly50pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=-1",51"-version");52output = new OutputAnalyzer(pb.start());53output.shouldContain("Improperly specified VM option 'CompressedClassSpaceSize=-1'")54.shouldHaveExitValue(1);555657// Maximum size is 3GB58pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=4g",59"-version");60output = new OutputAnalyzer(pb.start());61output.shouldContain("outside the allowed range")62.shouldHaveExitValue(1);636465// Make sure the minimum size is set correctly and printed66// (Note: ccs size shall be rounded up to the minimum size of 4m since metaspace reservations67// are done in a 4m granularity. Note that this is **reserved** size and does not affect rss.68pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",69"-XX:CompressedClassSpaceSize=1m",70"-Xlog:gc+metaspace=trace",71"-version");72output = new OutputAnalyzer(pb.start());73output.shouldMatch("Compressed class space.*4194304")74.shouldHaveExitValue(0);757677// Make sure the maximum size is set correctly and printed78pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",79"-XX:CompressedClassSpaceSize=3g",80"-Xlog:gc+metaspace=trace",81"-version");82output = new OutputAnalyzer(pb.start());83output.shouldMatch("Compressed class space.*3221225472")84.shouldHaveExitValue(0);858687pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedClassPointers",88"-XX:CompressedClassSpaceSize=1m",89"-version");90output = new OutputAnalyzer(pb.start());91output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")92.shouldHaveExitValue(0);93}94}959697