{"record":{"id":"a115ddfed5660233","repo":"oracle/graal","slug":"invalid-constant-pool-tag-s","errorCode":null,"errorMessage":"Invalid constant pool tag: %s","messagePattern":"Invalid constant pool tag: (.+?)","errorType":"exception","errorClass":"ClassFormatError","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/classfile/ClassfileConstantPool.java","lineNumber":135,"sourceCode":"                return new ClassfileConstant.Primitive(tag, JavaConstant.forDouble(stream.readDouble()));\n            case ClassfileConstant.CONSTANT_NameAndType:\n                return new ClassfileConstant.NameAndType(stream);\n            case ClassfileConstant.CONSTANT_Utf8:\n                return new ClassfileConstant.Utf8(stream.readUTF());\n            case ClassfileConstant.CONSTANT_MethodHandle:\n                skipFully(stream, 3); // reference_kind, reference_index\n                return new ClassfileConstant.Unsupported(tag, \"CONSTANT_MethodHandle_info\");\n            case ClassfileConstant.CONSTANT_MethodType:\n                skipFully(stream, 2); // descriptor_index\n                return new ClassfileConstant.Unsupported(tag, \"CONSTANT_MethodType_info\");\n            case ClassfileConstant.CONSTANT_Dynamic:\n                skipFully(stream, 4); // bootstrap_method_attr_index, name_and_type_index\n                return new ClassfileConstant.Unsupported(tag, \"CONSTANT_Dynamic_info\");\n            case ClassfileConstant.CONSTANT_InvokeDynamic:\n                skipFully(stream, 4); // bootstrap_method_attr_index, name_and_type_index\n                return new ClassfileConstant.Unsupported(tag, \"CONSTANT_InvokeDynamic_info\");\n            default:\n                throw new ClassFormatError(\"Invalid constant pool tag: \" + tag);\n        }\n    }\n\n    @Override\n    public int length() {\n        return entries.length;\n    }\n\n    <T extends ClassfileConstant> T get(Class<T> c, int index) {\n        return c.cast(entries[index]);\n    }\n\n    @Override\n    public void loadReferencedType(int index, int opcode) {\n        if (opcode == Bytecodes.INVOKEDYNAMIC) {\n            throw new GraalError(\"INVOKEDYNAMIC not supported by \" + ClassfileBytecodeProvider.class.getSimpleName());\n        }\n        entries[index].loadReferencedType(this, index, opcode);","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/classfile/ClassfileConstantPool.java#L117-L153","documentation":"ClassfileConstantPool parses the constant pool tag-by-tag; the JVMS defines a closed set of tags, and the default branch throws ClassFormatError('Invalid constant pool tag') for any tag byte outside it. This indicates malformed class-file data, not a usage error.","triggerScenarios":"The DataInputStream points at data that is not a well-formed constant pool: corrupt class bytes, a non-class resource misinterpreted as a class, or a class mutated by broken bytecode tooling.","commonSituations":"Corrupted jars (failed download, disk issue), bytecode generators computing wrong constant pool offsets, class files processed by an obfuscator/agent bug.","solutions":["Reproduce the parse outside Graal with javap -v on the class to confirm the file is malformed.","Rebuild or re-download the jar containing the broken class.","If you generate classes with ASM/bytecode tooling, verify the writer version and output with a verifier (e.g. CheckClassAdapter)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    ClassfileConstantPool pool = new ClassfileConstantPool(stream, context);\n} catch (ClassFormatError e) {\n    // Malformed bytes: quarantine the artifact and rebuild/re-download it; never parse it again as-is\n    throw new IllegalStateException(\"Corrupt class data for \" + type.toJavaName(), e);\n}","preventionTips":["Verify downloaded jars (checksums/signatures) before feeding classes to the parser.","If you generate bytecode, run it through a verifier (ASM CheckClassAdapter) in tests."],"tags":["classfile","constant-pool","corruption","class-format"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}