Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/shenandoah/options/TestClassUnloadingArguments.java
32285 views
/*1* Copyright (c) 2018, Red Hat, Inc. All rights reserved.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation.6*7* This code is distributed in the hope that it will be useful, but WITHOUT8* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or9* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License10* version 2 for more details (a copy is included in the LICENSE file that11* accompanied this code).12*13* You should have received a copy of the GNU General Public License version14* 2 along with this work; if not, write to the Free Software Foundation,15* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.16*17* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA18* or visit www.oracle.com if you need additional information or have any19* questions.20*21*/2223/*24* @test TestClassUnloadingArguments25* @summary Test that loop mining arguments are sane26* @key gc27* @library /testlibrary28*29* @run driver TestClassUnloadingArguments30*/3132import java.util.*;3334import com.oracle.java.testlibrary.*;3536public class TestClassUnloadingArguments {3738public static void testWith(String msg, boolean cu, boolean cuConc, String... args) throws Exception {39String[] cmds = Arrays.copyOf(args, args.length + 3);40cmds[args.length] = "-Xmx128m";41cmds[args.length + 1] = "-XX:+PrintFlagsFinal";42cmds[args.length + 2] = "-version";43ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds);44OutputAnalyzer output = new OutputAnalyzer(pb.start());45output.shouldHaveExitValue(0);46output.shouldContain("ClassUnloading");47output.shouldContain("ClassUnloadingWithConcurrentMark");4849Asserts.assertEQ(output.firstMatch("(.+?) ClassUnloading.+?= (.+?) (.+?)", 2),50Boolean.toString(cu),51msg + ", but got wrong ClassUnloading");52Asserts.assertEQ(output.firstMatch("(.+?) ClassUnloadingWithConcurrentMark.+?= (.+?) (.+?)", 2),53Boolean.toString(cuConc),54msg + ", but got wrong ClassUnloadingWithConcurrentMark");55}5657public static void main(String[] args) throws Exception {58testDefaultGC();59testShenandoah();60}6162public static void testDefaultGC() throws Exception {63testWith("Default GC should have class unloading enabled",64true, true);6566// Not in JDK 8 and Parallel GC67// testWith("Default GC should disable everything",68// false, false,69// "-XX:-ClassUnloading");7071testWith("Default GC should disable conc unload",72true, false,73"-XX:-ClassUnloadingWithConcurrentMark");7475// Not in JDK 8 and Parallel GC76// testWith("Default GC should not let conc unload to be enabled separately",77// false, false,78// "-XX:-ClassUnloading",79// "-XX:+ClassUnloadingWithConcurrentMark");80}8182public static void testShenandoah() throws Exception {83testWith("Shenandoah GC should have class unloading enabled",84true, true,85"-XX:+UnlockExperimentalVMOptions",86"-XX:+UseShenandoahGC");8788testWith("Shenandoah GC should disable everything",89false, false,90"-XX:+UnlockExperimentalVMOptions",91"-XX:+UseShenandoahGC",92"-XX:-ClassUnloading");9394testWith("Shenandoah GC should enable conc unload",95true, true,96"-XX:+UnlockExperimentalVMOptions",97"-XX:+UseShenandoahGC",98"-XX:+ClassUnloadingWithConcurrentMark");99100testWith("Shenandoah GC should not let conc unload to be enabled separately",101false, false,102"-XX:+UnlockExperimentalVMOptions",103"-XX:+UseShenandoahGC",104"-XX:-ClassUnloading",105"-XX:+ClassUnloadingWithConcurrentMark");106}107108}109110111