oracle/graal · error · IllegalArgumentException
Truncated signature:
Error message
Truncated signature:
What it means
IllegalArgumentException from SignatureUtil.parseParameterSignature: the descriptor ends in the middle of a type — parseParameterSignature hit StringIndexOutOfBoundsException while scanning (e.g. an 'L' class name with no terminating ';', or a parameter list cut off before ')'). The catch converts it into 'Truncated signature: <sig>' so callers get a domain error instead of an obscure bounds exception.
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
- Reproduce the descriptor from a real source (javap -s, MethodType.toMethodDescriptorString()) instead of repairing the truncated string.
- Fix the upstream truncation: check storage lengths and substring bounds.
- Validate with SignatureUtil.isSignatureValid before use to fail with a clear signal instead of mid-parse exceptions.
Example fix
// before String sig = raw.substring(0, 32); // may cut mid-descriptor // after String sig = raw; // keep full descriptor; validate length upstream
Defensive patterns
Strategy: validation
Validate before calling
// Cheap completeness checks before parsing
static boolean looksComplete(String sig) {
return sig != null && sig.startsWith("(") && sig.indexOf(')') > 0
&& sig.endsWith(";") || "VZBCDFIJS".indexOf(sig.charAt(sig.length() - 1)) >= 0;
}
boolean ok = looksComplete(sig) && SignatureUtil.isSignatureValid(sig, false); Type guard
static boolean isWellFormedMethodDescriptor(String s) {
return s != null && s.length() >= 3 && s.charAt(0) == '(' && s.indexOf(')') > 0
&& SignatureUtil.isSignatureValid(s, false);
} Try / catch
try {
SignatureUtil.parseSignature(sig, params);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Truncated signature")) {
// descriptor storage is corrupt — re-derive from the class file, do not pad by hand
sig = recomputeDescriptorFromBytecode(methodRef);
} else throw e;
} Prevention
- Verify fixed-width storage can hold the longest descriptor you write.
- Audit substring/split code for off-by-one cuts on descriptor strings.
- Validate with isSignatureValid immediately after any string surgery on descriptors.
When it happens
Trigger: Calling SignatureUtil.parseSignature with strings like '(Ljava/lang/String', '(', '(I', or 'Lfoo' — substring/split logic upstream dropped characters, or the descriptor was stored truncated.
Common situations: Truncation by a fixed-length column or buffer; substring(end-1) style off-by-one when splitting a signatures file; concatenation that skipped the last token; copy-paste that cut the string early.
Related errors
- Signature cannot be empty
- Extra characters at end of signature:
- Signature must start with a '(':
- Class name in signature contains '.' at index
- Invalid character '
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/8fa03bd99210fc11.
Report an issue: GitHub.