oracle/graal · error · MissingArgumentException

The argument '%s' is required.

Error message

The argument '%s' is required.

What it means

Thrown after the token loop when a required option argument (registered with isRequired()==true) was never set on the command line. The parser iterates all optionArguments and raises MissingArgumentException with the option's name. Defaults do not apply because the argument was declared required.

Source

Thrown at compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/args/ArgumentParser.java:94

            Argument argument;
            if (arg.startsWith(Argument.OPTION_PREFIX)) {
                int equalSignIndex = arg.indexOf(Argument.EQUAL_SIGN);
                String optionArgumentName = equalSignIndex == -1 ? arg : arg.substring(0, equalSignIndex);
                argument = optionArguments.get(optionArgumentName);
                if (argument == null) {
                    throw new UnknownArgumentException(arg);
                }
            } else {
                if (nextPositionalArg >= positionalArguments.size()) {
                    throw new UnknownArgumentException(arg);
                }
                argument = positionalArguments.get(nextPositionalArg++);
            }
            index = argument.parse(args, index);
        }
        for (Argument argument : optionArguments.getValues()) {
            if (!argument.isSet() && argument.isRequired()) {
                throw new MissingArgumentException(argument.getName());
            }
        }
        if (nextPositionalArg < positionalArguments.size() && positionalArguments.get(nextPositionalArg).isRequired()) {
            throw new MissingArgumentException(positionalArguments.get(nextPositionalArg).getName());
        }
    }

    /**
     * Gets options argument mapped by argument name.
     */
    public EconomicMap<String, Argument> getOptionArguments() {
        return optionArguments;
    }

    /**
     * Gets the list of positional arguments.
     */
    public List<Argument> getPositionalArguments() {

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Add the missing required flag named in the exception message, using the exact '--name' spelling.
  2. Run the command's help to see which options are bracketed (optional) vs required in the usage string.
  3. If scripting, validate that all required flags are present before invoking profdiff.

Example fix

# before
mx profdiff normal-tier --experiment1 out1
# after
mx profdiff normal-tier --experiment1 out1 --experiment2 out2
Defensive patterns

Strategy: validation

Validate before calling

// Ensure every required option is present before parse
for (var entry : parser.getOptionArguments().getEntries()) {
    if (entry.getValue().isRequired() && !entry.getValue().isSet()) {
        // check args contains entry.getKey() or entry.getKey() + "="
    }
}

Try / catch

try {
    parser.parse(args);
} catch (MissingArgumentException e) {
    System.err.println("Missing required argument: " + e.getMessage());
    System.exit(1);
}

Prevention

When it happens

Trigger: Invoking a profdiff command that declares a required option (e.g. an input path flag) without supplying it, or supplying it only for the other experiment of a pair (one '--experimentN' given, the other missing).

Common situations: Running a diff command with only one experiment specified, scripts written against an older interface where the option was optional or had a default, or CI jobs that strip arguments.

Related errors


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