Top Description Inners Fields Constructors Methods
org.graalvm.nativebridge

public abstract Class BinaryInput

extends Object
Class Inheritance
Known Direct Subclasses
org.graalvm.nativebridge.BinaryInput.ByteArrayBinaryInput, org.graalvm.nativebridge.BinaryInput.CCharPointerInput
Imports
org.graalvm.nativeimage.c.type.CCharPointer, .CTypeConversion, java.nio.ByteBuffer, .ByteOrder

A buffer used by the BinaryMarshaller to unmarshal parameters and results passed by value.
See Also
BinaryOutput, BinaryMarshaller, JNIConfig.Builder#registerMarshaller(Class, BinaryMarshaller)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final int
protected final int
protected int
private byte[]
private char[]

Constructor Summary

AccessConstructor and Description
private
BinaryInput(int length)

Method Summary

Modifier and TypeMethod and Description
public abstract ByteBuffer
asByteBuffer(int len)

Returns a read only ByteBuffer backed by the BinaryInput internal buffer.

public static BinaryInput
create(byte[] buffer)

Creates a new buffer backed by a byte array.

public static BinaryInput
create(byte[] buffer, int length)

Creates a new buffer backed by a byte array only up to a given length.

public static BinaryInput
create(CCharPointer address, int length)

Creates a new buffer wrapping an off-heap memory segment starting at an address having length bytes.

private void
private static char
packChar(int b1, int b2)

Creates a Java char from given unsigned bytes, where b1 is the most significant byte byte and b2 is the least significant byte.

private static int
packInt(int b1, int b2, int b3, int b4)

Creates a Java int from given unsigned bytes, where b1 is the most significant byte byte and b4 is the least significant byte.

private static long
packLong(int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8)

Creates a Java long from given unsigned bytes, where b1 is the most significant byte byte and b8 is the least significant byte.

private static short
packShort(int b1, int b2)

Creates a Java short from given unsigned bytes, where b1 is the most significant byte byte and b2 is the least significant byte.

public abstract int
read()

Reads a single byte.

public abstract void
read(byte[] b, int off, int len)

Reads len bytes into a byte array starting at offset off.

public final void
read(boolean[] b, int off, int len)

Reads len bytes into a boolean array starting at offset off.

public final void
read(short[] b, int off, int len)

Reads len shorts into a short array starting at offset off.

public final void
read(char[] b, int off, int len)

Reads len chars into a char array starting at offset off.

public final void
read(int[] b, int off, int len)

Reads len ints into an int array starting at offset off.

public final void
read(long[] b, int off, int len)

Reads len longs into a long array starting at offset off.

public final void
read(float[] b, int off, int len)

Reads len floats into a float array starting at offset off.

public final void
read(double[] b, int off, int len)

Reads len doubles into a double array starting at offset off.

public final boolean
readBoolean()

Reads a single byte and returns true if that byte is non-zero, false if that byte is zero.

public final byte
readByte()

Reads and returns a single byte.

public final char
readChar()

Reads two bytes and returns a char value.

public final double
readDouble()

Reads eight bytes and returns a double value.

public final float
readFloat()

Reads four bytes and returns a float value.

public final int
readInt()

Reads four bytes and returns an int value.

public final long
readLong()

Reads eight bytes and returns a long value.

public final short
readShort()

Reads two bytes and returns a short value.

public final Object

Returns:

The read value, such as a boxed Java primitive, a String, a null, or an array of these types.
readTypedValue
()

Reads a single value, using the data type encoded in the marshalled data.

public final String
readUTF()

Reads a string using a modified UTF-8 encoding in a machine-independent manner.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EOFback to summary
private static final int EOF
lengthback to summary
protected final int length
posback to summary
protected int pos
tempEncodingByteBufferback to summary
private byte[] tempEncodingByteBuffer
tempEncodingCharBufferback to summary
private char[] tempEncodingCharBuffer

Constructor Detail

BinaryInputback to summary
private BinaryInput(int length)

Method Detail

asByteBufferback to summary
public abstract ByteBuffer asByteBuffer(int len)

Returns a read only ByteBuffer backed by the BinaryInput internal buffer. The content of the buffer will start at the BinaryInput's current position. The buffer's capacity and limit will be len, its position will be zero, its mark will be undefined, and its byte order will be BIG_ENDIAN. After a successful call, the BinaryInput's current position is incremented by the len.

Exceptions
IndexOutOfBoundsException:
if the BinaryInput has not enough remaining bytes.
createback to summary
public static BinaryInput create(byte[] buffer)

Creates a new buffer backed by a byte array.

createback to summary
public static BinaryInput create(byte[] buffer, int length)

Creates a new buffer backed by a byte array only up to a given length.

createback to summary
public static BinaryInput create(CCharPointer address, int length)

Creates a new buffer wrapping an off-heap memory segment starting at an address having length bytes.

