Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/testlibrary_tests/whitebox/vm_flags/BooleanTest.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/*24* @test BooleanTest25* @bug 802875626* @library /testlibrary /testlibrary/whitebox27* @build BooleanTest28* @run main ClassFileInstaller sun.hotspot.WhiteBox29* @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI BooleanTest30* @summary testing of WB::set/getBooleanVMFlag()31* @author [email protected]32*/3334import sun.hotspot.WhiteBox;35import com.oracle.java.testlibrary.*;36import sun.management.*;37import com.sun.management.*;3839public class BooleanTest {40private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();41private static final Boolean[] TESTS = {true, false, true, true, false};42private static final String TEST_NAME = "BooleanTest";43private static final String FLAG_NAME = "PrintCompilation";44private static final String METHOD = TEST_NAME + "::method";45private static final String METHOD1 = METHOD + "1";46private static final String METHOD2 = METHOD + "2";4748public static void main(String[] args) throws Exception {49if (args.length == 0) {50VmFlagTest.runTest(FLAG_NAME, TESTS,51VmFlagTest.WHITE_BOX::setBooleanVMFlag,52VmFlagTest.WHITE_BOX::getBooleanVMFlag);53testFunctional(false);54testFunctional(true);55} else {56boolean value = Boolean.valueOf(args[0]);57method1();58VmFlagTest.WHITE_BOX.setBooleanVMFlag(FLAG_NAME, value);59method2();60}61}6263private static void testFunctional(boolean value) throws Exception {64ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(65"-Xbootclasspath/a:.",66"-XX:+UnlockDiagnosticVMOptions",67"-XX:+WhiteBoxAPI",68"-Xcomp",69"-XX:CompileCommand=compileonly," + METHOD + "*",70"-XX:" + (value ? "-" : "+") + FLAG_NAME,71TEST_NAME,72"" + value);73OutputAnalyzer out = new OutputAnalyzer(pb.start());74if (value) {75out.shouldNotContain(METHOD1);76out.shouldContain(METHOD2);77} else {78out.shouldContain(METHOD1);79out.shouldNotContain(METHOD2);80}81}8283private static void method1() { }84private static void method2() { }85}86878889