Top Description Fields Constructors Methods
sun.nio.ch

pack-priv Class NativeObject

extends Object
Class Inheritance
Known Direct Subclasses
sun.nio.ch.AllocatedNativeObject
Imports
java.nio.ByteOrder, jdk.internal.misc.Unsafe

Proxies for objects that reside in native memory.

Field Summary

Modifier and TypeField and Description
private final long
protected long
private static ByteOrder
private static int
pageSize

Cache for page size.

protected static final Unsafe

Constructor Summary

AccessConstructor and Description
pack-priv
NativeObject(long address)

Creates a new native object that is based at the given native address.

pack-priv
NativeObject(long address, long offset)

Creates a new native object allocated at the given native address but whose base is at the additional offset.

protected
NativeObject(int size, boolean pageAligned)

Method Summary

Modifier and TypeMethod and Description
pack-priv long

Returns:

The native base address
address
()

Returns the native base address of this native object.

pack-priv static int

Returns:

The address size of the native architecture
addressSize
()

Returns the native architecture's address size in bytes.

pack-priv long
pack-priv static ByteOrder

Returns:

An instance of java.nio.ByteOrder
byteOrder
()

Returns the byte order of the underlying hardware.

pack-priv final byte

Returns:

The byte value read
getByte
(int
The offset at which to read the byte
offset
)

Reads a byte starting at the given offset from base of this native object.

pack-priv final char

Returns:

The char value read
getChar
(int
The offset at which to read the char
offset
)

Reads a char starting at the given offset from base of this native object.

pack-priv final double

Returns:

The double value read
getDouble
(int
The offset at which to read the double
offset
)

Reads a double starting at the given offset from base of this native object.

pack-priv final float

Returns:

The float value read
getFloat
(int
The offset at which to read the float
offset
)

Reads a float starting at the given offset from base of this native object.

pack-priv final int

Returns:

The int value read
getInt
(int
The offset at which to read the int
offset
)

Reads an int starting at the given offset from base of this native object.

pack-priv final long

Returns:

The long value read
getLong
(int
The offset at which to read the long
offset
)

Reads a long starting at the given offset from base of this native object.

pack-priv NativeObject

Returns:

The native object created using the address read from the given offset
getObject
(int
The offset of the address to be read. Note that the size of an address is implementation-dependent.
offset
)

Reads an address from this native object at the given offset and constructs a native object using that address.

pack-priv final short

Returns:

The short value read
getShort
(int
The offset at which to read the short
offset
)

Reads a short starting at the given offset from base of this native object.

pack-priv static int

Returns:

The page size, in bytes
pageSize
()

Returns the page size of the underlying hardware.

pack-priv final void
putByte(int
The offset at which to write the byte
offset
,
byte
The byte value to be written
value
)

Writes a byte at the specified offset from this native object's base address.

pack-priv final void
putChar(int
The offset at which to write the char
offset
,
char
The char value to be written
value
)

Writes a char at the specified offset from this native object's base address.

pack-priv final void
putDouble(int
The offset at which to write the double
offset
,
double
The double value to be written
value
)

Writes a double at the specified offset from this native object's base address.

pack-priv final void
putFloat(int
The offset at which to write the float
offset
,
float
The float value to be written
value
)

Writes a float at the specified offset from this native object's base address.

pack-priv final void
putInt(int
The offset at which to write the int
offset
,
int
The int value to be written
value
)

Writes an int at the specified offset from this native object's base address.

pack-priv final void
putLong(int
The offset at which to write the long
offset
,
long
The long value to be written
value
)

Writes a long at the specified offset from this native object's base address.

pack-priv void
putObject(int
The offset at which the address is to be written. Note that the size of an address is implementation-dependent.
offset
,
NativeObject
The native object whose address is to be written
ob
)

Writes the base address of the given native object at the given offset of this native object.

pack-priv final void
putShort(int
The offset at which to write the short
offset
,
short
The short value to be written
value
)

Writes a short at the specified offset from this native object's base address.

pack-priv NativeObject

Returns:

The newly created native object
subObject
(int
The offset from the base of this native object that is to be the base of the new native object
offset
)

Creates a new native object starting at the given offset from the base of this native object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addressback to summary
private final long address
allocationAddressback to summary
protected long allocationAddress
byteOrderback to summary
private static ByteOrder byteOrder
pageSizeback to summary
private static int pageSize

Cache for page size. Lazily initialized via a data race; safe because ints are atomic.

unsafeback to summary
protected static final Unsafe unsafe

Constructor Detail

