@@ -157,11 +157,18 @@ boolean equalTo(
157157 long getCapacity ();
158158
159159 /**
160- * Gets the relative base offset of <i>this</i> with respect to <i>that</i>, defined as: <i>this</i> - <i>that</i>.
161- * This method is only valid for <i>native</i> (off-heap) allocated resources.
160+ * Gets the MemorySegment that backs this resource as a read-only MemorySegment.
161+ * @return the MemorySegment that back this resource as a read-only MemorySegment.
162+ */
163+ MemorySegment getMemorySegment ();
164+
165+ /**
166+ * Gets the relative base offset of <i>this</i> resource with respect to <i>that</i> resource,
167+ * defined as: <i>this</i> - <i>that</i>.
162168 * @param that the given resource.
163169 * @return <i>this</i> - <i>that</i> offset
164- * @throws IllegalArgumentException if one of the resources is on-heap.
170+ * @throws UnsupportedOperationException if the two resources cannot be compared, e.g. because they are of
171+ * different kinds, or because they are backed by different Java arrays.
165172 */
166173 long getRelativeOffset (Resource that );
167174
@@ -274,17 +281,6 @@ boolean equalTo(
274281 */
275282 void load ();
276283
277- /**
278- * Returns a positive number if <i>this</i> overlaps <i>that</i> and <i>this</i> base address is ≤ <i>that</i>
279- * base address.
280- * Returns a negative number if <i>this</i> overlaps <i>that</i> and <i>this</i> base address is > <i>that</i>
281- * base address.
282- * Returns a zero if there is no overlap or if one or both objects are null, not active or on heap.
283- * @param that the other Resource object
284- * @return a long value representing the ordering and size of overlap between <i>this</i> and <i>that</i>.
285- */
286- long nativeOverlap (Resource that );
287-
288284 /**
289285 * Finds the first byte mismatch with <i>that</i>.
290286 * @param that the other Resource
@@ -311,6 +307,17 @@ boolean equalTo(
311307 */
312308 long mismatch (Resource src , long srcFromOffset , long srcToOffset , Resource dst , long dstFromOffset , long dstToOffset );
313309
310+ /**
311+ * Returns a positive number if <i>this</i> overlaps <i>that</i> and <i>this</i> base address is ≤ <i>that</i>
312+ * base address.
313+ * Returns a negative number if <i>this</i> overlaps <i>that</i> and <i>this</i> base address is > <i>that</i>
314+ * base address.
315+ * Returns a zero if there is no overlap or if one or both objects are null, not active or on heap.
316+ * @param that the other Resource object
317+ * @return a long value representing the ordering and size of overlap between <i>this</i> and <i>that</i>.
318+ */
319+ long nativeOverlap (Resource that );
320+
314321 /**
315322 * Returns the resource scope associated with this memory segment.
316323 * @return the resource scope associated with this memory segment.
0 commit comments