{"record":{"id":"53629a4aa88e6762","repo":"oracle/graal","slug":"class-name-in-signature-contains-at-index","errorCode":null,"errorMessage":"Class name in signature contains '.' at index ","messagePattern":"Class name in signature contains '\\.' at index ","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: while scanning an 'L...' class name inside a descriptor, a '.' is found in the fully-qualified class name. JVMS descriptors use '/' as the package separator ('Ljava/lang/String;'); a '.' indicates a Java-source-style name ('Ljava.lang.String;') slipped in, which would silently produce wrong resolved types, so the parser rejects it explicitly (message includes the offending index and full signature).","triggerScenarios":"Calling SignatureUtil.parseSignature with a descriptor built via Class.getName() (which returns dotted names like 'java.lang.String') instead of the internal slash form — e.g. 'L' + clazz.getName() + ';' yields 'Ljava.lang.String;' and trips this check at the first '.'.","commonSituations":"Building descriptors from reflection: Class.getName() vs the internal name; copy-pasting signatures from javadoc/source instead of from javap -s output; string-replacing only some dots.","solutions":["Use the internal form: replace '.' with '/' — or better, use a helper like JVMCI's MetaUtil.toInternalName or signature.toString() from a ResolvedJavaMethod.","If building from reflection, use MethodType.toMethodDescriptorString() which emits the correct format.","Pre-validate with SignatureUtil.isSignatureValid before parsing untrusted strings."],"exampleFix":"// before\nString d = \"L\" + clazz.getName() + \";\"; // Ljava.lang.String;\n\n// after\nString d = \"L\" + clazz.getName().replace('.', '/') + \";\"; // Ljava/lang/String;\n// or: MethodType.fromMethodDescriptorString(...).toMethodDescriptorString()","handlingStrategy":"validation","validationCode":"// Normalize dotted names to internal form before parsing\nString normalized = sig.replace('.', '/');\nboolean ok = SignatureUtil.isSignatureValid(normalized, false);\n// But prefer generating from JVMCI/Reflection: MethodType...toMethodDescriptorString()","typeGuard":"static boolean usesInternalNames(String descriptor) {\n    // no '.' may appear anywhere inside L...; segments\n    return !descriptor.chars().anyMatch(c -> c == '.');\n}","tryCatchPattern":"try {\n    SignatureUtil.parseSignature(sig, params);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"contains '.'\")) {\n        SignatureUtil.parseSignature(sig.replace('.', '/'), params);\n    } else throw e;\n}","preventionTips":["Never build 'L...;' names from Class.getName() without replacing '.' with '/'.","Use reflection helpers (MethodType.toMethodDescriptorString) or javap -s for exact formats.","Add a unit test asserting every descriptor you emit parses cleanly."],"tags":["metadata","signature","parsing","jvm-descriptor","class-names","illegal-argument"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}