NativeObjectback to summary
pack-priv NativeObject(long address)

Creates a new native object that is based at the given native address.

NativeObjectback to summary
pack-priv NativeObject(long address, long offset)

Creates a new native object allocated at the given native address but whose base is at the additional offset.

NativeObjectback to summary
protected NativeObject(int size, boolean pageAligned)

Method Detail

addressback to summary
pack-priv long address()

Returns the native base address of this native object.

Returns:long

The native base address

addressSizeback to summary
pack-priv static int addressSize()

Returns the native architecture's address size in bytes.

Returns:int

The address size of the native architecture

allocationAddressback to summary
pack-priv long allocationAddress()
byteOrderback to summary
pack-priv static ByteOrder byteOrder()

Returns the byte order of the underlying hardware.

Returns:ByteOrder

An instance of java.nio.ByteOrder

getByteback to summary
pack-priv final byte getByte(int offset)

Reads a byte starting at the given offset from base of this native object.

Parameters
offset:int

The offset at which to read the byte

Returns:byte

The byte value read

getCharback to summary
pack-priv final char getChar(int offset)

Reads a char starting at the given offset from base of this native object.

Parameters
offset:int

The offset at which to read the char

Returns:char

The char value read

getDoubleback to summary
pack-priv final double getDouble(int offset)

Reads a double starting at the given offset from base of this native object.

Parameters
offset:int

The offset at which to read the double

Returns:double

The double value read

getFloatback to summary
pack-priv final float getFloat(int offset)

Reads a float starting at the given offset from base of this native object.

Parameters
offset:int

The offset at which to read the float

Returns:float

The float value read

getIntback to summary
pack-priv final int getInt(int offset)

Reads an int starting at the given offset from base of this native object.

Parameters
offset:int

The offset at which to read the int

Returns:int

The int value read

getLongback to summary
pack-priv final long getLong(int offset)

Reads a long starting at the given offset from base of this native object.

Parameters
offset:int

The offset at which to read the long

Returns:long

The long value read

getObjectback to summary
pack-priv NativeObject getObject(int offset)

Reads an address from this native object at the given offset and constructs a native object using that address.

Parameters
offset:int

The offset of the address to be read. Note that the size of an address is implementation-dependent.

Returns:NativeObject

The native object created using the address read from the given offset

getShortback to summary
pack-priv final short getShort(int offset)

Reads a short starting at the given offset from base of this native object.

Parameters
offset:int

The offset at which to read the short

Returns:short

The short value read

pageSizeback to summary
pack-priv static int pageSize()

Returns the page size of the underlying hardware.

Returns:int

The page size, in bytes

putByteback to summary
pack-priv final void putByte(int offset, byte value)

Writes a byte at the specified offset from this native object's base address.

Parameters
offset:int

The offset at which to write the byte

value:byte

The byte value to be written

putCharback to summary
pack-priv final void putChar(int offset, char value)

Writes a char at the specified offset from this native object's base address.

Parameters
offset:int

The offset at which to write the char

value:char

The char value to be written

putDoubleback to summary
pack-priv final void putDouble(int offset, double value)

Writes a double at the specified offset from this native object's base address.

Parameters
offset:int

The offset at which to write the double

value:double

The double value to be written

putFloatback to summary
pack-priv final void putFloat(int offset, float value)

Writes a float at the specified offset from this native object's base address.

Parameters
offset:int

The offset at which to write the float

value:float

The float value to be written

putIntback to summary
pack-priv final void putInt(int offset, int value)

Writes an int at the specified offset from this native object's base address.

Parameters
offset:int

The offset at which to write the int

value:int

The int value to be written

putLongback to summary
pack-priv final void putLong(int offset, long value)

Writes a long at the specified offset from this native object's base address.

Parameters
offset:int

The offset at which to write the long

value:long

The long value to be written

putObjectback to summary
pack-priv void putObject(int offset, NativeObject ob)

Writes the base address of the given native object at the given offset of this native object.

Parameters
offset:int

The offset at which the address is to be written. Note that the size of an address is implementation-dependent.

ob:NativeObject

The native object whose address is to be written

putShortback to summary
pack-priv final void putShort(int offset, short value)

Writes a short at the specified offset from this native object's base address.

Parameters
offset:int

The offset at which to write the short

value:short

The short value to be written

subObjectback to summary
pack-priv NativeObject subObject(int offset)

Creates a new native object starting at the given offset from the base of this native object.

Parameters
offset:int

The offset from the base of this native object that is to be the base of the new native object

Returns:NativeObject

The newly created native object