oracle/graal · error · IllegalArgumentException

Value for option '${desc.getName()}' has invalid number form

Error message

Value for option '${desc.getName()}' has invalid number format: ${valueString}

What it means

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.

Source

Thrown at compiler/src/jdk.graal.compiler.options/src/jdk/graal/compiler/options/OptionsParser.java:263

                value = ((EnumMultiOptionKey<?>) desc.getOptionKey()).valueOf(valueString);
            } else {
                if (valueString.isEmpty()) {
                    throw new IllegalArgumentException("Non empty value required for option '" + desc.getName() + "'");
                }
                try {
                    if (optionType == Float.class) {
                        value = Float.parseFloat(valueString);
                    } else if (optionType == Double.class) {
                        value = Double.parseDouble(valueString);
                    } else if (optionType == Integer.class) {
                        value = (int) parseLong(valueString);
                    } else if (optionType == Long.class) {
                        value = parseLong(valueString);
                    } else {
                        throw new IllegalArgumentException("Wrong value for option '" + desc.getName() + "'");
                    }
                } catch (NumberFormatException nfe) {
                    throw new IllegalArgumentException("Value for option '" + desc.getName() + "' has invalid number format: " + valueString);
                }
            }
        }
        return value;
    }

    private static long parseLong(String v) {
        String valueString = v.toLowerCase(Locale.ROOT);
        long scale = 1;
        if (valueString.endsWith("k")) {
            scale = 1024L;
        } else if (valueString.endsWith("m")) {
            scale = 1024L * 1024L;
        } else if (valueString.endsWith("g")) {
            scale = 1024L * 1024L * 1024L;
        } else if (valueString.endsWith("t")) {
            scale = 1024L * 1024L * 1024L * 1024L;
        }

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Correct the number format shown in the message; use plain decimal digits (optionally with k/m/g suffix for Long options).
  2. For fractional values use a Double/Float-typed option, or round to an integer for Integer/Long options.
  3. Sanitize locale-formatted input at your config boundary: strip thousands separators and convert decimal commas to dots.

Example fix

# before
java -Dgraal.CompileThreshold=1O0 com.app.Main   # letter O

# after
java -Dgraal.CompileThreshold=100 com.app.Main
Defensive patterns

Strategy: validation

Validate before calling

boolean isParsableNumber(Class<?> type, String v) {
    try {
        if (type == Float.class) Float.parseFloat(v);
        else if (type == Double.class) Double.parseDouble(v);
        else if (type == Integer.class || type == Long.class) {
            String s = v.toLowerCase(Locale.ROOT).replaceAll("[kmg]$", "");
            Long.parseLong(s);
        } else return false;
        return true;
    } catch (NumberFormatException e) {
        return false;
    }
}

Try / catch

try {
    OptionsParser.parseOptions(settings, values, loader);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("invalid number format")) {
        throw new ConfigException("Bad numeric value in option settings: " + e.getMessage(), e);
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/6fa469a0a2458f76. Report an issue: GitHub.