{"record":{"id":"95868904ee682f63","repo":"Konloch/bytecode-viewer","slug":"unknown-constant-pool-tag-tag","errorCode":null,"errorMessage":"Unknown constant pool tag ${tag}","messagePattern":"Unknown constant pool tag (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"plugins/java/ClassParser.java","lineNumber":304,"sourceCode":"                    case ConstantType.CONSTANT_MethodHandle:\n                        int referenceKind = buffer.get() & 0xFF;\n                        int referenceIndex = buffer.getShort() & 0xFFFF;\n                        cpList.add(\"[\" + i + \"] CONSTANT_MethodHandle: \" + referenceKind + \":#\" + referenceIndex);\n                        break;\n\n                    case ConstantType.CONSTANT_MethodType:\n                        int descriptorIndex1 = buffer.getShort() & 0xFFFF;\n                        cpList.add(\"[\" + i + \"] CONSTANT_MethodType: #\" + descriptorIndex1);\n                        break;\n\n                    case ConstantType.CONSTANT_InvokeDynamic:\n                        int bootstrapMethodAttrIndex = buffer.getShort() & 0xFFFF;\n                        int nameAndTypeIndex3 = buffer.getShort() & 0xFFFF;\n                        cpList.add(\"[\" + i + \"] CONSTANT_InvokeDynamic: #\" + bootstrapMethodAttrIndex + \":#\" + nameAndTypeIndex3);\n                        break;\n\n                    default:\n                        throw new IllegalArgumentException(\"Unknown constant pool tag \" + tag);\n                }\n            }\n        }\n\n        private String getRefTypeName(int tag)\n        {\n            switch (tag)\n            {\n                case ConstantType.CONSTANT_Fieldref:\n                    return \"Fieldref\";\n                case ConstantType.CONSTANT_Methodref:\n                    return \"Methodref\";\n                case ConstantType.CONSTANT_InterfaceMethodref:\n                    return \"InterfaceMethodref\";\n                default:\n                    return \"Unknown\";\n            }\n        }","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/Konloch/bytecode-viewer/blob/31430e0033fa220db566b5ef461256727ff6793b/plugins/java/ClassParser.java#L286-L322","documentation":"Thrown by parseConstantPool in the Java class-file parser when the constant pool entry's tag byte is not one of the recognized JVM CONSTANT_* tags. The JVM spec defines tags 1-15 (Utf8, Integer, Float, Long, Double, Class, String, Fieldref, Methodref, InterfaceMethodref, NameAndType, MethodHandle, MethodType, Dynamic, InvokeDynamic, Module, Package); any other value indicates a malformed or unsupported class file. This is a fail-fast guard against silently mis-parsing corrupted input.","triggerScenarios":"Parsing a class file whose constant pool contains a tag byte outside the recognized set, e.g. a truncated, corrupted, or deliberately fuzzed .class file, a file from a newer JVM using a tag this parser doesn't implement, or a non-class file that is not validated by magic-number/header checks before reaching the parser.","commonSituations":"Fuzzing or security-testing bytecode tooling; processing class files compiled by a much newer JDK than the parser supports; accidentally passing a jar/zip or renamed text file to the class parser; corrupted downloads or partial writes of .class files.","solutions":["Verify the input is a genuine class file (magic 0xCAFEBABE) before parsing.","Check the class file's major version and use a parser/jvm version that supports that constant pool format.","Re-obtain or re-download the class file; if it is corrupted, regenerate it from source.","If you maintain the parser, add a case for the unknown tag or convert the throw into a skip/log for resilience."],"exampleFix":"// before\nif (!isClassFile(bytes)) parse(bytes); // throws deep in parser\n// after\nif (readMagic(bytes) != 0xCAFEBABE) { throw new InvalidClassFileException(\"not a class file\"); }\nparse(bytes);","handlingStrategy":"try-catch","validationCode":"// check magic number + major version before parsing\nif (bytes.length < 8 || (bytes[0]&0xFF)!=0xCA||(bytes[1]&0xFF)!=0xFE||(bytes[2]&0xFF)!=0xBA||(bytes[3]&0xFF)!=0xBE)\n    throw new IllegalArgumentException(\"not a class file\");","typeGuard":"boolean isKnownCpTag(int tag) {\n    return (tag >= 1 && tag <= 15) || tag == 16 || tag == 17 || tag == 18 || tag == 19 || tag == 20;\n}","tryCatchPattern":"try { parser.parseConstantPool(buffer); }\ncatch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unknown constant pool tag\")) {\n        log.warn(\"unrecognized/unsupported class file: \" + e.getMessage());\n    } else throw e;\n}","preventionTips":["Validate CAFEBABE magic and class-file major version before parsing","Never feed non-class files (jars, text) directly to the class parser","Keep parser support current with JVM constant-pool tag additions","Treat unparseable input as data corruption: log, quarantine, and continue"],"tags":["java","class-parsing","malformed-input"],"backgroundTag":"unknown-constant-pool-tag","analyzedSha":"31430e0033fa220db566b5ef461256727ff6793b","analyzedAt":"2026-09-05T18:22:22.725Z","contentChangedAt":"2026-09-05T18:22:22.725Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}