From 0833286475faa504a844f53773e5309705fe33d6 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Thu, 6 Nov 2025 17:33:45 +0100 Subject: [PATCH 1/4] Expose ByteBufferDataInput and its position --- .../api/bytecode/serialization/ByteBufferDataInput.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.java b/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.java index 4dacbd313382..f15193d1c4d4 100644 --- a/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.java +++ b/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.java @@ -53,7 +53,7 @@ * @see SerializationUtils#createDataInput(ByteBuffer) * @since 24.2 */ -final class ByteBufferDataInput implements DataInput { +public final class ByteBufferDataInput implements DataInput { private final ByteBuffer buffer; private char[] lineBuffer; @@ -237,4 +237,11 @@ public String readLine() throws IOException { public String readUTF() throws IOException { return DataInputStream.readUTF(this); } + + /** + * Returns the position in the underlying byte buffer. + */ + public int position() { + return buffer.position(); + } } From 787189b342d999de20fadfc43df82a937be29b16 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Thu, 6 Nov 2025 17:33:55 +0100 Subject: [PATCH 2/4] Fix ByteBufferDataInput.skipBytes --- .../truffle/api/bytecode/serialization/ByteBufferDataInput.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.java b/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.java index f15193d1c4d4..fa6eaee94dd9 100644 --- a/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.java +++ b/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.java @@ -84,7 +84,7 @@ public void readFully(byte[] b, int off, int len) throws IOException { @Override public int skipBytes(int n) throws IOException { - int skip = buffer.remaining() > n ? buffer.remaining() : n; + int skip = buffer.remaining() < n ? buffer.remaining() : n; buffer.position(buffer.position() + skip); return skip; } From 2bb0a0f4be26f8f77fe447aa29384c1dcc88dcdb Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Fri, 7 Nov 2025 09:42:21 +0100 Subject: [PATCH 3/4] Update API signatures --- .../snapshot.sigtest | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/truffle/src/com.oracle.truffle.api.bytecode/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.bytecode/snapshot.sigtest index e182a77bc20f..4515916d84b4 100644 --- a/truffle/src/com.oracle.truffle.api.bytecode/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.bytecode/snapshot.sigtest @@ -802,6 +802,28 @@ meth public com.oracle.truffle.api.bytecode.debug.PrintInstructionTracer$Builder supr java.lang.Object hfds filter,out +CLSS public final com.oracle.truffle.api.bytecode.serialization.ByteBufferDataInput +intf java.io.DataInput +meth public boolean readBoolean() throws java.io.IOException +meth public byte readByte() throws java.io.IOException +meth public char readChar() throws java.io.IOException +meth public double readDouble() throws java.io.IOException +meth public float readFloat() throws java.io.IOException +meth public int position() +meth public int readInt() throws java.io.IOException +meth public int readUnsignedByte() throws java.io.IOException +meth public int readUnsignedShort() throws java.io.IOException +meth public int skipBytes(int) throws java.io.IOException +meth public java.lang.String readLine() throws java.io.IOException + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") +meth public java.lang.String readUTF() throws java.io.IOException +meth public long readLong() throws java.io.IOException +meth public short readShort() throws java.io.IOException +meth public void readFully(byte[]) throws java.io.IOException +meth public void readFully(byte[],int,int) throws java.io.IOException +supr java.lang.Object +hfds buffer,lineBuffer + CLSS public abstract interface com.oracle.truffle.api.bytecode.serialization.BytecodeDeserializer anno 0 java.lang.FunctionalInterface() innr public abstract interface static DeserializerContext @@ -986,6 +1008,23 @@ hcls Constant CLSS public abstract interface com.oracle.truffle.api.nodes.UnadoptableNode +CLSS public abstract interface java.io.DataInput +meth public abstract boolean readBoolean() throws java.io.IOException +meth public abstract byte readByte() throws java.io.IOException +meth public abstract char readChar() throws java.io.IOException +meth public abstract double readDouble() throws java.io.IOException +meth public abstract float readFloat() throws java.io.IOException +meth public abstract int readInt() throws java.io.IOException +meth public abstract int readUnsignedByte() throws java.io.IOException +meth public abstract int readUnsignedShort() throws java.io.IOException +meth public abstract int skipBytes(int) throws java.io.IOException +meth public abstract java.lang.String readLine() throws java.io.IOException +meth public abstract java.lang.String readUTF() throws java.io.IOException +meth public abstract long readLong() throws java.io.IOException +meth public abstract short readShort() throws java.io.IOException +meth public abstract void readFully(byte[]) throws java.io.IOException +meth public abstract void readFully(byte[],int,int) throws java.io.IOException + CLSS public abstract interface java.io.Serializable CLSS public abstract interface java.lang.Cloneable From 90d295a84ead92d8f76eedabe5661a1f531de13d Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Fri, 7 Nov 2025 09:43:45 +0100 Subject: [PATCH 4/4] Add changelog entry --- truffle/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/truffle/CHANGELOG.md b/truffle/CHANGELOG.md index 1bab0733a35b..097573eb4932 100644 --- a/truffle/CHANGELOG.md +++ b/truffle/CHANGELOG.md @@ -37,6 +37,7 @@ This changelog summarizes major changes between Truffle versions relevant to lan * GR-70086: Added `replacementOf` and `replacementMethod` attributes to `GenerateLibrary.Abstract` annotation. They enable automatic generation of legacy delegators during message library evolution, while allowing custom conversions when needed. * GR-70086 Deprecated `Message.resolve(Class, String)`. Use `Message.resolveExact(Class, String, Class...)` with argument types instead. This deprecation was necessary as library messages are no longer unique by message name, if the previous message was deprecated. +* GR-71245: Exposed `ByteBufferDataInput` as public and added a `position` method that returns the underlying buffer's position. ## Version 25.0