oracle/graal · error · IllegalArgumentException

"%s" is not a valid option for %s. Valid values are %s

Error message

"%s" is not a valid option for %s. Valid values are %s

What it means

EnumMultiOptionKey parses a comma-separated option value into an EconomicSet of enum constants. Each split name is passed to Enum.valueOf; failure throws IllegalArgumentException with the quoted bad value, the option's name, and the full set of valid enum constants. This is the parse-time validation for multi-valued enum options like -Dgraal.SomeOption=A,B.

Source

Thrown at compiler/src/jdk.graal.compiler.options/src/jdk/graal/compiler/options/EnumMultiOptionKey.java:66

    /**
     * Returns the set of possible values for this option.
     */
    public EnumSet<T> getAllValues() {
        return EnumSet.allOf(enumClass);
    }

    public Object valueOf(String name) {
        EconomicSet<T> value = EconomicSet.create();
        if (name.isEmpty()) {
            return value;
        }
        String[] names = name.split(",");
        for (String splitName : names) {
            try {
                value.add(Enum.valueOf(enumClass, splitName));
            } catch (IllegalArgumentException e) {
                throw new IllegalArgumentException("\"" + splitName + "\" is not a valid option for " + getName() + ". Valid values are " + getAllValues());
            }
        }
        return value;
    }
}

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Match the token exactly (case-sensitive) to one of the constants listed in the message's 'Valid values are' set.
  2. Remove stale constants after a GraalVM upgrade by checking the current enum's values (the error message enumerates them all).
  3. Validate the value in CI with a smoke run that parses options before deployment.
  4. Watch for whitespace or trailing commas around tokens in the comma-separated list.

Example fix

# before
-Dgraal.GraalCompilerConfiguration=misspelled,native
# after (exact enum constant names from the message)
-Dgraal.GraalCompilerConfiguration=community,native
Defensive patterns

Strategy: validation

Validate before calling

// Validate tokens against the enum before setting the option
Set<String> valid = EnumSet.allOf(MyOptionEnum.class).stream().map(Enum::name).collect(Collectors.toSet());
for (String token : value.split(",")) {
    if (!valid.contains(token)) throw new IllegalArgumentException("bad token: " + token);
}

Try / catch

try {
    optionKey.valueOf(value);
} catch (IllegalArgumentException e) {
    // message lists all valid values; pick the closest constant and re-run
}

Prevention

When it happens

Trigger: Setting a multi-value enum option to a string containing a token that is not one of its enum constants — misspelling, wrong case (enum names are matched exactly), trailing comma producing an empty token after split in some cases, or a constant that exists only in another GraalVM version.

Common situations: Typos in -Dgraal.* flags on the command line or in mx/env files; upgrading GraalVM where an enum constant was renamed/removed; copy-pasting option values from documentation for a different version.

Related errors


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