{"record":{"id":"0e0ca9a5ebce369b","repo":"oracle/graal","slug":"invalid-double-value-s","errorCode":null,"errorMessage":"invalid double value: \"%s\"","messagePattern":"invalid double value: \"(.+?)\"","errorType":"validation","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"warning","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/args/DoubleValue.java","lineNumber":48,"sourceCode":"public class DoubleValue extends OptionValue<Double> {\n    public DoubleValue(String name, String help) {\n        super(name, help);\n    }\n\n    public DoubleValue(String name, Double defaultValue, String help) {\n        super(name, defaultValue, help);\n    }\n\n    @Override\n    public boolean parseValue(String arg) throws InvalidArgumentException {\n        if (arg == null) {\n            throw new InvalidArgumentException(getName(), \"no value provided\");\n        }\n        try {\n            value = Double.valueOf(arg);\n            return true;\n        } catch (NumberFormatException e) {\n            throw new InvalidArgumentException(getName(), String.format(\"invalid double value: \\\"%s\\\"\", arg));\n        }\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":52,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/args/DoubleValue.java#L30-L52","documentation":"InvalidArgumentException from DoubleValue.parseValue: a value string was supplied but Double.valueOf(arg) threw NumberFormatException — the text is not a parsable Java double. The message quotes the offending string, so NaN spellings like 'nan ' with whitespace, localized decimal commas ('0,5'), and trailing units ('0.85x') are all directly visible.","triggerScenarios":"Passing '-opt=0,5' (comma decimal separator from a localized environment), '-opt=85%' , '-opt=1e' or empty string to a DoubleValue option; NumberFormatException is caught and rethrown as InvalidArgumentException with String.format(\"invalid double value: \\\"%s\\\"\", arg).","commonSituations":"Locales that format decimals with commas (de/fr) leaking into arg strings; values read from config files with trailing whitespace or quotes; percentage strings passed where a fraction is expected.","solutions":["Use a plain dot-decimal number: '0.85', '1e-3', '-2.5'; quote shell expansions and trim whitespace.","Fix the producer of the value (config parser, locale-aware formatting) rather than compensating at the CLI.","If a percentage is natural for users, add a dedicated option type that strips '%' and divides, instead of feeding it to DoubleValue."],"exampleFix":"# before (de_DE locale)\n$ tool --threshold=0,85\n\n# after\n$ tool --threshold=0.85","handlingStrategy":"validation","validationCode":"static String normalizeDecimal(String raw) {\n    if (raw == null) return null;\n    String t = raw.trim().replace(',', '.');   // handle localized decimal comma\n    if (t.endsWith(\"%\")) t = t.substring(0, t.length() - 1);\n    if (!t.matches(\"[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?\")) return null; // reject early\n    return t;\n}","typeGuard":"static boolean isParsableDouble(String s) {\n    if (s == null) return false;\n    try { Double.parseDouble(s.trim()); return true; } catch (NumberFormatException e) { return false; }\n}","tryCatchPattern":"try {\n    cmd.parse(args);\n} catch (InvalidArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"invalid double value\")) {\n        System.err.println(e.getOption() + \" expects a dot-decimal number, e.g. 0.85 (got: \" + e.getValue() + \")\");\n    } else throw e;\n}","preventionTips":["Force Locale.ROOT when programmatically formatting numbers destined for CLI args.","Never paste locale-formatted values (comma decimals) into options.","Trim whitespace and strip units at the point of entry, not inside the parse."],"tags":["cli","arguments","double","parsing","locale","options"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}