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
EnumOptionKey.valueOf delegates to Enum.valueOf(enumClass, name); an unknown constant throws IllegalArgumentException quoting the bad value, the option name, and EnumSet.allOf(enumClass) as the valid set. This is the standard parse-time check every single-valued Graal enum option performs when a -D option string is converted to its enum value.
Source
Thrown at compiler/src/jdk.graal.compiler.options/src/jdk/graal/compiler/options/EnumOptionKey.java:53
super(value);
if (value == null) {
throw new IllegalArgumentException("Value must not be null");
}
this.enumClass = value.getDeclaringClass();
}
/**
* @return the set of possible values for this option.
*/
public EnumSet<T> getAllValues() {
return EnumSet.allOf(enumClass);
}
public Object valueOf(String name) {
try {
return Enum.valueOf(enumClass, name);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("\"" + name + "\" is not a valid option for " + getName() + ". Valid values are " + getAllValues());
}
}
@Override
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, T oldValue, T newValue) {
assert enumClass.isInstance(newValue) : newValue + " is not a valid value for " + getName();
}
}
View on GitHub (pinned to a66e9ccd1d)
Solutions
- Use one of the constants listed in the message's 'Valid values are' output, with exact casing.
- After upgrading GraalVM, re-check the option's enum via the options help/dump for renames.
- Lint option values in build scripts against the enum values before running.
- Prefer symbolic constants over hand-typed strings where the API allows setting the enum directly.
Example fix
# before -Dgraal.OptimizationLevel=aggressive # after (valid constant from the message) -Dgraal.OptimizationLevel=Aggressive
Defensive patterns
Strategy: validation
Validate before calling
// Check the value parses before launching with -D
try {
Enum.valueOf(MyOptionEnum.class, value);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid value; valid: " + EnumSet.allOf(MyOptionEnum.class));
} Try / catch
try {
EnumOptionKey k = (EnumOptionKey) key;
k.valueOf(value);
} catch (IllegalArgumentException e) {
// message shows the valid set; correct the -D flag and restart
} Prevention
- Match enum constant casing exactly
- Verify option value sets per GraalVM version in a smoke test
- Prefer API-set enum values over string flags when available
When it happens
Trigger: Setting a Graal enum option to a name that is not one of its constants: case mismatch (e.g. 'inline' vs 'Inline'), renamed constant across versions, or passing a boolean/other-typed value to an enum option.
Common situations: Command-line or .graal-compiler-config typos; documentation from a different GraalVM version; scripts built against older option sets after an upgrade.
Related errors
- "%s" is not a valid option for %s. Valid values are %s
- Value for {} cannot be empty
- Invalid directed inlining rules file path: {path}
- Invalid option
- Unknown tier option value '%s'. %s
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/c4efe781078c83fc.
Report an issue: GitHub.