Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java
32284 views
/*1* Copyright (c) 2014, 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/* @test LimitSharedSizes24* @summary Test handling of limits on shared space size25* @library /testlibrary26* @run main LimitSharedSizes27*/2829import com.oracle.java.testlibrary.*;3031public class LimitSharedSizes {32private static class SharedSizeTestData {33public String optionName;34public String optionValue;35public String expectedErrorMsg;3637public SharedSizeTestData(String name, String value, String msg) {38optionName = name;39optionValue = value;40expectedErrorMsg = msg;41}42}4344private static final SharedSizeTestData[] testTable = {45// values in this part of the test table should cause failure46// (shared space sizes are deliberately too small)47new SharedSizeTestData("-XX:SharedReadOnlySize", "4M", "read only"),48new SharedSizeTestData("-XX:SharedReadWriteSize","4M", "read write"),4950// Known issue, JDK-8038422 (assert() on Windows)51// new SharedSizeTestData("-XX:SharedMiscDataSize", "500k", "miscellaneous data"),5253// Too small of a misc code size should not cause a vm crash.54// It should result in the following error message:55// The shared miscellaneous code space is not large enough56// to preload requested classes. Use -XX:SharedMiscCodeSize=57// to increase the initial size of shared miscellaneous code space.58new SharedSizeTestData("-XX:SharedMiscCodeSize", "20k", "miscellaneous code"),5960// these values are larger than default ones, but should61// be acceptable and not cause failure62new SharedSizeTestData("-XX:SharedReadOnlySize", "20M", null),63new SharedSizeTestData("-XX:SharedReadWriteSize", "20M", null),64new SharedSizeTestData("-XX:SharedMiscDataSize", "20M", null),65new SharedSizeTestData("-XX:SharedMiscCodeSize", "20M", null)66};6768public static void main(String[] args) throws Exception {69String fileName = "test.jsa";7071for (SharedSizeTestData td : testTable) {72String option = td.optionName + "=" + td.optionValue;73System.out.println("testing option <" + option + ">");7475ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(76"-XX:+UnlockDiagnosticVMOptions",77"-XX:SharedArchiveFile=./" + fileName,78option,79"-Xshare:dump");8081OutputAnalyzer output = new OutputAnalyzer(pb.start());8283if (td.expectedErrorMsg != null) {84output.shouldContain("The shared " + td.expectedErrorMsg85+ " space is not large enough");8687output.shouldHaveExitValue(2);88} else {89output.shouldNotContain("space is not large enough");90output.shouldHaveExitValue(0);91}92}93}94}959697