Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/arguments/TestSurvivorAlignmentInBytesOption.java
32285 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*/2223import com.oracle.java.testlibrary.ExitCode;24import com.oracle.java.testlibrary.cli.CommandLineOptionTest;2526/**27* @test28* @bug 803132329* @summary Verify SurvivorAlignmentInBytes option processing.30* @library /testlibrary31* @requires vm.opt.SurvivorAlignmentInBytes == null32* & vm.opt.ObjectAlignmentInBytes == null33* & vm.opt.UnlockExperimentalVMOptions == null34* & (vm.opt.IgnoreUnrecognizedVMOptions == null35* | vm.opt.IgnoreUnrecognizedVMOptions == "false")36* @run main TestSurvivorAlignmentInBytesOption37*/38public class TestSurvivorAlignmentInBytesOption {39public static void main(String args[]) throws Throwable {40String optionName = "SurvivorAlignmentInBytes";41String unlockExperimentalVMOpts = "UnlockExperimentalVMOptions";42String optionIsExperimental43= CommandLineOptionTest.getExperimentalOptionErrorMessage(44optionName);45String valueIsTooSmall= ".*SurvivorAlignmentInBytes=.*must be greater"46+ " than ObjectAlignmentInBytes.*";47String mustBePowerOf2 = ".*SurvivorAlignmentInBytes=.*must be "48+ "power of 2.*";4950// Verify that without -XX:+UnlockExperimentalVMOptions usage of51// SurvivorAlignmentInBytes option will cause JVM startup failure52// with the warning message saying that that option is experimental.53CommandLineOptionTest.verifyJVMStartup(54new String[]{optionIsExperimental}, null, ExitCode.FAIL, false,55"-XX:-UnlockExperimentalVMOptions",56CommandLineOptionTest.prepareBooleanFlag(57unlockExperimentalVMOpts, false),58CommandLineOptionTest.prepareNumericFlag(optionName, 64));5960// Verify that with -XX:+UnlockExperimentalVMOptions passed to JVM61// usage of SurvivorAlignmentInBytes option won't cause JVM startup62// failure.63CommandLineOptionTest.verifyJVMStartup(64null, new String[]{optionIsExperimental}, ExitCode.OK, false,65CommandLineOptionTest.prepareBooleanFlag(66unlockExperimentalVMOpts, true),67CommandLineOptionTest.prepareNumericFlag(optionName, 64));6869// Verify that if specified SurvivorAlignmentInBytes is lower then70// ObjectAlignmentInBytes, then the JVM startup will fail with71// appropriate error message.72CommandLineOptionTest.verifyJVMStartup(73new String[]{valueIsTooSmall}, null, ExitCode.FAIL, false,74CommandLineOptionTest.prepareBooleanFlag(75unlockExperimentalVMOpts, true),76CommandLineOptionTest.prepareNumericFlag(optionName, 2));7778// Verify that if specified SurvivorAlignmentInBytes value is not79// a power of 2 then the JVM startup will fail with appropriate error80// message.81CommandLineOptionTest.verifyJVMStartup(82new String[]{mustBePowerOf2}, null, ExitCode.FAIL, false,83CommandLineOptionTest.prepareBooleanFlag(84unlockExperimentalVMOpts, true),85CommandLineOptionTest.prepareNumericFlag(optionName, 127));8687// Verify that if SurvivorAlignmentInBytes has correct value, then88// the JVM will be started without errors.89CommandLineOptionTest.verifyJVMStartup(90null, new String[]{".*SurvivorAlignmentInBytes.*"},91ExitCode.OK, false,92CommandLineOptionTest.prepareBooleanFlag(93unlockExperimentalVMOpts, true),94CommandLineOptionTest.prepareNumericFlag(optionName, 128));9596// Verify that we can setup different SurvivorAlignmentInBytes values.97for (int alignment = 32; alignment <= 128; alignment *= 2) {98CommandLineOptionTest.verifyOptionValue(optionName,99Integer.toString(alignment),100CommandLineOptionTest.prepareBooleanFlag(101unlockExperimentalVMOpts, true),102CommandLineOptionTest.prepareNumericFlag(103optionName, alignment));104}105}106}107108109