oracle/graal · error · UnsupportedOperationException

access mode: {}

Error message

access mode: {}

What it means

Thrown by TruffleFileSystemProvider.accessModesToMask when an AccessMode passed to checkAccess is not READ, WRITE, or EXECUTE. AccessMode is an enum with exactly those three constants, so hitting this means a custom AccessMode-like value or a version skew between the host list and the guest-side Target_*_TruffleFileSystemProvider#SUPPORTED_ACCESS_MODES it must stay in sync with.

Source

Thrown at espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/fs/TruffleFileSystemProvider.java:280

    }

    @Override
    public FileStore getFileStore(Path path) {
        return new TruffleFileStore(path);
    }

    // Keep in sync with Target_*_TruffleFileSystemProvider#SUPPORTED_ACCESS_MODES.
    private static final List<AccessMode> SUPPORTED_ACCESS_MODES = List.of(
                    AccessMode.READ,
                    AccessMode.WRITE,
                    AccessMode.EXECUTE);

    private static int accessModesToMask(AccessMode... modes) {
        int mask = 0;
        for (AccessMode mode : modes) {
            int index = SUPPORTED_ACCESS_MODES.indexOf(mode);
            if (index < 0) {
                throw new UnsupportedOperationException("access mode: " + mode);
            }
            mask |= 1 << index;
        }
        return mask;
    }

    @Override
    public void checkAccess(Path path, AccessMode... modes) throws IOException {
        checkAccess0(TrufflePath.toTrufflePath(path), accessModesToMask(modes));
    }

    @Override
    @SuppressWarnings("unchecked")
    public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
        Objects.requireNonNull(type);
        if (type != BasicFileAttributeView.class) {
            throw new UnsupportedOperationException();
        }

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Use only AccessMode.READ, AccessMode.WRITE, AccessMode.EXECUTE
  2. Ensure the Espresso guest and host builds match (the SUPPORTED_ACCESS_MODES lists must stay in sync)
  3. Check the guest classpath for shadowed/patched java.nio classes

Example fix

// before (hypothetical patched enum value)
provider.checkAccess(path, AccessMode.READ, customMode);

// after
provider.checkAccess(path, AccessMode.READ, AccessMode.WRITE);
Defensive patterns

Strategy: validation

Validate before calling

for (AccessMode m : modes) {
    if (!(m == AccessMode.READ || m == AccessMode.WRITE || m == AccessMode.EXECUTE)) {
        throw new UnsupportedOperationException("access mode: " + m);
    }
}

Prevention

When it happens

Trigger: Files.isReadable/isWritable/isExecutable never trigger it (they pass single constants); it fires only if a caller supplies a non-enum AccessMode from a recompiled/patched java.nio or a mismatched Espresso build where the host and guest lists diverge.

Common situations: Running a guest JDK whose java.nio.fs was modified or built from a different source, or class-path shadowing of java.nio.file.AccessMode; mixing Espresso component versions.

Related errors


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