ensureBufferSizeback to summary
private void ensureBufferSize(int len)
packCharback to summary
private static char packChar(int b1, int b2)

Creates a Java char from given unsigned bytes, where b1 is the most significant byte byte and b2 is the least significant byte.

packIntback to summary
private static int packInt(int b1, int b2, int b3, int b4)

Creates a Java int from given unsigned bytes, where b1 is the most significant byte byte and b4 is the least significant byte.

packLongback to summary
private static long packLong(int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8)

Creates a Java long from given unsigned bytes, where b1 is the most significant byte byte and b8 is the least significant byte.

packShortback to summary
private static short packShort(int b1, int b2)

Creates a Java short from given unsigned bytes, where b1 is the most significant byte byte and b2 is the least significant byte.

readback to summary
public abstract int read()

Reads a single byte. The byte value is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.

readback to summary
public abstract void read(byte[] b, int off, int len) throws IndexOutOfBoundsException

Reads len bytes into a byte array starting at offset off.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read
readback to summary
public final void read(boolean[] b, int off, int len)

Reads len bytes into a boolean array starting at offset off.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read
readback to summary
public final void read(short[] b, int off, int len)

Reads len shorts into a short array starting at offset off.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read
readback to summary
public final void read(char[] b, int off, int len)

Reads len chars into a char array starting at offset off.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read
readback to summary
public final void read(int[] b, int off, int len)

Reads len ints into an int array starting at offset off.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read
readback to summary
public final void read(long[] b, int off, int len)

Reads len longs into a long array starting at offset off.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read
readback to summary
public final void read(float[] b, int off, int len)

Reads len floats into a float array starting at offset off.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read
readback to summary
public final void read(double[] b, int off, int len)

Reads len doubles into a double array starting at offset off.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read
readBooleanback to summary
public final boolean readBoolean() throws IndexOutOfBoundsException

Reads a single byte and returns true if that byte is non-zero, false if that byte is zero.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read.
readByteback to summary
public final byte readByte() throws IndexOutOfBoundsException

Reads and returns a single byte.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read.
readCharback to summary
public final char readChar() throws IndexOutOfBoundsException

Reads two bytes and returns a char value.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read.
readDoubleback to summary
public final double readDouble() throws IndexOutOfBoundsException

Reads eight bytes and returns a double value. It does this by reading a long value and converting the long value to a double using Double#longBitsToDouble(long).

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read.
readFloatback to summary
public final float readFloat() throws IndexOutOfBoundsException

Reads four bytes and returns a float value. It does this by reading an int value and converting the int value to a float using Float#intBitsToFloat(int).

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read.
readIntback to summary
public final int readInt() throws IndexOutOfBoundsException

Reads four bytes and returns an int value.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read.
readLongback to summary
public final long readLong() throws IndexOutOfBoundsException

Reads eight bytes and returns a long value.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read.
readShortback to summary
public final short readShort() throws IndexOutOfBoundsException

Reads two bytes and returns a short value.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read.
readTypedValueback to summary
public final Object readTypedValue() throws IndexOutOfBoundsException, IllegalArgumentException

Reads a single value, using the data type encoded in the marshalled data.

Returns:Object

The read value, such as a boxed Java primitive, a String, a null, or an array of these types.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read.
IllegalArgumentException:
when the marshaled type is not supported or if the bytes do not represent a valid modified UTF-8 encoding of a string.
readUTFback to summary
public final String readUTF() throws IndexOutOfBoundsException, IllegalArgumentException

Reads a string using a modified UTF-8 encoding in a machine-independent manner.

Exceptions
IndexOutOfBoundsException:
if there are not enough bytes to read.
IllegalArgumentException:
if the bytes do not represent a valid modified UTF-8 encoding of a string.
org.graalvm.nativebridge back to summary

private final Class BinaryInput.ByteArrayBinaryInput

extends BinaryInput
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final byte[]
Inherited from org.graalvm.nativebridge.BinaryInput:
lengthpos

Constructor Summary

AccessConstructor and Description
pack-priv
ByteArrayBinaryInput(byte[] buffer)

pack-priv
ByteArrayBinaryInput(byte[] buffer, int length)

Method Summary

Modifier and TypeMethod and Description
public ByteBuffer
asByteBuffer(int len)

Implements abstract org.graalvm.nativebridge.BinaryInput.asByteBuffer.

Returns a read only ByteBuffer backed by the BinaryInput internal buffer.

public int
read()

Implements abstract org.graalvm.nativebridge.BinaryInput.read.

Reads a single byte.

public void
read(byte[] b, int off, int len)

Implements abstract org.graalvm.nativebridge.BinaryInput.read.

Reads len bytes into a byte array starting at offset off.

