oracle/graal · info · IllegalArgumentException
Unsupported kind: {}
Error message
Unsupported kind: {} What it means
The final default arm of the JavaKind switch in readPrimitiveArrayUnaligned's Unsafe read. Because line 512 already rejected null/non-primitive/void kinds, every remaining primitive kind (Boolean..Double) has a case, so this 'Unsupported kind' IllegalArgumentException is defensively unreachable in normal use. Seeing it means the kind validation and the read switch have drifted apart (e.g. a new JavaKind value added to the enum, or validation was bypassed/changed).
Source
Thrown at compiler/src/jdk.graal.compiler.hostvmaccess/src/jdk/graal/compiler/hostvmaccess/HostVMAccess.java:543
if (offset < 0 || (long) offset + bytesToRead > sourceArrayEnd) {
throw new IllegalArgumentException(
"Invalid input range: " + offset + ".." + (offset + bytesToRead) + " for array of length " + Array.getLength(array) + " with kind " +
arrayType.getComponentType().getJavaKind());
}
Unsafe unsafe = Unsafe.getUnsafe();
long baseOffset = unsafe.arrayBaseOffset(array.getClass());
long absoluteOffset = baseOffset + offset;
return switch (kind) {
case Boolean -> JavaConstant.forBoolean(unsafe.getByte(array, absoluteOffset) != 0);
case Byte -> JavaConstant.forByte(unsafe.getByte(array, absoluteOffset));
case Short -> JavaConstant.forShort(unsafe.getShort(array, absoluteOffset));
case Char -> JavaConstant.forChar(unsafe.getChar(array, absoluteOffset));
case Int -> JavaConstant.forInt(unsafe.getInt(array, absoluteOffset));
case Long -> JavaConstant.forLong(unsafe.getLong(array, absoluteOffset));
case Float -> JavaConstant.forFloat(unsafe.getFloat(array, absoluteOffset));
case Double -> JavaConstant.forDouble(unsafe.getDouble(array, absoluteOffset));
default -> throw new IllegalArgumentException("Unsupported kind: " + kind);
};
}
@Override
public JavaConstant createHostProxy(Object hostTarget, ResolvedJavaType guestType) {
Objects.requireNonNull(hostTarget);
Class<?> guestClass = providers.getSnippetReflection().originalClass(Objects.requireNonNull(guestType));
if (guestClass == null || !guestClass.isInterface()) {
throw new IllegalArgumentException("Invalid guest type");
}
/* There is no fast-path for guestClass == hostClass due to exception handling */
HostProxyHandler handler = new HostProxyHandler(hostTarget, getHostProxyMethodMap(hostTarget.getClass(), guestClass));
Object guestHostProxy = Proxy.newProxyInstance(guestClass.getClassLoader(), new Class<?>[]{guestClass}, handler);
return providers.getSnippetReflection().forObject(guestHostProxy);
}
@Override
public Throwable unwrapHostProxyException(JavaConstant guestWrapper) {View on GitHub (pinned to a66e9ccd1d)
Solutions
- If hit after a JDK/JVMCI upgrade, add the missing kind case to the switch (or extend the front guard to exclude it)
- Check for local patches that weakened the kind check at the top of readPrimitiveArrayUnaligned
- Report upstream — as shipped, this branch indicates an internal inconsistency, not caller error
Example fix
// before (JVMCI adds JavaKind.Float16, isPrimitive()==true) // switch lacks a case -> 'Unsupported kind: Float16' // after case Float16 -> JavaConstant.forShort(unsafe.getShort(array, absoluteOffset)); // decode as needed
Defensive patterns
Strategy: try-catch
Try / catch
catch (IllegalArgumentException e) { if ("Unsupported kind".equals(prefix of message)) { log kind value and Graal/JVMCI versions; this signals version drift, report upstream; } } Prevention
- Pin jdk.vm.ci and Graal versions together when upgrading the JDK
- Run the hostvmaccess unit tests after any JVMCI upgrade
- Treat this message as an internal invariant failure, not a caller bug
When it happens
Trigger: A future JavaKind constant that isPrimitive() returns true for but has no case in the switch; or a subclass/patched variant where the guard at line 512 is relaxed. Not reachable via the public API as currently written.
Common situations: After upgrading the JDK/jdk.vm.ci where JavaKind gains a value; local forks of Graal that modify the kind validation.
Related errors
- Element {} should be a {}, got {}
- Element {} should be an object, got {}
- Expected an array constant, got {}
- Could not unwrap array: {}
- No original class for type {}
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/ad1bdb7f1e8e3861.
Report an issue: GitHub.