{"record":{"id":"8fa03bd99210fc11","repo":"oracle/graal","slug":"truncated-signature","errorCode":null,"errorMessage":"Truncated signature: ","messagePattern":"Truncated 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.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.","triggerScenarios":"Calling SignatureUtil.parseSignature with strings like '(Ljava/lang/String', '(', '(I', or 'Lfoo' — substring/split logic upstream dropped characters, or the descriptor was stored truncated.","commonSituations":"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.","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."],"exampleFix":"// before\nString sig = raw.substring(0, 32); // may cut mid-descriptor\n\n// after\nString sig = raw; // keep full descriptor; validate length upstream","handlingStrategy":"validation","validationCode":"// Cheap completeness checks before parsing\nstatic boolean looksComplete(String sig) {\n    return sig != null && sig.startsWith(\"(\") && sig.indexOf(')') > 0\n        && sig.endsWith(\";\") || \"VZBCDFIJS\".indexOf(sig.charAt(sig.length() - 1)) >= 0;\n}\nboolean ok = looksComplete(sig) && SignatureUtil.isSignatureValid(sig, false);","typeGuard":"static boolean isWellFormedMethodDescriptor(String s) {\n    return s != null && s.length() >= 3 && s.charAt(0) == '(' && s.indexOf(')') > 0\n        && SignatureUtil.isSignatureValid(s, false);\n}","tryCatchPattern":"try {\n    SignatureUtil.parseSignature(sig, params);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Truncated signature\")) {\n        // descriptor storage is corrupt — re-derive from the class file, do not pad by hand\n        sig = recomputeDescriptorFromBytecode(methodRef);\n    } else throw e;\n}","preventionTips":["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."],"tags":["metadata","signature","parsing","jvm-descriptor","truncation","illegal-argument"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}