public interface MemoryAddress
MemorySegment. Memory addresses are typically obtained
 using the MemorySegment.baseAddress() method; such addresses can then be adjusted as required,
 using addOffset(long).
 A memory address is typically used as the first argument in a memory access var handle call, to perform some operation on the underlying memory backing a given memory segment. Since a memory address is always associated with a memory segment, such access operations are always subject to spatial and temporal checks as enforced by the address' owning memory region.
 All implementations of this interface must be value-based;
 use of identity-sensitive operations (including reference equality (==), identity hash code, or synchronization) on
 instances of MemoryAddress may have unpredictable results and should be avoided. The equals method should
 be used for comparisons.
 
Non-platform classes should not implement MemoryAddress directly.
- API Note:
- In the future, if the Java language permits, MemoryAddressmay become asealedinterface, which would prohibit subclassing except by explicitly permitted types.
- Implementation Requirements:
- Implementations of this interface are immutable and thread-safe.
- 
Method SummaryModifier and Type Method Description MemoryAddressaddOffset(long offset)Creates a new memory address with given offset (in bytes), which might be negative, from current one.static voidcopy(MemoryAddress src, MemoryAddress dst, long bytes)Perform bulk copy from source address to target address.booleanequals(Object that)Compares the specified object with this address for equality.inthashCode()Returns the hash code value for this address.longoffset()The offset of this memory address into the underlying segment.MemorySegmentsegment()The memory segment this address belongs to.
- 
Method Details- 
addOffsetCreates a new memory address with given offset (in bytes), which might be negative, from current one.- Parameters:
- offset- specified offset (in bytes), relative to this address, which should be used to create the new address.
- Returns:
- a new memory address with given offset from current one.
 
- 
offsetlong offset()The offset of this memory address into the underlying segment.- Returns:
- the offset
 
- 
segmentMemorySegment segment()The memory segment this address belongs to.- Returns:
- The memory segment this address belongs to.
 
- 
equalsCompares the specified object with this address for equality. Returnstrueif and only if the specified object is also an address, and it refers to the same memory location as this address.- Overrides:
- equalsin class- Object
- API Note:
- two addresses might be considered equal despite their associated segments differ. This
 can happen, for instance, if the segment associated with one address is a slice
 (see MemorySegment.asSlice(long, long)) of the segment associated with the other address. Moreover, two addresses might be considered equals despite differences in the temporal bounds associated with their corresponding segments (this is possible, for example, as a result of calls toMemorySegment.acquire()).
- Parameters:
- that- the object to be compared for equality with this address.
- Returns:
- trueif the specified object is equal to this address.
- See Also:
- Object.hashCode(),- HashMap
 
- 
hashCodeint hashCode()Returns the hash code value for this address.- Overrides:
- hashCodein class- Object
- Returns:
- the hash code value for this address.
- See Also:
- Object.equals(java.lang.Object),- System.identityHashCode(java.lang.Object)
 
- 
copyPerform bulk copy from source address to target address. More specifically, the bytes at addressessrcthroughsrc.addOffset(bytes - 1)are copied into addressesdstthroughdst.addOffset(bytes - 1). If the source and address ranges overlap, then the copying is performed as if the bytes at addressessrcthroughsrc.addOffset(bytes - 1)were first copied into a temporary segment with sizebytes, and then the contents of the temporary segment were copied into the bytes at addressesdstthroughdst.addOffset(bytes - 1).- Parameters:
- src- the source address.
- dst- the target address.
- bytes- the number of bytes to be copied.
- Throws:
- IndexOutOfBoundsException- if- bytes < 0, or if it is greater than the size of the segments associated with either- srcor- dst.
- IllegalStateException- if either the source address or the target address belong to memory segments which have been already closed, or if access occurs from a thread other than the thread owning either segment.
- UnsupportedOperationException- if- dstis associated with a read-only segment (see- MemorySegment.isReadOnly()).
 
 
-