oracle/graal · error · UnsupportedOperationException

getAttribute is not supported.

Error message

getAttribute is not supported.

What it means

TruffleFileStore implements only space/read-only queries natively (totalSpace0, getUsableSpace0, getUnallocatedSpace0, isReadOnly0) and no file-store attribute views; FileStore.getAttribute therefore always throws UnsupportedOperationException. This is a declared capability gap of Espresso's Truffle NIO provider, mirroring a minimal FileStore.

Source

Thrown at espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/fs/TruffleFileStore.java:88

    @Override
    public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
        return type == BasicFileAttributeView.class;
    }

    @Override
    public boolean supportsFileAttributeView(String name) {
        return "basic".equals(name);
    }

    @Override
    public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> type) {
        return null;
    }

    @Override
    public Object getAttribute(String attribute) throws IOException {
        throw new UnsupportedOperationException("getAttribute is not supported.");
    }

    private static native boolean isReadOnly0(TrufflePath path);

    private static native long totalSpace0(TrufflePath path);

    private static native long getUsableSpace0(TrufflePath path);

    private static native long getUnallocatedSpace0(TrufflePath path);
}

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Use FileStore.getTotalSpace()/getUsableSpace()/getUnallocatedSpace()/isReadOnly() methods directly instead of getAttribute(String).
  2. Branch on the provider (scheme/name) and skip attribute queries for the Truffle FS.
  3. For host-accurate values, perform the query in host code and pass results into the guest.

Example fix

// before
long total = (long) Files.getFileStore(p).getAttribute("totalSpace"); // throws

// after
long total = Files.getFileStore(p).getTotalSpace();
Defensive patterns

Strategy: fallback

Validate before calling

FileStore fs = Files.getFileStore(p);
if (!"getAttribute is supported".isEmpty()) { /* never call fs.getAttribute; use typed getters */ }
long total = fs.getTotalSpace();

Try / catch

try {
    Object v = fs.getAttribute(name);
} catch (UnsupportedOperationException e) {
    // fall back to typed getters: getTotalSpace()/getUsableSpace()/isReadOnly()
}

Prevention

When it happens

Trigger: Guest code calling Files.getFileStore(path).getAttribute("totalSpace") or any attribute name; requesting a FileStoreAttributeView via getFileStoreAttributeView (returns null, then NPE/UsageError downstream).

Common situations: Monitoring/diagnostic libraries (disk usage checks, quota tools) that call FileStore.getAttribute; portable code that works on the default provider but runs on the Truffle provider under Espresso.

Related errors


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