Path: blob/master/test/hotspot/jtreg/gc/arguments/GCArguments.java
40943 views
/*1* Copyright (c) 2019, 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*/2223package gc.arguments;2425import java.util.ArrayList;26import java.util.Collections;27import java.util.List;28import jdk.test.lib.Platform;29import jdk.test.lib.process.ProcessTools;3031/**32* Helper class for adding options to child processes that should be33* used by all of the argument tests in this package. The default34* options are added at the front, to allow them to be overridden by35* explicit options from any particular test.36*/3738public final class GCArguments {3940// Avoid excessive execution time.41static private void disableZapUnusedHeapArea(List<String> arguments) {42// Develop option, only available in debug builds.43if (Platform.isDebugBuild()) {44arguments.add("-XX:-ZapUnusedHeapArea");45}46}4748// Avoid excessive execution time.49static private void disableVerifyBeforeExit(List<String> arguments) {50// Diagnostic option, default enabled in debug builds.51if (Platform.isDebugBuild()) {52arguments.add("-XX:-VerifyBeforeExit");53}54}5556static private void addDefaults(List<String> arguments) {57disableZapUnusedHeapArea(arguments);58disableVerifyBeforeExit(arguments);59}6061static private String[] withDefaults(String[] arguments) {62List<String> augmented = new ArrayList<String>();63addDefaults(augmented);64Collections.addAll(augmented, arguments);65return augmented.toArray(new String[augmented.size()]);66}6768static public ProcessBuilder createJavaProcessBuilder(List<String> arguments) {69return createJavaProcessBuilder(arguments.toArray(String[]::new));70}7172static public ProcessBuilder createJavaProcessBuilder(String... arguments) {73return ProcessTools.createJavaProcessBuilder(withDefaults(arguments));74}7576static public ProcessBuilder createTestJvm(List<String> arguments) {77return createTestJvm(arguments.toArray(String[]::new));78}7980static public ProcessBuilder createTestJvm(String... arguments) {81return ProcessTools.createTestJvm(withDefaults(arguments));82}83}848586