oracle/graal · error · IllegalArgumentException
Extra characters at end of signature:
Error message
Extra characters at end of signature:
What it means
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.
Source
Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/SignatureUtil.java:141
}
}
/**
* Checks if the given signature can be successfully parsed by
* {@link #parseSignature(String, List)}.
*
* @param signature the signature to check
* @param acceptMissingReturnType whether a signature without a return type is considered to be
* valid
* @return whether the signature can be successfully parsed
*/
public static boolean isSignatureValid(String signature, boolean acceptMissingReturnType) {
return parseSignatureInternal(signature, null, false, acceptMissingReturnType) != null;
}
private static <T> T throwOrReturn(boolean shouldThrow, T returnValue, String errorMessage) {
if (shouldThrow) {
throw new IllegalArgumentException(errorMessage);
} else {
return returnValue;
}
}
}
View on GitHub (pinned to a66e9ccd1d)
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).
Example fix
// before String sig = paramDesc + retDesc + ";"; // stray trailing ';' // after String sig = paramDesc + retDesc; // e.g. "(I)V"
Defensive patterns
Strategy: validation
Validate before calling
boolean ok = SignatureUtil.isSignatureValid(sig, false);
if (!ok) reject("malformed method descriptor: " + sig); Try / catch
try {
SignatureUtil.parseSignature(sig, params);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Extra characters")) trimAndRetryOrReject(sig);
else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Signature cannot be empty
- Signature must start with a '(':
- Class name in signature contains '.' at index
- Invalid character '
- Truncated signature:
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/b9df151fb9f5f75c.
Report an issue: GitHub.