oracle/graal · error · IllegalArgumentException

Non empty value required for option '%s'

Error message

Non empty value required for option '%s'

What it means

Thrown by OptionsParser.parseOptionValue when a numeric-typed option (Float, Double, Integer, Long) is given an empty string as its value. An empty value makes it impossible to attempt number parsing, so the parser rejects it up front with this IllegalArgumentException instead of a NumberFormatException.

Source

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

            value = uncheckedValue;
        } else {
            if (optionType == Boolean.class) {
                if ("true".equals(valueString)) {
                    value = Boolean.TRUE;
                } else if ("false".equals(valueString)) {
                    value = Boolean.FALSE;
                } else {
                    throw new IllegalArgumentException("Boolean option '" + desc.getName() + "' must have value \"true\" or \"false\", not \"" + uncheckedValue + "\"");
                }
            } else if (optionType == String.class) {
                value = valueString;
            } else if (Enum.class.isAssignableFrom(optionType)) {
                value = ((EnumOptionKey<?>) desc.getOptionKey()).valueOf(valueString);
            } else if (optionType == EconomicSet.class) {
                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);
                }
            }
        }

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Supply an actual number for the option named in the message.
  2. If the knob is meant to be unset, omit the whole <name>= entry rather than leaving the value empty.
  3. In scripts, guard with a default: VAL=${VAL:-1000} before assembling the flag.

Example fix

# before
java -Dgraal.CompileThreshold= com.app.Main

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

Strategy: validation

Validate before calling

boolean isNonEmptySetting(String setting) {
    int eq = setting.indexOf('=');
    return eq >= 0 && !setting.substring(eq + 1).isEmpty();
}

settingsList.removeIf(s -> !isNonEmptySetting(s)); // or reject with a clear error

Try / catch

try {
    OptionsParser.parseOptions(settings, values, loader);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Non empty value required")) {
        throw new ConfigException("Numeric option left blank: " + e.getMessage(), e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Passing 'CompileThreshold=' or ' someOption=""' for any non-Boolean, non-String, non-Enum option. It fires only on the numeric branch: String options accept empty values, Enum/EnumMulti go through valueOf, Booleans get the true/false error.

Common situations: Templates or property files with a placeholder that was never filled in (OPT=); shell scripts building flags from unset variables (-Dgraal.Threshold="${VAL}" with VAL empty); CI config where an optional numeric knob is left blank instead of omitted.

Related errors


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