{"record":{"id":"d862519028e34364","repo":"oracle/graal","slug":"invalid-character-at-index-cur-in-signature","errorCode":null,"errorMessage":"Invalid character at index ${cur} in signature: ${signature}","messagePattern":"Invalid character at index (.+?) in signature: (.+?)","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler.processor/src/jdk/graal/compiler/replacements/processor/APHotSpotSignature.java","lineNumber":96,"sourceCode":"        switch (first) {\n            case 'L':\n                while (signature.charAt(cur) != ';') {\n                    cur++;\n                }\n                cur++;\n                break;\n            case 'V':\n            case 'I':\n            case 'B':\n            case 'C':\n            case 'D':\n            case 'F':\n            case 'J':\n            case 'S':\n            case 'Z':\n                break;\n            default:\n                throw new RuntimeException(\"Invalid character at index \" + cur + \" in signature: \" + signature);\n        }\n        return cur;\n    }\n\n    public int getParameterCount(boolean withReceiver) {\n        return arguments.size() + (withReceiver ? 1 : 0);\n    }\n\n    public TypeMirror getParameterType(ProcessingEnvironment env, int index) {\n        if (argumentTypes == null) {\n            argumentTypes = new TypeMirror[arguments.size()];\n        }\n        TypeMirror type = argumentTypes[index];\n        if (arguments.get(index) == null) {\n            throw new RuntimeException(String.format(\"Invalid argument at index %s.\", index));\n        }\n\n        if (type == null) {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler.processor/src/jdk/graal/compiler/replacements/processor/APHotSpotSignature.java#L78-L114","documentation":"While walking a JVM type descriptor, APHotSpotSignature.parseSignature accepts only primitives ('V','I','B','C','D','F','J','S','Z'), 'L...;' class references and '[' array prefixes. Any other character at the current index throws RuntimeException naming the index and the full signature. This is the generic 'malformed descriptor' error for substitution processors that read signature strings from annotations.","triggerScenarios":"A descriptor containing an invalid character where a type is expected: '(Q;)V', '(LFoo)V' (missing semicolon), '()X' or a stray space '(I I)V'. The switch in parseSignature falls through to default and throws at APHotSpotSignature.java:96. The reported index points at the first bad character.","commonSituations":"Typos in hand-written signature strings in replacement/intrinsics annotations; missing ';' after L<class> entries; using Java source syntax ('int') instead of descriptor syntax ('I'); unicode/whitespace accidentally pasted into the annotation value.","solutions":["Rewrite the descriptor using JVM type syntax: primitives as I/B/C/D/F/J/S/Z, objects as 'Lfully/qualified/Name;' (semicolons mandatory), arrays as '[' prefixes.","Use the index in the message to locate the exact bad character.","Cross-check the descriptor with javap -s output for the target method.","Prefer generating descriptors via MethodType.toMethodDescriptorString when building them programmatically."],"exampleFix":"// before\nnew APHotSpotSignature(\"(LFoo)V\"); // missing ';' after Foo\n\n// after\nnew APHotSpotSignature(\"(LFoo;)V\");","handlingStrategy":"validation","validationCode":"static int checkDescriptor(String sig, int i) {\n    char c = sig.charAt(i);\n    if (c == '[') return checkDescriptor(sig, i + 1);\n    if (\"VIBCDFJSZ\".indexOf(c) >= 0) return i + 1;\n    if (c == 'L') {\n        int semi = sig.indexOf(';', i);\n        if (semi < 0) throw new IllegalArgumentException(\"missing ';' at \" + i);\n        return semi + 1;\n    }\n    throw new IllegalArgumentException(\"bad char '\" + c + \"' at \" + i + \" in \" + sig);\n}\n\n// validate each parameter/return chunk before constructing APHotSpotSignature","typeGuard":null,"tryCatchPattern":"try {\n    new APHotSpotSignature(descriptor);\n} catch (RuntimeException e) {\n    // message contains 'Invalid character at index N': use N to fix that exact spot\n    reportMalformedDescriptor(descriptor, e);\n}","preventionTips":["Use JVM descriptor syntax only: I/B/C/D/F/J/S/Z for primitives, 'Lpkg/Name;' (with semicolon) for classes, '[' for arrays.","Never paste Java source types ('int', 'String') into signature strings — convert them first.","Generate descriptors with MethodType.toMethodDescriptorString() when possible."],"tags":["java","graalvm","annotation-processing","jvm-signatures","parsing","runtime-exception"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}