Inherited from org.graalvm.nativebridge.BinaryInput:
createcreatecreatereadreadreadreadreadreadreadreadBooleanreadBytereadCharreadDoublereadFloatreadIntreadLongreadShortreadTypedValuereadUTF

Field Detail

bufferback to summary
private final byte[] buffer

Constructor Detail

ByteArrayBinaryInputback to summary
pack-priv ByteArrayBinaryInput(byte[] buffer)
ByteArrayBinaryInputback to summary
pack-priv ByteArrayBinaryInput(byte[] buffer, int length)

Method Detail

asByteBufferback to summary
public ByteBuffer asByteBuffer(int len)

Implements abstract org.graalvm.nativebridge.BinaryInput.asByteBuffer.

Doc from org.graalvm.nativebridge.BinaryInput.asByteBuffer.

Returns a read only ByteBuffer backed by the BinaryInput internal buffer. The content of the buffer will start at the BinaryInput's current position. The buffer's capacity and limit will be len, its position will be zero, its mark will be undefined, and its byte order will be BIG_ENDIAN. After a successful call, the BinaryInput's current position is incremented by the len.

Annotations
@Override
readback to summary
public int read()

Implements abstract org.graalvm.nativebridge.BinaryInput.read.

Doc from org.graalvm.nativebridge.BinaryInput.read.

Reads a single byte. The byte value is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.

Annotations
@Override
readback to summary
public void read(byte[] b, int off, int len)

Implements abstract org.graalvm.nativebridge.BinaryInput.read.

Doc from org.graalvm.nativebridge.BinaryInput.read.

Reads len bytes into a byte array starting at offset off.

Annotations
@Override
org.graalvm.nativebridge back to summary

private final Class BinaryInput.CCharPointerInput

extends BinaryInput
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final CCharPointer
private static final int
BYTEBUFFER_COPY_TO_ARRAY_THRESHOLD

Represents the point at which the average cost of a JNI call exceeds the expense of an element by element copy.

private ByteBuffer
byteBufferView

ByteBuffer view of this CCharPointerInput direct memory.

Inherited from org.graalvm.nativebridge.BinaryInput:
lengthpos

Constructor Summary

AccessConstructor and Description
pack-priv
CCharPointerInput(CCharPointer address, int length)

Method Summary

Modifier and TypeMethod and Description
public ByteBuffer
asByteBuffer(int len)

Implements abstract org.graalvm.nativebridge.BinaryInput.asByteBuffer.

Returns a read only ByteBuffer backed by the BinaryInput internal buffer.

public int
read()

Implements abstract org.graalvm.nativebridge.BinaryInput.read.

Reads a single byte.

public void
read(byte[] b, int off, int len)

Implements abstract org.graalvm.nativebridge.BinaryInput.read.

Reads len bytes into a byte array starting at offset off.

Inherited from org.graalvm.nativebridge.BinaryInput:
createcreatecreatereadreadreadreadreadreadreadreadBooleanreadBytereadCharreadDoublereadFloatreadIntreadLongreadShortreadTypedValuereadUTF

Field Detail

addressback to summary
private final CCharPointer address
BYTEBUFFER_COPY_TO_ARRAY_THRESHOLDback to summary
private static final int BYTEBUFFER_COPY_TO_ARRAY_THRESHOLD

Represents the point at which the average cost of a JNI call exceeds the expense of an element by element copy. See java.nio.Bits#JNI_COPY_TO_ARRAY_THRESHOLD.

byteBufferViewback to summary
private ByteBuffer byteBufferView

ByteBuffer view of this CCharPointerInput direct memory. The ByteBuffer is used for bulk data transfers, where the bulk ByteBuffer operations outperform element by element copying by an order of magnitude.

Constructor Detail

CCharPointerInputback to summary
pack-priv CCharPointerInput(CCharPointer address, int length)

Method Detail

asByteBufferback to summary
public ByteBuffer asByteBuffer(int len)

Implements abstract org.graalvm.nativebridge.BinaryInput.asByteBuffer.

Doc from org.graalvm.nativebridge.BinaryInput.asByteBuffer.

Returns a read only ByteBuffer backed by the BinaryInput internal buffer. The content of the buffer will start at the BinaryInput's current position. The buffer's capacity and limit will be len, its position will be zero, its mark will be undefined, and its byte order will be BIG_ENDIAN. After a successful call, the BinaryInput's current position is incremented by the len.

Annotations
@Override
readback to summary
public int read()

Implements abstract org.graalvm.nativebridge.BinaryInput.read.

Doc from org.graalvm.nativebridge.BinaryInput.read.

Reads a single byte. The byte value is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.

Annotations
@Override
readback to summary
public void read(byte[] b, int off, int len)

Implements abstract org.graalvm.nativebridge.BinaryInput.read.

Doc from org.graalvm.nativebridge.BinaryInput.read.

Reads len bytes into a byte array starting at offset off.

Annotations
@Override