{"record":{"id":"e70d31430f1a497b","repo":"oracle/graal","slug":"invalid-method-signature","errorCode":null,"errorMessage":"Invalid method signature: {}","messagePattern":"Invalid method signature: (.+?)","errorType":"exception","errorClass":"ParserException.ClassFormatError","httpStatus":null,"severity":"error","filePath":"espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/descriptors/SignatureSymbols.java","lineNumber":202,"sourceCode":"        if (type == ParserTypes.java_lang_Object || TypeSymbols.isArray(type)) {\n            return ParserTypes.java_lang_Object;\n        } else if (type == ParserTypes._int || type == ParserTypes._short || type == ParserTypes._boolean || type == ParserTypes._char) {\n            return ParserTypes._int;\n        } else {\n            return type;\n        }\n    }\n\n    /**\n     * Parses a signature descriptor string into its parameter and return type components.\n     *\n     * @return the parsed parameter types followed by the return type.\n     * @throws ParserException.ClassFormatError if {the signature is not well-formed\n     */\n    @SuppressWarnings({\"rawtypes\", \"unchecked\"})\n    public static Symbol<Type>[] parse(TypeSymbols typeSymbols, Symbol<Signature> signature) throws ParserException.ClassFormatError {\n        if ((signature.length() < 3) || signature.byteAt(0) != '(') {\n            throw new ParserException.ClassFormatError(\"Invalid method signature: \" + signature);\n        }\n        final List<Symbol<Type>> buf = new ArrayList<>();\n        int i = 1;\n        while (signature.byteAt(i) != ')') {\n            final Symbol<Type> descriptor = typeSymbols.parse(signature, i, true);\n            buf.add(descriptor);\n            i = i + descriptor.length();\n            if (i >= signature.length()) {\n                throw new ParserException.ClassFormatError(\"Invalid method signature: \" + signature);\n            }\n        }\n        i++;\n        final Symbol<Type> descriptor = typeSymbols.parse(signature, i, true);\n        if (i + descriptor.length() != signature.length()) {\n            throw new ParserException.ClassFormatError(\"Invalid method signature: \" + signature);\n        }\n        final Symbol<Type>[] descriptors = buf.toArray(new Symbol[buf.size() + 1]);\n        descriptors[buf.size()] = descriptor;","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/descriptors/SignatureSymbols.java#L184-L220","documentation":"SignatureSymbols.parse splits a method signature descriptor such as '(ILjava/lang/String;)V' into parameter and return types. The very first check requires length >= 3 and a leading '('; anything shorter or not starting with '(' throws ClassFormatError 'Invalid method signature: <sig>'.","triggerScenarios":"Passing a signature like 'V', '()', '(I', or a field descriptor by mistake (e.g. 'I' or 'Ljava/lang/String;') where a method signature is required; truncated signature strings from generated bytecode.","commonSituations":"Using a field type descriptor where the method signature slot is expected (common in generated-proxies/serialization code); empty signature from a failed lookup; off-by-one string slicing when concatenating descriptors.","solutions":["Ensure the signature is a full method descriptor: starts with '(', ends with a return type, minimal valid form is '()V'","If you hold a field descriptor, wrap or re-fetch the method descriptor rather than reusing the field type","Add a cheap pre-check: sig.length() >= 3 && sig.charAt(0) == '(' before parsing"],"exampleFix":"// before\nSymbol<Type>[] parts = SignatureSymbols.parse(types, fieldDescriptor); // e.g. \"I\"\n\n// after\nSymbol<Type>[] parts = SignatureSymbols.parse(types, methodDescriptor); // e.g. \"(I)V\"","handlingStrategy":"validation","validationCode":"if (sig.length() < 3 || sig.charAt(0) != '(') throw new IllegalArgumentException(\"Not a method signature: \" + sig);","typeGuard":"static boolean looksLikeMethodSignature(String s) { return s != null && s.length() >= 3 && s.charAt(0) == '(' && s.indexOf(')') > 0; }","tryCatchPattern":"catch (ParserException.ClassFormatError e) { report the offending signature and where it came from (class/method) }","preventionTips":["Do not reuse field descriptors where method signatures are expected","Fuzz-test generated signatures through a parser in CI"],"tags":["espresso","classfile","signature","parsing"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}