oracle/graal · error · GraalError
Unexpected constant pool tag %s
Error message
Unexpected constant pool tag %s
What it means
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.
Source
Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/classfile/ClassfileConstantPool.java:252
public Object lookupConstant(int index) {
return lookupConstant(index, true);
}
@Override
public Object lookupConstant(int index, boolean resolve) {
ClassfileConstant c = entries[index];
if (c instanceof Primitive) {
Primitive p = (Primitive) c;
return p.value;
}
switch (c.tag) {
case CONSTANT_Class:
final int opcode = -1;
return lookupType(index, opcode);
case ClassfileConstant.CONSTANT_String:
return ((ClassfileConstant.StringRef) c).getValue(this);
default:
throw new GraalError("Unexpected constant pool tag %s", c.tag);
}
}
@Override
public JavaConstant lookupAppendix(int index, int opcode) {
if (opcode == Bytecodes.INVOKEVIRTUAL) {
return null;
}
throw GraalError.shouldNotReachHereUnexpectedValue(opcode); // ExcludeFromJacocoGeneratedReport
}
}
View on GitHub (pinned to a66e9ccd1d)
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).
Defensive patterns
Strategy: validation
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Snippet code that references MethodType/MethodHandle constants or other condy-bearing constructs; same root cause family as the INVOKEDYNAMIC errors of this provider.
Related errors
- Resolution of %s constant pool entries not supported by %s
- too many arguments
- Too deep inlining, probably caused by recursive inlining.
- Could not find method in %s named %s
- Can't store into VarargsParameter array
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/7b3538d21b3f18ef.
Report an issue: GitHub.