< prev index next >

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryAddress.java

Print this page




  43  * be used for comparisons.
  44  * <p>
  45  * Non-platform classes should not implement {@linkplain MemoryAddress} directly.
  46  *
  47  * @apiNote In the future, if the Java language permits, {@link MemoryAddress}
  48  * may become a {@code sealed} interface, which would prohibit subclassing except by
  49  * explicitly permitted types.
  50  *
  51  * @implSpec
  52  * Implementations of this interface are immutable and thread-safe.
  53  */
  54 public interface MemoryAddress {
  55     /**
  56      * Creates a new memory address with given offset (in bytes) from current one.
  57      * @param l specified offset (in bytes), relative to this address, which should be used to create the new address.
  58      * @return a new memory address with given offset from current one.
  59      */
  60     MemoryAddress offset(long l);
  61 
  62     /**
  63      * The offset of this MemoryAddress into the underlying segment.
  64      *
  65      * @return the offset
  66      */
  67     long offset();
  68 
  69     /**
  70      * The memory segment this address belongs to.
  71      * @return The memory segment this address belongs to.
  72      */
  73     MemorySegment segment();
  74 
  75     /**
  76      * Compares the specified object with this address for equality. Returns {@code true} if and only if the specified
  77      * object is also a address, and it is equal to this address.
  78      *
  79      * @param that the object to be compared for equality with this address.
  80      * @return {@code true} if the specified object is equal to this address.
  81      */
  82     @Override
  83     boolean equals(Object that);




  43  * be used for comparisons.
  44  * <p>
  45  * Non-platform classes should not implement {@linkplain MemoryAddress} directly.
  46  *
  47  * @apiNote In the future, if the Java language permits, {@link MemoryAddress}
  48  * may become a {@code sealed} interface, which would prohibit subclassing except by
  49  * explicitly permitted types.
  50  *
  51  * @implSpec
  52  * Implementations of this interface are immutable and thread-safe.
  53  */
  54 public interface MemoryAddress {
  55     /**
  56      * Creates a new memory address with given offset (in bytes) from current one.
  57      * @param l specified offset (in bytes), relative to this address, which should be used to create the new address.
  58      * @return a new memory address with given offset from current one.
  59      */
  60     MemoryAddress offset(long l);
  61 
  62     /**
  63      * The offset of this memory address into the underlying segment.
  64      *
  65      * @return the offset
  66      */
  67     long offset();
  68 
  69     /**
  70      * The memory segment this address belongs to.
  71      * @return The memory segment this address belongs to.
  72      */
  73     MemorySegment segment();
  74 
  75     /**
  76      * Compares the specified object with this address for equality. Returns {@code true} if and only if the specified
  77      * object is also a address, and it is equal to this address.
  78      *
  79      * @param that the object to be compared for equality with this address.
  80      * @return {@code true} if the specified object is equal to this address.
  81      */
  82     @Override
  83     boolean equals(Object that);


< prev index next >