oracle/graal · error · IllegalArgumentException

Expected a non-void primitive kind, got

Error message

Expected a non-void primitive kind, got 

What it means

Error "Expected a non-void primitive kind, got " thrown in oracle/graal.

Source

Thrown at espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalVMAccess.java:1043

        EspressoResolvedObjectType arrayType = objectConstant.getType();
        if (!(arrayType.isArray() && arrayType.getComponentType().isPrimitive())) {
            throw new IllegalArgumentException("Source should be a primitive array, got " + arrayType);
        }
        try {
            objectConstant.getValue().readBuffer(srcFrom, dst, dstFrom, srcTo - srcFrom);
        } catch (IndexOutOfBoundsException e) {
            throw new IllegalArgumentException("Failed to copy into " + src, e);
        }
    }

    /**
     * The value is decoded directly from Espresso interop buffer access using native endianness to
     * match hosted unaligned read semantics.
     */
    @Override
    public JavaConstant readPrimitiveArrayUnaligned(JavaConstant array, JavaKind kind, int offset) {
        if (kind == null || !kind.isPrimitive() || kind == JavaKind.Void) {
            throw new IllegalArgumentException("Expected a non-void primitive kind, got " + kind);
        }
        if (!(array instanceof EspressoExternalObjectConstant objectConstant)) {
            throw new IllegalArgumentException("Expected an EspressoExternalObjectConstant, got " + safeGetClass(array));
        }
        EspressoResolvedObjectType arrayType = objectConstant.getType();
        if (!(arrayType.isArray() && arrayType.getComponentType().isPrimitive())) {
            throw new IllegalArgumentException("Source should be a primitive array, got " + arrayType);
        }
        Value value = objectConstant.getValue();
        long byteLength = value.getBufferSize();
        int bytesToRead = kind.getByteCount();
        if (offset < 0 || (long) offset + bytesToRead > byteLength) {
            throw new IllegalArgumentException("Invalid input range: " + offset + ".." + (offset + bytesToRead) + " for buffer size " + byteLength);
        }
        return switch (kind) {
            case Boolean -> JavaConstant.forBoolean(value.readBufferByte(offset) != 0);
            case Byte -> JavaConstant.forByte(value.readBufferByte(offset));
            case Short -> JavaConstant.forShort(value.readBufferShort(ByteOrder.nativeOrder(), offset));

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Fix the condition reported by the error: Expected a non-void primitive kind, got
  2. Check the throwing call site and ensure its documented preconditions (argument values, types, environment, or configuration) are satisfied before the call.

Example fix

Validate inputs and environment so that the failing condition does not occur: Expected a non-void primitive kind, got

When it happens

Trigger: Thrown at espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalVMAccess.java:1043 when the library encounters an invalid state.

Common situations: Occurs when a caller violates the contract guarded by this check: Expected a non-void primitive kind, got


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/93cc6d360baa351b. Report an issue: GitHub.