Path: blob/master/test/hotspot/jtreg/vmTestbase/vm/share/options/Option.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;23import java.lang.annotation.*;24/**25* This annotation is the most useful one of the whole API.26* It is used to mark non-static fields of the object and to declare the27* corresponding options. The name of the option defaults to the name of the field.28* The help message for the option should also be also declared29* here (or it could be declared at the {@link ObjectFactory} level at any case it is mandatory).30* For non-simple option types a factory attribute should be provided which31* points to a class which implements {@link ObjectFactory} interface. That factory is32* then used to instantiate an object given the option value and to populate the33* annotated field.34*35* If a default value is provided it is used if the corresponding option is not declared36* at the command line. If it is not provided and there is no option then an error is thrown.37* For non-simple field types default values can be provided at ObjectFactory level.38* See also the documentation at the package level.).39*/40// kept at runtime, applied to fields only.41@Retention(RetentionPolicy.RUNTIME)42@Target(ElementType.FIELD)43public @interface Option44{45// these strings help to find out if the corresponding attribute was not defined.46final public static String defName = "[no name]";47final public static String defDefaultValue = "[no default]";48final public static String defDescription = "[no description]";4950/**51* The name of the option, defaults to the name of the annotated field.52*/53String name() default defName;54/**55* The default value for the option, option is mandatory if it is not specified here56* and at the ObjectFactory level.57*/58String default_value() default defDefaultValue;59/**60* A short description of the option used to generate a help message.61*/62String description() default defDescription;6364/**65* The factory class to use for instantiating the corresponding option.66*/67Class<? extends OptionObjectFactory> factory() default OptionObjectFactory.class;68}697071