{"record":{"id":"10ae011739ab5e72","repo":"oracle/graal","slug":"unknown-primitive-or-void-type-character-10ae01","errorCode":null,"errorMessage":"unknown primitive or void type character: ","messagePattern":"unknown primitive or void type character: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/JavaKind.java","lineNumber":261,"sourceCode":"    public static JavaKind fromWordSize(int wordSizeInBytes) {\n        if (wordSizeInBytes == 8) {\n            return JavaKind.Long;\n        } else {\n            assert wordSizeInBytes == 4 : \"Unsupported word size!\";\n            return JavaKind.Int;\n        }\n    }\n\n    /**\n     * Returns the kind from the character describing a primitive or void. An exception is thrown if\n     * the character doesn't correspond to any primitive or void type.\n     *\n     * @param ch the character for a void or primitive kind as returned by {@link #getTypeChar()}\n     */\n    public static JavaKind fromPrimitiveOrVoidTypeChar(char ch) {\n        JavaKind kind = fromPrimitiveOrVoidTypeCharOrNull(ch);\n        if (kind == null) {\n            throw new IllegalArgumentException(invalidTypeCharMessage(ch));\n        }\n        return kind;\n    }\n\n    /**\n     * Returns the kind from the character describing a primitive or void. If the character doesn't\n     * correspond to any primitive or void type, null is returned.\n     *\n     * @param ch the character for a void or primitive kind as returned by {@link #getTypeChar()}\n     */\n    public static JavaKind fromPrimitiveOrVoidTypeCharOrNull(char ch) {\n        return switch (ch) {\n            case 'Z' -> Boolean;\n            case 'C' -> Char;\n            case 'F' -> Float;\n            case 'D' -> Double;\n            case 'B' -> Byte;\n            case 'S' -> Short;","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/JavaKind.java#L243-L279","documentation":"JavaKind.fromPrimitiveOrVoidTypeChar maps a single JVM type descriptor character to a JavaKind: Z,C,F,D,B,S,I,J,V. Any other character (including 'L' for references or '[' for arrays, which this method intentionally does not handle) yields IllegalArgumentException 'unknown primitive or void type character'.","triggerScenarios":"Calling fromPrimitiveOrVoidTypeChar with the first char of a descriptor without first checking for 'L'/'[' (e.g. feeding 'Ljava/lang/String;' -> 'L'); descriptor strings with a typo like 'l' or 'i' lowercase; empty/garbage descriptor input from bytecode the tool generated.","commonSituations":"Writing a bytecode parser or generator that assumes every descriptor is primitive; passing class-file descriptors obtained from reflection (getType() char) without filtering reference types; case confusion between JVM spec letters and their lowercase forms.","solutions":["Filter reference/array descriptors first: if the first char is 'L' or '[', it is JavaKind.Object and must not go through this method","Use the null-safe sibling fromPrimitiveOrVoidTypeCharOrNull(ch) and branch on null instead of relying on the exception","Validate generated descriptors against the JVM spec letters (Z C F D B S I J V) before parsing"],"exampleFix":"// before\nJavaKind k = JavaKind.fromPrimitiveOrVoidTypeChar(desc.charAt(0)); // fails on 'L' or '['\n\n// after\nJavaKind k = JavaKind.fromPrimitiveOrVoidTypeCharOrNull(desc.charAt(0));\nif (k == null) k = (desc.charAt(0) == 'L' || desc.charAt(0) == '[') ? JavaKind.Object : null;","handlingStrategy":"validation","validationCode":"JavaKind k = JavaKind.fromPrimitiveOrVoidTypeCharOrNull(ch);\nif (k == null && ch != 'L' && ch != '[') throw new IllegalArgumentException(\"Bad descriptor char: \" + ch);","typeGuard":"static boolean isPrimitiveOrVoidChar(char c) { return \"ZCFDBSIJV\".indexOf(c) >= 0; }","tryCatchPattern":"catch (IllegalArgumentException e) { report the offending descriptor string and index, not just the char }","preventionTips":["Check for 'L'/'[' (reference/array) before calling the primitive mapper","Prefer the OrNull variant in parsers and branch on null"],"tags":["espresso","classfile","descriptor","parsing"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}