{"record":{"id":"a40ec4cc51095879","repo":"oracle/graal","slug":"the-provided-argument-is-a-method-variant-name-s","errorCode":null,"errorMessage":"The provided argument is a method variant name: %s","messagePattern":"The provided argument is a method variant name: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/core/Method.java","lineNumber":78,"sourceCode":"    /**\n     * The list of Graal compilations of this method.\n     */\n    private final List<CompilationUnit> compilationUnits;\n\n    /**\n     * The sum of execution periods of the individual compilation units.\n     */\n    private long totalPeriod;\n\n    /**\n     * Constructs a method.\n     *\n     * @param methodName the name of the method\n     * @param experiment the experiment to which the method belongs\n     */\n    public Method(String methodName, Experiment experiment) {\n        if (methodName.contains(StableMethodNameFormatter.METHOD_VARIANT_KEY_SEPARATOR)) {\n            throw new IllegalArgumentException(\"The provided argument is a method variant name: \" + methodName);\n        }\n        compilationUnits = new ArrayList<>();\n        this.methodName = methodName;\n        this.experiment = experiment;\n        totalPeriod = 0;\n    }\n\n    /**\n     * Gets the experiment to which this compilation unit belongs.\n     */\n    public Experiment getExperiment() {\n        return experiment;\n    }\n\n    /**\n     * Gets the full signature of the root method of this compilation unit including parameter types\n     * as reported in the optimization log.\n     *","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/core/Method.java#L60-L96","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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 '%%'."],"exampleFix":"// before\nMethod m = new Method(rawName, experiment); // rawName = \"java.util.List%%v0.add(int)\"\n// after\nMethod m = new Method(Method.removeMethodVariantKey(rawName), experiment);","handlingStrategy":"validation","validationCode":"if (name.contains(StableMethodNameFormatter.METHOD_VARIANT_KEY_SEPARATOR)) {\n    name = Method.removeMethodVariantKey(name);\n}\nMethod m = new Method(name, experiment);","typeGuard":"static boolean isPlainMethodName(String name) {\n    return name != null && !name.contains(\"%%\");\n}","tryCatchPattern":"try {\n    new Method(name, experiment);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"method variant name\")) { name = Method.removeMethodVariantKey(name); }\n}","preventionTips":["Treat any name from optimization-log positions as variant-carrying and normalize it first.","Never feed raw log strings into the Method constructor."],"tags":["profdiff","api-contract","method-names","validation"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}