Path: blob/master/test/hotspot/jtreg/gc/shenandoah/options/TestClassUnloadingArguments.java
41153 views
/*1* Copyright (c) 2018, 2019, Red Hat, Inc. 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*22*/2324/*25* @test TestClassUnloadingArguments26* @summary Test that loop mining arguments are sane27* @requires vm.gc.Shenandoah28* @library /test/lib29* @run driver TestClassUnloadingArguments30*/3132import java.util.*;3334import jdk.test.lib.Asserts;35import jdk.test.lib.process.ProcessTools;36import jdk.test.lib.process.OutputAnalyzer;3738public class TestClassUnloadingArguments {3940public static void testWith(String msg, boolean cu, boolean cuConc, String... args) throws Exception {41String[] cmds = Arrays.copyOf(args, args.length + 3);42cmds[args.length] = "-Xmx128m";43cmds[args.length + 1] = "-XX:+PrintFlagsFinal";44cmds[args.length + 2] = "-version";45ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds);46OutputAnalyzer output = new OutputAnalyzer(pb.start());47output.shouldHaveExitValue(0);48output.shouldContain("ClassUnloading");49output.shouldContain("ClassUnloadingWithConcurrentMark");5051Asserts.assertEQ(output.firstMatch("(.+?) ClassUnloading.+?= (.+?) (.+?)", 2),52Boolean.toString(cu),53msg + ", but got wrong ClassUnloading");54Asserts.assertEQ(output.firstMatch("(.+?) ClassUnloadingWithConcurrentMark.+?= (.+?) (.+?)", 2),55Boolean.toString(cuConc),56msg + ", but got wrong ClassUnloadingWithConcurrentMark");57}5859public static void main(String[] args) throws Exception {60testDefaultGC();61testShenandoah();62}6364public static void testDefaultGC() throws Exception {65testWith("Default GC should have class unloading enabled",66true, true);6768testWith("Default GC should disable everything",69false, false,70"-XX:-ClassUnloading");7172testWith("Default GC should disable conc unload",73true, false,74"-XX:-ClassUnloadingWithConcurrentMark");7576testWith("Default GC should not let conc unload to be enabled separately",77false, 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