{"record":{"id":"7b3538d21b3f18ef","repo":"oracle/graal","slug":"unexpected-constant-pool-tag-s","errorCode":null,"errorMessage":"Unexpected constant pool tag %s","messagePattern":"Unexpected constant pool tag (.+?)","errorType":"exception","errorClass":"GraalError","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/classfile/ClassfileConstantPool.java","lineNumber":252,"sourceCode":"    public Object lookupConstant(int index) {\n        return lookupConstant(index, true);\n    }\n\n    @Override\n    public Object lookupConstant(int index, boolean resolve) {\n        ClassfileConstant c = entries[index];\n        if (c instanceof Primitive) {\n            Primitive p = (Primitive) c;\n            return p.value;\n        }\n        switch (c.tag) {\n            case CONSTANT_Class:\n                final int opcode = -1;\n                return lookupType(index, opcode);\n            case ClassfileConstant.CONSTANT_String:\n                return ((ClassfileConstant.StringRef) c).getValue(this);\n            default:\n                throw new GraalError(\"Unexpected constant pool tag %s\", c.tag);\n        }\n    }\n\n    @Override\n    public JavaConstant lookupAppendix(int index, int opcode) {\n        if (opcode == Bytecodes.INVOKEVIRTUAL) {\n            return null;\n        }\n        throw GraalError.shouldNotReachHereUnexpectedValue(opcode); // ExcludeFromJacocoGeneratedReport\n    }\n}\n","sourceCodeStart":234,"sourceCodeEnd":264,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/classfile/ClassfileConstantPool.java#L234-L264","documentation":"lookupConstant (the ldc equivalent of this constant-pool implementation) only knows how to materialize primitive constants, CONSTANT_Class, and CONSTANT_String. Any other tag reaching the switch hits default and GraalError('Unexpected constant pool tag') is thrown.","triggerScenarios":"A class parsed by ClassfileBytecodeProvider executes ldc of a constant whose pool entry is a MethodType, MethodHandle, or Dynamic entry (condy), e.g. from lambda desugaring or explicit MethodType constants.","commonSituations":"Snippet code that references MethodType/MethodHandle constants or other condy-bearing constructs; same root cause family as the INVOKEDYNAMIC errors of this provider.","solutions":["Remove ldc of MethodType/MethodHandle/condy constants from code parsed as snippets.","If the constant snuck in via compilation of a lambda or bootstrap-linked construct, rewrite that code in plain form (anonymous class / direct calls)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not ldc MethodType/MethodHandle constants in snippet code.","Run javap -v on snippet classes in CI and fail on CONSTANT_MethodHandle / CONSTANT_MethodType / CONSTANT_Dynamic entries."],"tags":["graal","constant-pool","ldc","snippet","condy"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}