{"record":{"id":"bf51a234e8071854","repo":"oracle/graal","slug":"signature-cannot-be-empty","errorCode":null,"errorMessage":"Signature cannot be empty","messagePattern":"Signature cannot be empty","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 (surfaced via SignatureUtil.parseSignature): the method descriptor string is empty. SignatureUtil parses JVMS 4.3.3 method descriptors like '(II)V'; the very first check rejects '' before even looking for the mandatory leading '('. The non-throwing twin isSignatureValid returns false for the same input.","triggerScenarios":"Calling SignatureUtil.parseSignature(\"\") (or with a string that trims to empty) — e.g. a null-safe default of \"\" for a missing descriptor, or reading a signature field that was never populated.","commonSituations":"Metadata parsing where a method record has an absent signature defaulted to empty string; generating descriptors from templates whose parameter/return placeholders were never substituted; passing a substring that computed to zero length.","solutions":["Guard the call: if signature == null || signature.isBlank(), skip or report the missing descriptor upstream instead of parsing.","Fix the producer so a valid descriptor is always supplied (e.g. use MetaAccessProvider to derive the descriptor from a ResolvedJavaMethod rather than building it by hand).","Use SignatureUtil.isSignatureValid(sig, false) to check before parsing when input is untrusted."],"exampleFix":"// before\nString ret = SignatureUtil.parseSignature(mayBeEmpty, params);\n\n// after\nif (sig == null || sig.isEmpty()) throw new IllegalStateException(\"missing descriptor for \" + method);\nString ret = SignatureUtil.parseSignature(sig, params);","handlingStrategy":"validation","validationCode":"if (sig == null || sig.isEmpty()) {\n    throw new IllegalArgumentException(\"method descriptor missing for \" + method);\n}\n// or non-throwing check\nboolean ok = SignatureUtil.isSignatureValid(sig, /*acceptMissingReturnType=*/ false);","typeGuard":"static boolean isNonEmptyMethodDescriptor(String s) {\n    return s != null && !s.isEmpty() && s.charAt(0) == '(';\n}","tryCatchPattern":"try {\n    String ret = SignatureUtil.parseSignature(sig, params);\n} catch (IllegalArgumentException e) {\n    throw new MetadataException(\"bad descriptor '\" + sig + \"': \" + e.getMessage(), e);\n}","preventionTips":["Never default descriptor fields to \"\"; use null plus explicit checks.","Derive descriptors from ResolvedJavaMethod/MethodType instead of storing hand-made strings.","Use isSignatureValid as a gate for externally supplied descriptors."],"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"}