{"record":{"id":"7eea98336026f7a2","repo":"oracle/graal","slug":"unexpected-tag-tag","errorCode":null,"errorMessage":"Unexpected tag: ${tag}","messagePattern":"Unexpected tag: (.+?)","errorType":"exception","errorClass":"ParserException.ClassFormatError","httpStatus":null,"severity":"error","filePath":"espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/ConstantPoolPatcher.java","lineNumber":106,"sourceCode":"                    stream.readS4();\n                    break;\n                case FLOAT:\n                    stream.readFloat();\n                    break;\n                case LONG:\n                    stream.readS8();\n                    ++i;\n                    break;\n                case DOUBLE:\n                    stream.readDouble();\n                    ++i;\n                    break;\n                case METHODHANDLE:\n                    stream.readU1();\n                    stream.readU2();\n                    break;\n                default:\n                    throw new ParserException.ClassFormatError(\"Unexpected tag: \" + tag);\n            }\n            i++;\n        }\n    }\n\n    private static boolean isDirectAnonymousInnerClass(ByteSequence outer, ByteSequence inner) {\n        if (!inner.contentStartsWith(outer) || inner.length() < outer.length() + 2) {\n            return false;\n        }\n        int i = outer.length();\n        if (inner.byteAt(i++) != '$') {\n            return false;\n        }\n        do {\n            if (!isDecimalDigit(inner.byteAt(i++))) {\n                return false;\n            }\n        } while (i < inner.length());","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/ConstantPoolPatcher.java#L88-L124","documentation":"A ClassFormatError (ParserException) thrown while walking a constant pool during ConstantPoolPatcher's first pass: an entry whose tag byte does not match any known JVM constant tag (Utf8, Integer, Long, Float, Double, Class, String, ... MethodHandle) hits the default branch. The pool bytes are structurally corrupt, so the class file is rejected as malformed.","triggerScenarios":"Loading a class whose constant pool contains an unknown/reserved tag byte (not 1-15 or 17-19); truncated or shifted pool data so the parser reads a non-tag byte as a tag; a class file corrupted on disk, in a jar, or by an earlier patching step that desynchronized the pool offsets.","commonSituations":"Corrupted jar/agent instrumentation that rewrites constant pools incorrectly; class files produced by broken bytecode tools or modified by an outdated patcher; truncated downloads; classes from a newer class-file version using tags this parser predates.","solutions":["Verify the class file with a standard tool (javap -v, or a JVM load of the same class) — if it also fails, the class is genuinely corrupt.","Rebuild/re-download the jar or regenerate the class with a recent, compatible bytecode tool.","If agent-based patching is involved, disable it and re-test to see whether the patcher mangles the pool.","Check the class file major version is supported by this Espresso version."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before loading untrusted class bytes\nbyte[] bytes = ...;\nif (bytes.length < 10 || bytes[6] > SUPPORTED_MAJOR_VERSION) {\n    throw new ClassFormatException(\"suspicious class file\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    context.getEnv().parseClass(bytes);\n} catch (ParserException.ClassFormatError e) {\n    // reject the input; log the offending resource so the corrupt artifact can be replaced\n}","preventionTips":["Validate class-file checksums/signatures when loading untrusted classes.","Keep bytecode-generation tools (ASM etc.) updated and version-compatible with the guest classes.","Do not run two class transformers that both rewrite constant pools on the same classes."],"tags":["class-format","classfile-parsing","constant-pool","espresso"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}