{"record":{"id":"376632b4b4d63020","repo":"oracle/graal","slug":"signature-must-start-with-a","errorCode":null,"errorMessage":"Signature must start with a '(': ","messagePattern":"Signature must start with a '\\(': ","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: the descriptor does not start with '(' — the mandatory opening parenthesis of a JVMS 4.3.3 method descriptor. SignatureUtil only accepts full method descriptors '(params)return', so a bare type descriptor such as 'I' or 'Ljava/lang/String;' (valid as a field descriptor, not a method descriptor) is rejected.","triggerScenarios":"Calling SignatureUtil.parseSignature with a field-type descriptor ('I', 'Ljava/lang/String;'), a human-readable signature ('void foo(int)'), or a string that lost its leading '(' in preprocessing.","commonSituations":"Confusing field descriptors with method descriptors when reading class-file metadata; passing a Java-source-style signature where a bytecode descriptor is required; off-by-one substring that drops the first character.","solutions":["Wrap the value as a method descriptor if it is meant to be a parameter/return type: '(I)V' not 'I'.","If you have a Java-source signature, convert it with a proper parser (e.g. MetaAccessProvider.parseMethodDescriptor or bytecode-tooling helpers) instead of string surgery.","Pre-check with SignatureUtil.isSignatureValid(sig, false) on untrusted input."],"exampleFix":"// before\nString ret = SignatureUtil.parseSignature(\"I\", params);\n\n// after\nString ret = SignatureUtil.parseSignature(\"(I)V\", params); // full method descriptor","handlingStrategy":"validation","validationCode":"if (sig == null || sig.isEmpty() || sig.charAt(0) != '(') {\n    throw new IllegalArgumentException(\"expected method descriptor like (I)V, got: \" + sig);\n}","typeGuard":"static boolean isMethodDescriptor(String s) {\n    return s != null && !s.isEmpty() && s.charAt(0) == '(' && s.indexOf(')') > 0;\n}","tryCatchPattern":"try {\n    SignatureUtil.parseSignature(sig, params);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Signature must start\")) {\n        sig = \"(\" + sig + \")V\"; // only if you knowingly held a bare type descriptor\n    } else throw e;\n}","preventionTips":["Remember SignatureUtil accepts only full method descriptors, not field-type descriptors.","Wrap bare type descriptors explicitly when building a synthetic method signature.","Pre-validate externally sourced strings with isSignatureValid."],"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"}