{"record":{"id":"b9df151fb9f5f75c","repo":"oracle/graal","slug":"extra-characters-at-end-of-signature","errorCode":null,"errorMessage":"Extra characters at end of signature: ","messagePattern":"Extra characters at end of signature: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/SignatureUtil.java","lineNumber":141,"sourceCode":"        }\n    }\n\n    /**\n     * Checks if the given signature can be successfully parsed by\n     * {@link #parseSignature(String, List)}.\n     *\n     * @param signature the signature to check\n     * @param acceptMissingReturnType whether a signature without a return type is considered to be\n     *            valid\n     * @return whether the signature can be successfully parsed\n     */\n    public static boolean isSignatureValid(String signature, boolean acceptMissingReturnType) {\n        return parseSignatureInternal(signature, null, false, acceptMissingReturnType) != null;\n    }\n\n    private static <T> T throwOrReturn(boolean shouldThrow, T returnValue, String errorMessage) {\n        if (shouldThrow) {\n            throw new IllegalArgumentException(errorMessage);\n        } else {\n            return returnValue;\n        }\n    }\n}\n","sourceCodeStart":123,"sourceCodeEnd":147,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/SignatureUtil.java#L123-L147","documentation":"IllegalArgumentException from SignatureUtil.parseSignatureInternal: after the parameter list and return type were successfully parsed, the parse position is not at the end of the string, so the descriptor has extra trailing characters. Valid JVMS 4.3.3 descriptors end exactly after the return type; anything after that (e.g. a second ')' or a stray suffix) makes the descriptor malformed.","triggerScenarios":"Calling SignatureUtil.parseSignature with strings like '(I)VI', '(Ljava/lang/String;)V;', or '(I)V extra' — parseParameterSignature consumes the return type, nextCur != signature.length(), and the error fires with the full signature appended.","commonSituations":"Concatenating descriptors by string '+' instead of building them properly; a template that appends a suffix unconditionally; parsing a string that is actually two descriptors joined; trailing whitespace or semicolon from CSV/JSON round-tripping.","solutions":["Inspect the reported signature string in the message and strip or fix the trailing garbage.","Build descriptors from real methods (ResolvedJavaMethod.getSignature().toMethodDescriptor()) instead of string manipulation when possible.","Pre-validate untrusted input with SignatureUtil.isSignatureValid(sig, false)."],"exampleFix":"// before\nString sig = paramDesc + retDesc + \";\"; // stray trailing ';'\n\n// after\nString sig = paramDesc + retDesc; // e.g. \"(I)V\"","handlingStrategy":"validation","validationCode":"boolean ok = SignatureUtil.isSignatureValid(sig, false);\nif (!ok) reject(\"malformed method descriptor: \" + sig);","typeGuard":null,"tryCatchPattern":"try {\n    SignatureUtil.parseSignature(sig, params);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Extra characters\")) trimAndRetryOrReject(sig);\n    else throw e;\n}","preventionTips":["Build descriptors by concatenating parameter descriptors between '(' and ')' plus exactly one return descriptor — nothing else.","Prefer signature objects from JVMCI metadata over string assembly.","Validate with isSignatureValid at system boundaries."],"tags":["metadata","signature","parsing","jvm-descriptor","illegal-argument"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}