oracle/graal · warning · InvalidArgumentException

no value provided

Error message

no value provided

What it means

InvalidArgumentException from IntegerValue.parseValue: the option was declared as an Integer but parseValue received null — the option name was present with no operand. Note a known copy-paste defect in this class: the NumberFormatException branch reuses DoubleValue's message text ('invalid double value') even though Integer.valueOf is what is parsed, so the sibling unparseable-value error for integers is mislabeled.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/args/IntegerValue.java:42

 */
package jdk.graal.compiler.util.args;

/**
 * Parses a {@link Integer} from command line arguments.
 */
public class IntegerValue extends OptionValue<Integer> {
    public IntegerValue(String name, String help) {
        super(name, help);
    }

    public IntegerValue(String name, Integer defaultValue, String help) {
        super(name, defaultValue, help);
    }

    @Override
    public boolean parseValue(String arg) throws InvalidArgumentException {
        if (arg == null) {
            throw new InvalidArgumentException(getName(), "no value provided");
        }
        try {
            value = Integer.valueOf(arg);
            return true;
        } catch (NumberFormatException e) {
            throw new InvalidArgumentException(getName(), String.format("invalid double value: \"%s\"", arg));
        }
    }
}

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Pass an explicit integer: '--max-depth=5' or 'max-depth 5' per the parser's convention.
  2. Declare a default via new IntegerValue(name, defaultValue, help) so omitting the option entirely is valid.
  3. When debugging a follow-up 'invalid double value' error from an int option, remember it actually means Integer.valueOf failed (copy-paste bug) — check the string is a plain int literal.

Example fix

# before
$ tool --max-depth

# after
$ tool --max-depth=5
Defensive patterns

Strategy: validation

Validate before calling

// Ensure every integer option token carries a value before parsing
for (int i = 0; i < args.length; i++) {
    if (isIntOption(args[i]) && !args[i].contains("=") && i + 1 >= args.length) {
        fail(args[i] + " requires an integer value, e.g. " + args[i] + "=5");
    }
}

Type guard

static boolean isParsableInt(String s) {
    if (s == null) return false;
    try { Integer.parseInt(s.trim()); return true; } catch (NumberFormatException e) { return false; }
}

Try / catch

try {
    cmd.parse(args);
} catch (InvalidArgumentException e) {
    // note: unparseable int values are mislabeled 'invalid double value' in IntegerValue
    if ("no value provided".equals(e.getMessage()) || e.getMessage().contains("invalid double value")) {
        System.err.println(e.getOption() + " needs an integer like " + e.getOption() + "=5");
    } else throw e;
}

Prevention

When it happens

Trigger: A Command/OptionValue-based CLI where an int option token appears at the end of args or its value element was dropped, so the framework calls IntegerValue.parseValue(null) and the 'no value provided' branch fires.

Common situations: Scripts conditionally appending option names but not values; shell continuations dropping the next line; users assuming a bare '--max-depth' picks a default.

Related errors


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