oracle/graal · error · IllegalArgumentException

Source should be a primitive array, got

Error message

Source should be a primitive array, got 

What it means

Error "Source should be a primitive array, 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:1027

        }
        long size = bytes.getBufferSize();
        byte[] result = new byte[Math.toIntExact(size)];
        bytes.readBuffer(0, result, 0, result.length);
        return result;
    }

    public boolean hasAnnotations(Value metaObject) {
        return invokeJVMCIHelper("hasAnnotations", metaObject).asBoolean();
    }

    @Override
    public void copyMemory(JavaConstant src, int srcFrom, int srcTo, byte[] dst, int dstFrom) {
        if (!(src instanceof EspressoExternalObjectConstant objectConstant)) {
            throw new IllegalArgumentException("Expected an EspressoExternalObjectConstant, got " + safeGetClass(src));
        }
        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)) {

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Fix the condition reported by the error: Source should be a primitive array, 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: Source should be a primitive array, got

When it happens

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

Common situations: Occurs when a caller violates the contract guarded by this check: Source should be a primitive array, got


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