- All Superinterfaces:
AddressablePREVIEW
MemoryAddress
is a preview API of the Java platform.
- By calling
Addressable.address()
PREVIEW on an instance of typeAddressable
PREVIEW (e.g. a memory segment); - By invoking a downcall method handlePREVIEW which returns a pointer;
- By reading an address from memory, e.g. via
MemorySegment.get(ValueLayout.OfAddress, long)
PREVIEW; and - By the invocation of an upcall stubPREVIEW which accepts a pointer.
Dereferencing memory addresses
A memory address can be read or written using various methods provided in this class (e.g.get(ValueLayout.OfInt, long)
).
Each dereference method takes a value layoutPREVIEW, which specifies the size,
alignment constraints, byte order as well as the Java type associated with the dereference operation, and an offset.
For instance, to read an int from a segment, using default endianness, the following code can be used:
MemoryAddress address = ...
int value = address.get(ValueLayout.JAVA_INT, 0);
big-endian
encoding, the dereference operation
can be expressed as follows:
MemoryAddress address = ...
int value = address.get(ValueLayout.JAVA_INT.withOrder(BIG_ENDIAN), 0);
- Implementation Requirements:
- Implementations of this interface are immutable, thread-safe and value-based.
- Since:
- 19
-
Field Summary
Modifier and TypeFieldDescriptionstatic final MemoryAddressPREVIEW
The memory address instance modelling theNULL
address. -
Method Summary
Modifier and TypeMethodDescriptionaddOffset
(long offset) Returns a memory address at given offset from this address.boolean
Compares the specified object with this address for equality.get
(ValueLayout.OfAddressPREVIEW layout, long offset) Reads an address from this address at the given offset, with the given layout.boolean
get
(ValueLayout.OfBooleanPREVIEW layout, long offset) Reads a boolean from this address at the given offset, with the given layout.byte
get
(ValueLayout.OfBytePREVIEW layout, long offset) Reads a byte from this address at the given offset, with the given layout.char
get
(ValueLayout.OfCharPREVIEW layout, long offset) Reads a char from this address at the given offset, with the given layout.double
get
(ValueLayout.OfDoublePREVIEW layout, long offset) Reads a double from this address at the given offset, with the given layout.float
get
(ValueLayout.OfFloatPREVIEW layout, long offset) Reads a float from this address at the given offset, with the given layout.int
get
(ValueLayout.OfIntPREVIEW layout, long offset) Reads an int from this address at the given offset, with the given layout.long
get
(ValueLayout.OfLongPREVIEW layout, long offset) Reads a long from this address at the given offset, with the given layout.short
get
(ValueLayout.OfShortPREVIEW layout, long offset) Reads a short from this address at the given offset, with the given layout.getAtIndex
(ValueLayout.OfAddressPREVIEW layout, long index) Reads an address from this address at the given index, scaled by the given layout size.char
getAtIndex
(ValueLayout.OfCharPREVIEW layout, long index) Reads a char from this address at the given index, scaled by the given layout size.double
getAtIndex
(ValueLayout.OfDoublePREVIEW layout, long index) Reads a double from this address at the given index, scaled by the given layout size.float
getAtIndex
(ValueLayout.OfFloatPREVIEW layout, long index) Reads a float from this address at the given index, scaled by the given layout size.int
getAtIndex
(ValueLayout.OfIntPREVIEW layout, long index) Reads an int from this address at the given index, scaled by the given layout size.long
getAtIndex
(ValueLayout.OfLongPREVIEW layout, long index) Reads a long from this address at the given index, scaled by the given layout size.short
getAtIndex
(ValueLayout.OfShortPREVIEW layout, long index) Reads a short from this address at the given index, scaled by the given layout size.getUtf8String
(long offset) Reads a UTF-8 encoded, null-terminated string from this address at the given offset.int
hashCode()
Returns the hash code value for this address.static MemoryAddressPREVIEW
ofLong
(long value) Creates a memory address from the given long value.void
set
(ValueLayout.OfAddressPREVIEW layout, long offset, AddressablePREVIEW value) Writes an address into this address at the given offset, with the given layout.void
set
(ValueLayout.OfBooleanPREVIEW layout, long offset, boolean value) Writes a boolean into this address at the given offset, with the given layout.void
set
(ValueLayout.OfBytePREVIEW layout, long offset, byte value) Writes a byte into this address at the given offset, with the given layout.void
set
(ValueLayout.OfCharPREVIEW layout, long offset, char value) Writes a char into this address at the given offset, with the given layout.void
set
(ValueLayout.OfDoublePREVIEW layout, long offset, double value) Writes a double into this address at the given offset, with the given layout.void
set
(ValueLayout.OfFloatPREVIEW layout, long offset, float value) Writes a float into this address at the given offset, with the given layout.void
set
(ValueLayout.OfIntPREVIEW layout, long offset, int value) Writes an int into this address at the given offset, with the given layout.void
set
(ValueLayout.OfLongPREVIEW layout, long offset, long value) Writes a long into this address at the given offset, with the given layout.void
set
(ValueLayout.OfShortPREVIEW layout, long offset, short value) Writes a short into this address at the given offset, with the given layout.void
setAtIndex
(ValueLayout.OfAddressPREVIEW layout, long index, AddressablePREVIEW value) Writes an address into this address at the given index, scaled by the given layout size.void
setAtIndex
(ValueLayout.OfCharPREVIEW layout, long index, char value) Writes a char into this address at the given index, scaled by the given layout size.void
setAtIndex
(ValueLayout.OfDoublePREVIEW layout, long index, double value) Writes a double into this address at the given index, scaled by the given layout size.void
setAtIndex
(ValueLayout.OfFloatPREVIEW layout, long index, float value) Writes a float into this address at the given index, scaled by the given layout size.void
setAtIndex
(ValueLayout.OfIntPREVIEW layout, long index, int value) Writes an int into this address at the given index, scaled by the given layout size.void
setAtIndex
(ValueLayout.OfLongPREVIEW layout, long index, long value) Writes a long into this address at the given index, scaled by the given layout size.void
setAtIndex
(ValueLayout.OfShortPREVIEW layout, long index, short value) Writes a short into this address at the given index, scaled by the given layout size.void
setUtf8String
(long offset, String str) Writes the given string to this address at the given offset, converting it to a null-terminated byte sequence using UTF-8 encoding.long
Returns the raw long value associated with this memory address.Methods declared in interface java.lang.foreign.AddressablePREVIEW
address
-
Field Details
-
NULL
The memory address instance modelling theNULL
address.
-
-
Method Details
-
toRawLongValue
long toRawLongValue()Returns the raw long value associated with this memory address.- Returns:
- the raw long value associated with this memory address
-
addOffset
Returns a memory address at given offset from this address.- Parameters:
offset
- specified offset (in bytes), relative to this address, which should be used to create the new address. Might be negative.- Returns:
- a memory address with the given offset from current one.
-
getUtf8String
Reads a UTF-8 encoded, null-terminated string from this address at the given offset.This method always replaces malformed-input and unmappable-character sequences with this charset's default replacement string. The
CharsetDecoder
class should be used when more control over the decoding process is required.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
offset
- offset in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + offset
.- Returns:
- a Java string constructed from the bytes read from the given starting address (
toRawLongValue() + offset
) up to (but not including) the first'\0'
terminator character (assuming one is found). - Throws:
IllegalArgumentException
- if the size of the UTF-8 string is greater than the largest string supported by the platform.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
setUtf8String
Writes the given string to this address at the given offset, converting it to a null-terminated byte sequence using UTF-8 encoding.This method always replaces malformed-input and unmappable-character sequences with this charset's default replacement string. The
CharsetDecoder
class should be used when more control over the decoding process is required.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
offset
- offset in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + offset
.str
- the Java string to be written at this address.- Throws:
IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
equals
Compares the specified object with this address for equality. Returnstrue
if and only if the specified object is also an address, and it refers to the same memory location as this address. -
hashCode
int hashCode()Returns the hash code value for this address. -
ofLong
Creates a memory address from the given long value.- Parameters:
value
- the long value representing a raw address.- Returns:
- a memory address with the given raw long value.
-
get
Reads a byte from this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.offset
- offset in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + offset
.- Returns:
- a byte value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
set
Writes a byte into this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.offset
- offset in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + offset
.value
- the byte value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
get
Reads a boolean from this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.offset
- offset in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + offset
.- Returns:
- a boolean value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
set
Writes a boolean into this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.offset
- offset in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + offset
.value
- the boolean value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
get
Reads a char from this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.offset
- offset in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + offset
.- Returns:
- a char value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
set
Writes a char into this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.offset
- offset in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + offset
.value
- the char value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
get
Reads a short from this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.offset
- offset in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + offset
.- Returns:
- a short value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
set
Writes a short into this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.offset
- offset in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + offset
.value
- the short value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
get
Reads an int from this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.offset
- offset in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + offset
.- Returns:
- an int value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
set
Writes an int into this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.offset
- offset in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + offset
.value
- the int value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
get
Reads a float from this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.offset
- offset in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + offset
.- Returns:
- a float value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
set
Writes a float into this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.offset
- offset in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + offset
.value
- the float value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
get
Reads a long from this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.offset
- offset in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + offset
.- Returns:
- a long value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
set
Writes a long into this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.offset
- offset in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + offset
.value
- the long value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
get
Reads a double from this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.offset
- offset in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + offset
.- Returns:
- a double value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
set
Writes a double into this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.offset
- offset in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + offset
.value
- the double value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
get
Reads an address from this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.offset
- offset in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + offset
.- Returns:
- an address value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
set
Writes an address into this address at the given offset, with the given layout.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.offset
- offset in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + offset
.value
- the address value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
getAtIndex
Reads a char from this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.index
- index in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.- Returns:
- a char value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
setAtIndex
Writes a char into this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.index
- index in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.value
- the char value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
getAtIndex
Reads a short from this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.index
- index in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.- Returns:
- a short value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
setAtIndex
Writes a short into this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.index
- index in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.value
- the short value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
getAtIndex
Reads an int from this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.index
- index in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.- Returns:
- an int value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
setAtIndex
Writes an int into this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.index
- index in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.value
- the int value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
getAtIndex
Reads a float from this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.index
- index in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.- Returns:
- a float value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
setAtIndex
Writes a float into this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.index
- index in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.value
- the float value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
getAtIndex
Reads a long from this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.index
- index in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.- Returns:
- a long value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
setAtIndex
Writes a long into this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.index
- index in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.value
- the long value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
getAtIndex
Reads a double from this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.index
- index in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.- Returns:
- a double value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
setAtIndex
Writes a double into this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.index
- index in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.value
- the double value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
getAtIndex
Reads an address from this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be read.index
- index in bytes (relative to this address). Might be negative. The final address of this read operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.- Returns:
- an address value read from this address.
- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
setAtIndex
Writes an address into this address at the given index, scaled by the given layout size.This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
- Parameters:
layout
- the layout of the memory region to be written.index
- index in bytes (relative to this address). Might be negative. The final address of this write operation can be expressed astoRawLongValue() + (index * layout.byteSize())
.value
- the address value to be written.- Throws:
IllegalArgumentException
- if the dereference operation is incompatible with the alignment constraints in the provided layout, or if the layout alignment is greater than its size.IllegalCallerException
- if access to this method occurs from a moduleM
and the command line option--enable-native-access
is specified, but does not mention the module nameM
, orALL-UNNAMED
in caseM
is an unnamed module.
-
MemoryAddress
when preview features are enabled.