1 /* 2 * Copyright (c) 2020, Red Hat, Inc. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 /* 26 * @test TestSoftMaxHeapSize 27 * @summary Test that Shenandoah checks SoftMaxHeapSize 28 * @library /testlibrary 29 * @modules java.base/jdk.internal.misc 30 * java.management 31 * @run driver TestSoftMaxHeapSize 32 */ 33 34 import com.oracle.java.testlibrary.*; 35 36 public class TestSoftMaxHeapSize { 37 public static void main(String[] args) throws Exception { 38 { 39 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", 40 "-XX:+UseShenandoahGC", 41 "-Xms4m", 42 "-Xmx128m", 43 "-XX:ShenandoahSoftMaxHeapSize=4m", 44 "-version"); 45 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 46 output.shouldHaveExitValue(0); 47 } 48 49 { 50 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", 51 "-XX:+UseShenandoahGC", 52 "-Xms4m", 53 "-Xmx128m", 54 "-XX:ShenandoahSoftMaxHeapSize=128m", 55 "-version"); 56 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 57 output.shouldHaveExitValue(0); 58 } 59 60 { 61 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", 62 "-XX:+UseShenandoahGC", 63 "-Xms4m", 64 "-Xmx128m", 65 "-XX:ShenandoahSoftMaxHeapSize=129m", 66 "-version"); 67 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 68 output.shouldHaveExitValue(1); 69 output.shouldContain("SoftMaxHeapSize must be less than or equal to the maximum heap size"); 70 } 71 } 72 }