oracle/graal · error · IllegalArgumentException
The provided argument is a method variant name: %s
Error message
The provided argument is a method variant name: %s
What it means
Method's constructor rejects any methodName containing the method variant key separator '%%' (StableMethodNameFormatter.METHOD_VARIANT_KEY_SEPARATOR). Method objects must hold plain method names; names carrying a variant key are only valid input to splitMethodVariantName/removeMethodVariantKey. It is an IllegalArgumentException, i.e. a programmer/contract error, not bad input data.
Source
Thrown at compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/core/Method.java:78
/**
* The list of Graal compilations of this method.
*/
private final List<CompilationUnit> compilationUnits;
/**
* The sum of execution periods of the individual compilation units.
*/
private long totalPeriod;
/**
* Constructs a method.
*
* @param methodName the name of the method
* @param experiment the experiment to which the method belongs
*/
public Method(String methodName, Experiment experiment) {
if (methodName.contains(StableMethodNameFormatter.METHOD_VARIANT_KEY_SEPARATOR)) {
throw new IllegalArgumentException("The provided argument is a method variant name: " + methodName);
}
compilationUnits = new ArrayList<>();
this.methodName = methodName;
this.experiment = experiment;
totalPeriod = 0;
}
/**
* Gets the experiment to which this compilation unit belongs.
*/
public Experiment getExperiment() {
return experiment;
}
/**
* Gets the full signature of the root method of this compilation unit including parameter types
* as reported in the optimization log.
*View on GitHub (pinned to a66e9ccd1d)
Solutions
- Normalize the name before construction: Method.removeMethodVariantKey(name) or Method.splitMethodVariantName(name).
- If you intended to key by variant, keep the variant name as a map key and construct Method with only the base name.
- Add a unit test asserting Method is never constructed from names containing '%%'.
Example fix
// before Method m = new Method(rawName, experiment); // rawName = "java.util.List%%v0.add(int)" // after Method m = new Method(Method.removeMethodVariantKey(rawName), experiment);
Defensive patterns
Strategy: validation
Validate before calling
if (name.contains(StableMethodNameFormatter.METHOD_VARIANT_KEY_SEPARATOR)) {
name = Method.removeMethodVariantKey(name);
}
Method m = new Method(name, experiment); Type guard
static boolean isPlainMethodName(String name) {
return name != null && !name.contains("%%");
} Try / catch
try {
new Method(name, experiment);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("method variant name")) { name = Method.removeMethodVariantKey(name); }
} Prevention
- Treat any name from optimization-log positions as variant-carrying and normalize it first.
- Never feed raw log strings into the Method constructor.
When it happens
Trigger: Calling 'new Method(name, experiment)' where name came straight from an optimization log position that still contains a variant key like 'java.lang.String%%variant0(int)'. The fix is to strip the key first with Method.removeMethodVariantKey or Method.splitMethodVariantName.
Common situations: New parsing code that feeds raw optimization-log method names into Method; logs produced by GraalVM versions that emit variant keys (duplicate inlined shapes of the same method) hitting older/naive call sites.
Related errors
- Malformed method variant name: %s
- classForNode method shall return node class representation r
- Cannot compare {JavaLangRuntimeVersion.__name__} to {type(ot
- Out of scratch registers: %s
- Should be recognized as signature:
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/a40ec4cc51095879.
Report an issue: GitHub.