Path: blob/master/test/hotspot/jtreg/vmTestbase/vm/share/options/OptionSupport.java
41155 views
/*1* Copyright (c) 2008, 2018, 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*/22package vm.share.options;2324/**25* This class actually provides the OptionFramework API26* via two static {@link OptionSupport#setup} methods.27* See also "General description" section of the package level documentation.28*/29public class OptionSupport30{31/**32* This method parses the commandline arguments, setups the instance fields (annotated by @Option) accordingly33* and calls method run().34* @param test the instance to setup fields for35* @param args command line arguments array36*/37public static void setupAndRun(Runnable test, String[] args) {38setupAndRun(test, args, null);39}4041/**42* This method parses the commandline arguments and setups the instance fields (annotated by @Option) accordingly43* @param test the instance to setup fields for44* @param args command line arguments array45*/46public static void setup(Object test, String[] args)47{48setup(test, args, null);49}5051/**52* This method parses the commandline arguments, setups the instance fields (annotated by @Option) accordingly53* and calls method run().54* @param test the instance to setup fields for55* @param args command line arguments array56* @param unknownOptionHandler an option handler for unknown options57*/58public static void setupAndRun(Runnable test, String[] args, OptionHandler unknownOptionHandler) {59setup(test, args, unknownOptionHandler);60test.run();61}626364/**65* This is an extension API which allows Test author to create and66* process some specific options.67* @param test the instance to setup fields for68* @param args command line arguments array69* @param unknownOptionHandler an option handler for unknown options70*71*/72public static void setup(Object test, String[] args, OptionHandler unknownOptionHandler) {73new OptionsSetup(test, args, unknownOptionHandler).run();74}75}767778