oracle/graal · error · UnsupportedOperationException

getMark

Error message

getMark

What it means

StreamSource is a streaming (non-seekable) DataSource over a DataInputStream and cannot report a position/mark in the input. getMark() is part of the DataSource interface (needed by random-access sources) but is deliberately unimplemented here; any reader that calls it to resume or re-read a graph dump fails immediately.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/StreamSource.java:144

            return null;
        }
        return readBytes(len);
    }

    @Override
    public byte[] readBytes(int len) throws IOException {
        return readBytes(new byte[len], len);
    }

    @Override
    public byte[] readBytes(byte[] b, int len) throws IOException {
        in.readFully(b, 0, len);
        return b;
    }

    @Override
    public long getMark() {
        throw new UnsupportedOperationException("getMark");
    }

    private void setVersion(int newMajorVersion, int newMinorVersion) throws IOException {
        if (newMajorVersion > CURRENT_MAJOR_VERSION || (newMajorVersion == CURRENT_MAJOR_VERSION && newMinorVersion > CURRENT_MINOR_VERSION)) {
            throw new VersionMismatchException("File format version " + versionPair(newMajorVersion, newMinorVersion) + " unsupported.  Current version is " + CURRENT_VERSION);
        }
        majorVersion = newMajorVersion;
        minorVersion = newMinorVersion;
    }

    @Override
    public int getMajorVersion() {
        return majorVersion;
    }

    public int getMinorVersion() {
        return minorVersion;
    }

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Use a random-access source (file-based DataSource, e.g. the reader opened from a File) instead of StreamSource when the parser needs marks
  2. Buffer the whole stream into a byte[] and re-create a source over it if the input is not a file
  3. If you own the reader logic, avoid getMark()-dependent re-parse paths for stream inputs

Example fix

// before
DataSource src = new StreamSource(socket.getInputStream());
long mark = src.getMark(); // UnsupportedOperationException

// after
Path tmp = Files.createTempFile("graph", ".bgv");
try (InputStream in = socket.getInputStream()) {
    Files.copy(in, tmp, StandardCopyOption.REPLACE_EXISTING);
}
DataSource src = new FileSource(tmp.toFile()); // supports getMark
Defensive patterns

Strategy: try-catch

Validate before calling

boolean supportsMarks(DataSource src) { return !(src instanceof jdk.graal.compiler.graphio.parsing.StreamSource); }

Try / catch

try { long m = src.getMark(); } catch (UnsupportedOperationException e) { /* fall back to non-seekable parsing or re-open from a file */ }

Prevention

When it happens

Trigger: Calling DataSource.getMark() on an instance of StreamSource (e.g. a GraphReader constructed over a plain InputStream instead of a File or RandomAccessFile-based source), then attempting to seek back or re-parse a group at a recorded mark.

Common situations: Pointing the graph reader (IdealGraphParser/GraphReader) at System.in, a socket, a gzipped stream, or any InputStream rather than a file path; tools that re-read earlier graph groups.

Related errors


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