{"record":{"id":"2aa6aff7878f9261","repo":"oracle/graal","slug":"wrong-value-for-option-s","errorCode":null,"errorMessage":"Wrong value for option '%s'","messagePattern":"Wrong value for option '(.+?)'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler.options/src/jdk/graal/compiler/options/OptionsParser.java","lineNumber":260,"sourceCode":"            } else if (Enum.class.isAssignableFrom(optionType)) {\n                value = ((EnumOptionKey<?>) desc.getOptionKey()).valueOf(valueString);\n            } else if (optionType == EconomicSet.class) {\n                value = ((EnumMultiOptionKey<?>) desc.getOptionKey()).valueOf(valueString);\n            } else {\n                if (valueString.isEmpty()) {\n                    throw new IllegalArgumentException(\"Non empty value required for option '\" + desc.getName() + \"'\");\n                }\n                try {\n                    if (optionType == Float.class) {\n                        value = Float.parseFloat(valueString);\n                    } else if (optionType == Double.class) {\n                        value = Double.parseDouble(valueString);\n                    } else if (optionType == Integer.class) {\n                        value = (int) parseLong(valueString);\n                    } else if (optionType == Long.class) {\n                        value = parseLong(valueString);\n                    } else {\n                        throw new IllegalArgumentException(\"Wrong value for option '\" + desc.getName() + \"'\");\n                    }\n                } catch (NumberFormatException nfe) {\n                    throw new IllegalArgumentException(\"Value for option '\" + desc.getName() + \"' has invalid number format: \" + valueString);\n                }\n            }\n        }\n        return value;\n    }\n\n    private static long parseLong(String v) {\n        String valueString = v.toLowerCase(Locale.ROOT);\n        long scale = 1;\n        if (valueString.endsWith(\"k\")) {\n            scale = 1024L;\n        } else if (valueString.endsWith(\"m\")) {\n            scale = 1024L * 1024L;\n        } else if (valueString.endsWith(\"g\")) {\n            scale = 1024L * 1024L * 1024L;","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler.options/src/jdk/graal/compiler/options/OptionsParser.java#L242-L278","documentation":"Thrown by OptionsParser.parseOptionValue when the option's declared value type is none of the supported kinds (Boolean, String, Enum, EconomicSet, Float, Double, Integer, Long). It is a defensive branch: it indicates an OptionDescriptor was declared with an option type the generic parser does not know how to convert from a String, which is essentially a programming error in the option declaration rather than a user input mistake.","triggerScenarios":"A custom OptionKey subclass with an unsupported boxed type (e.g. Short, BigDecimal, or a custom class) whose descriptor reaches the generic string-parsing path in parseOptionValue. Users cannot trigger this through ordinary -Dgraal flags because shipped options all use supported types.","commonSituations":"Writing a new Graal option with an exotic value type and relying on OptionsParser to parse it from a String; passing a programmatically-built OptionDescriptor for a custom option system modeled on Graal's.","solutions":["Declare the option with one of the supported types (Boolean, String, an enum, Float, Double, Integer, Long) or an EnumMultiOptionKey set.","If a custom type is required, parse the String yourself and call desc.getOptionKey().update(values, parsedObject) directly, bypassing the generic String branch.","Check desc.getOptionValueType() for the offending option to confirm which type fell through."],"exampleFix":"// before\nOptionKey<Short> MyOpt = OptionKey.stub(...); // unsupported type\n\n// after\nOptionKey<Integer> MyOpt = new OptionKey<>(0); // supported; scale at use site","handlingStrategy":"validation","validationCode":"static final Set<Class<?>> SUPPORTED = Set.of(Boolean.class, String.class, Float.class, Double.class, Integer.class, Long.class);\n\nboolean isParserSupported(OptionDescriptor desc) {\n    Class<?> t = desc.getOptionValueType();\n    return SUPPORTED.contains(t) || Enum.class.isAssignableFrom(t) || EconomicSet.class.isAssignableFrom(t);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare custom options only with Boolean, String, enum, Float, Double, Integer, Long, or EnumMultiOptionKey set types.","For exotic types, parse Strings yourself and call getOptionKey().update() with a pre-built object.","Add a unit test that round-trips every custom option through parseOptionValue."],"tags":["graalvm","options","unsupported-type","internal"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}