oracle/graal · error · ParserException.ClassFormatError
Array type with more than 255 dimensions
Error message
Array type with more than 255 dimensions
What it means
Espresso's TypeSymbols.arrayOf(Symbol<Type>, int) constructs an array type descriptor by prepending 'dimensions' '[' bytes to the component descriptor. The JVM class file format caps array types at 255 dimensions, so the factory throws ParserException.ClassFormatError when the component's existing dimension count plus the requested dimensions exceeds 255.
Source
Thrown at espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/descriptors/TypeSymbols.java:260
}
}
throw new ParserException.ClassFormatError("Invalid type descriptor " + descriptor.subSequence(beginIndex));
}
/**
* Gets the type descriptor for the specified component type descriptor with the specified
* number of dimensions. For example if the number of dimensions is 1, then this method will
* return a descriptor for an array of the component type; if the number of dimensions is 2, it
* will return a descriptor for an array of an array of the component type, etc.
*
* @param type the type descriptor for the component type of the array
* @param dimensions the number of array dimensions
* @return the canonical type descriptor for the specified component type and dimensions
*/
public Symbol<Type> arrayOf(Symbol<Type> type, int dimensions) {
assert dimensions > 0;
if (TypeSymbols.getArrayDimensions(type) + dimensions > 255) {
throw new ParserException.ClassFormatError("Array type with more than 255 dimensions");
}
// Prepend #dimensions '[' to type descriptor.
byte[] bytes = new byte[type.length() + dimensions];
Arrays.fill(bytes, 0, dimensions, (byte) '[');
type.writeTo(bytes, dimensions);
return symbols.getOrCreate(ByteSequence.wrap(bytes));
}
public Symbol<Type> arrayOf(Symbol<Type> type) {
return arrayOf(type, 1);
}
private static int skipClassName(Symbol<? extends Descriptor> descriptor, int from, final char separator) throws ParserException.ClassFormatError {
assert separator == '.' || separator == '/';
int index = from;
final int length = descriptor.length();
while (index < length) {
// Safe cast, method returns only for ./;[ characters.View on GitHub (pinned to a66e9ccd1d)
Solutions
- If you generate descriptors in a loop, track dimensions and stop/cap at 255 before calling arrayOf.
- If the error comes from loading a class, inspect the offending descriptor in the class file and fix the producer of that class.
- Validate third-party/generated class files (e.g. with a verifier like ASM CheckClassAdapter) before feeding them to Espresso.
Example fix
// before
Symbol<Type> t = type;
for (int i = 0; i < 300; i++) { t = symbols.arrayOf(t); } // throws at 256th iteration
// after
Symbol<Type> t = type;
for (int i = 0; i < 300 && TypeSymbols.getArrayDimensions(t) < 255; i++) { t = symbols.arrayOf(t); } Defensive patterns
Strategy: validation
Validate before calling
static int dimsOf(Symbol<Type> t) { return TypeSymbols.getArrayDimensions(t); }
static boolean canAddDimensions(Symbol<Type> t, int n) {
return n > 0 && dimsOf(t) + n <= 255;
} Prevention
- Track dimension count in any loop that calls arrayOf and cap it at 255.
- Verify generated class files with a descriptor-aware checker before loading them into Espresso.
- Treat descriptors with 200+ '[' as hostile input in fuzzing/test harnesses.
When it happens
Trigger: Calling arrayOf(type, n) where TypeSymbols.getArrayDimensions(type) + n > 255, e.g. arrayOf(inner, 256) or arrayOf(existing200DimArray, 60). Also reached when parsing/loading a class whose descriptor string contains more than 255 consecutive '[' characters.
Common situations: Bytecode generators or class-file manipulators running on Espresso that build nested array descriptors in a loop; fuzzed or hostile class files; tests probing JVM array limits.
Related errors
- Array with more than 255 dimensions {}
- unknown primitive or void type character:
- invalid descriptor: {}
- invalid type descriptor: {}
- Invalid Java name {}
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/8e46a98fb92e901f.
Report an issue: GitHub.