{"record":{"id":"6fa469a0a2458f76","repo":"oracle/graal","slug":"value-for-option-desc-getname-has-invalid-n","errorCode":null,"errorMessage":"Value for option '${desc.getName()}' has invalid number format: ${valueString}","messagePattern":"Value for option '(.+?)' has invalid number format: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler.options/src/jdk/graal/compiler/options/OptionsParser.java","lineNumber":263,"sourceCode":"                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;\n        } else if (valueString.endsWith(\"t\")) {\n            scale = 1024L * 1024L * 1024L * 1024L;\n        }","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler.options/src/jdk/graal/compiler/options/OptionsParser.java#L245-L281","documentation":"Thrown by OptionsParser.parseOptionValue when Float.parseFloat, Double.parseDouble, or parseLong throws NumberFormatException while converting a non-empty string for a numeric option. Long options go through parseLong, which additionally accepts k/m/g/K/M/G scale suffixes, so '10m' is valid for Long but anything non-numeric (including bad suffixes or stray characters) fails here.","triggerScenarios":"Passing 'abc', '1.5.2', '10x', ''+garbage, or an unparseable float like '1,5' (comma decimal separator) to an Integer/Long/Float/Double option; e.g. -Dgraal.CompileThreshold=1O0 (letter O instead of zero) or a locale-formatted number.","commonSituations":"Typos in numeric flags; values copied from spreadsheets or European-locale tools containing commas or spaces; using a decimal value for an Integer/Long option ('2.5' for CompileThreshold); assuming hex without 0x is parsed.","solutions":["Correct the number format shown in the message; use plain decimal digits (optionally with k/m/g suffix for Long options).","For fractional values use a Double/Float-typed option, or round to an integer for Integer/Long options.","Sanitize locale-formatted input at your config boundary: strip thousands separators and convert decimal commas to dots."],"exampleFix":"# before\njava -Dgraal.CompileThreshold=1O0 com.app.Main   # letter O\n\n# after\njava -Dgraal.CompileThreshold=100 com.app.Main","handlingStrategy":"validation","validationCode":"boolean isParsableNumber(Class<?> type, String v) {\n    try {\n        if (type == Float.class) Float.parseFloat(v);\n        else if (type == Double.class) Double.parseDouble(v);\n        else if (type == Integer.class || type == Long.class) {\n            String s = v.toLowerCase(Locale.ROOT).replaceAll(\"[kmg]$\", \"\");\n            Long.parseLong(s);\n        } else return false;\n        return true;\n    } catch (NumberFormatException e) {\n        return false;\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    OptionsParser.parseOptions(settings, values, loader);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"invalid number format\")) {\n        throw new ConfigException(\"Bad numeric value in option settings: \" + e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Strip thousands separators and normalize decimal commas before passing user input as option values.","Remember Long options accept k/m/g suffixes; Integer options do not accept fractions.","Validate numeric flags with a parse attempt in your config loader."],"tags":["graalvm","options","number-format","validation"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}