src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.options/src/org/graalvm/compiler/options/OptionsParser.java
changeset 49873 26ebfe8ce852
parent 48861 47f19ff9903c
child 50858 2d3e99a72541
equal deleted inserted replaced
49872:0798eab12791 49873:26ebfe8ce852
    26 import java.util.Collection;
    26 import java.util.Collection;
    27 import java.util.Formatter;
    27 import java.util.Formatter;
    28 import java.util.List;
    28 import java.util.List;
    29 import java.util.ServiceLoader;
    29 import java.util.ServiceLoader;
    30 
    30 
    31 import org.graalvm.collections.EconomicMap;
    31 import jdk.internal.vm.compiler.collections.EconomicMap;
    32 import org.graalvm.collections.MapCursor;
    32 import jdk.internal.vm.compiler.collections.MapCursor;
    33 import org.graalvm.util.CollectionsUtil;
    33 import org.graalvm.util.CollectionsUtil;
    34 
    34 
    35 /**
    35 /**
    36  * This class contains methods for parsing Graal options and matching them against a set of
    36  * This class contains methods for parsing Graal options and matching them against a set of
    37  * {@link OptionDescriptors}. The {@link OptionDescriptors} are loaded via a {@link ServiceLoader}.
    37  * {@link OptionDescriptors}. The {@link OptionDescriptors} are loaded via a {@link ServiceLoader}.
   114      * @param uncheckedValue the unchecked value for the option
   114      * @param uncheckedValue the unchecked value for the option
   115      * @param values the object in which to store the parsed option and value
   115      * @param values the object in which to store the parsed option and value
   116      * @param loader source of the available {@link OptionDescriptors}
   116      * @param loader source of the available {@link OptionDescriptors}
   117      * @throws IllegalArgumentException if there's a problem parsing {@code option}
   117      * @throws IllegalArgumentException if there's a problem parsing {@code option}
   118      */
   118      */
   119     static void parseOption(String name, Object uncheckedValue, EconomicMap<OptionKey<?>, Object> values, Iterable<OptionDescriptors> loader) {
   119     public static void parseOption(String name, Object uncheckedValue, EconomicMap<OptionKey<?>, Object> values, Iterable<OptionDescriptors> loader) {
   120 
   120 
   121         OptionDescriptor desc = lookup(loader, name);
   121         OptionDescriptor desc = lookup(loader, name);
   122         if (desc == null) {
   122         if (desc == null) {
   123             List<OptionDescriptor> matches = fuzzyMatch(loader, name);
   123             List<OptionDescriptor> matches = fuzzyMatch(loader, name);
   124             Formatter msg = new Formatter();
   124             Formatter msg = new Formatter();
   130                 }
   130                 }
   131             }
   131             }
   132             throw new IllegalArgumentException(msg.toString());
   132             throw new IllegalArgumentException(msg.toString());
   133         }
   133         }
   134 
   134 
   135         Class<?> optionType = desc.getType();
   135         Class<?> optionType = desc.getOptionValueType();
   136         Object value;
   136         Object value;
   137         if (!(uncheckedValue instanceof String)) {
   137         if (!(uncheckedValue instanceof String)) {
   138             if (optionType != uncheckedValue.getClass()) {
   138             if (optionType != uncheckedValue.getClass()) {
   139                 String type = optionType.getSimpleName();
   139                 String type = optionType.getSimpleName();
   140                 throw new IllegalArgumentException(type + " option '" + name + "' must have " + type + " value, not " + uncheckedValue.getClass() + " [toString: " + uncheckedValue + "]");
   140                 throw new IllegalArgumentException(type + " option '" + name + "' must have " + type + " value, not " + uncheckedValue.getClass() + " [toString: " + uncheckedValue + "]");