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
- Use a random-access source (file-based DataSource, e.g. the reader opened from a File) instead of StreamSource when the parser needs marks
- Buffer the whole stream into a byte[] and re-create a source over it if the input is not a file
- 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
- Open graph readers from File/random-access sources when re-parsing is required
- Buffer non-file streams fully before parsing
- Feature-detect DataSource capabilities before using getMark
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
- Expecting
- Error loading phase plan from %s
- Could not connect to the IGV on %s:%d
- Error archiving %s. This directory will not be deleted and m
- Error deleting %s. This is most likely due to a compilation
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/3abe169585b9fdb0.
Report an issue: GitHub.