Skip to content

Commit f755fad

Browse files
committed
8349653: Clarify the docs for MemorySegment::reinterpret
Reviewed-by: jvernee, mcimadamore
1 parent a5c9a4d commit f755fad

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/java.base/share/classes/java/lang/foreign/MemorySegment.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -756,30 +756,30 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
756756

757757
/**
758758
* Returns a new memory segment with the same address and size as this segment, but
759-
* with the provided scope. As such, the returned segment cannot be accessed after
760-
* the provided arena has been closed. Moreover, the returned segment can be
759+
* with the provided arena's scope. As such, the returned segment cannot be accessed
760+
* after the provided arena has been closed. Moreover, the returned segment can be
761761
* accessed compatibly with the confinement restrictions associated with the provided
762762
* arena: that is, if the provided arena is a {@linkplain Arena#ofConfined() confined arena},
763763
* the returned segment can only be accessed by the arena's owner thread, regardless
764764
* of the confinement restrictions associated with this segment. In other words, this
765765
* method returns a segment that can be used as any other segment allocated using the
766-
* provided arena. However, The returned segment is backed by the same memory region
766+
* provided arena. However, the returned segment is backed by the same memory region
767767
* as that of the original segment. As such, the region of memory backing the
768768
* returned segment is deallocated only when this segment's arena is closed.
769769
* This might lead to <em>use-after-free</em> issues, as the returned segment can be
770770
* accessed <em>after</em> its region of memory has been deallocated via this
771771
* segment's arena.
772772
* <p>
773773
* Clients can specify an optional cleanup action that should be executed when the
774-
* provided scope becomes invalid. This cleanup action receives a fresh memory
774+
* provided arena's scope becomes invalid. This cleanup action receives a fresh memory
775775
* segment that is obtained from this segment as follows:
776776
* {@snippet lang=java :
777777
* MemorySegment cleanupSegment = MemorySegment.ofAddress(this.address())
778778
* .reinterpret(byteSize());
779779
* }
780780
* That is, the cleanup action receives a segment that is associated with the global
781-
* scope, and is accessible from any thread. The size of the segment accepted by the
782-
* cleanup action is {@link #byteSize()}.
781+
* arena's scope, and is accessible from any thread. The size of the segment accepted
782+
* by the cleanup action is {@link #byteSize()}.
783783
* <p>
784784
* If this segment is {@linkplain MemorySegment#isReadOnly() read-only},
785785
* the returned segment is also {@linkplain MemorySegment#isReadOnly() read-only}.
@@ -790,8 +790,8 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
790790
* @apiNote The cleanup action (if present) should take care not to leak the received
791791
* segment to external clients that might access the segment after its
792792
* backing region of memory is no longer available. Furthermore, if the
793-
* provided scope is the scope of an {@linkplain Arena#ofAuto() automatic arena},
794-
* the cleanup action must not prevent the scope from becoming
793+
* provided arena is an {@linkplain Arena#ofAuto() automatic arena},
794+
* the cleanup action must not prevent the arena from becoming
795795
* {@linkplain java.lang.ref##reachability unreachable}.
796796
* A failure to do so will permanently prevent the regions of memory
797797
* allocated by the automatic arena from being deallocated.
@@ -812,30 +812,30 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
812812

813813
/**
814814
* Returns a new segment with the same address as this segment, but with the provided
815-
* size and scope. As such, the returned segment cannot be accessed after the
816-
* provided arena has been closed. Moreover, if the returned segment can be accessed
817-
* compatibly with the confinement restrictions associated with the provided arena:
818-
* that is, if the provided arena is a {@linkplain Arena#ofConfined() confined arena},
815+
* size and the provided arena's scope. As such, the returned segment cannot be
816+
* accessed after the provided arena has been closed. Moreover, if the returned
817+
* segment can be accessed compatibly with the confinement restrictions associated
818+
* with the provided arena: that is, if the provided arena is a {@linkplain Arena#ofConfined() confined arena},
819819
* the returned segment can only be accessed by the arena's owner thread, regardless
820820
* of the confinement restrictions associated with this segment. In other words, this
821821
* method returns a segment that can be used as any other segment allocated using the
822-
* provided arena. However, The returned segment is backed by the same memory region
822+
* provided arena. However, the returned segment is backed by the same memory region
823823
* as that of the original segment. As such, the region of memory backing the
824824
* returned segment is deallocated only when this segment's arena is closed.
825825
* This might lead to <em>use-after-free</em> issues, as the returned segment can be
826826
* accessed <em>after</em> its region of memory has been deallocated via this
827827
* segment's arena.
828828
* <p>
829829
* Clients can specify an optional cleanup action that should be executed when the
830-
* provided scope becomes invalid. This cleanup action receives a fresh memory
830+
* provided arena's scope becomes invalid. This cleanup action receives a fresh memory
831831
* segment that is obtained from this segment as follows:
832832
* {@snippet lang=java :
833833
* MemorySegment cleanupSegment = MemorySegment.ofAddress(this.address())
834834
* .reinterpret(newSize);
835835
* }
836836
* That is, the cleanup action receives a segment that is associated with the global
837-
* scope, and is accessible from any thread. The size of the segment accepted by the
838-
* cleanup action is {@code newSize}.
837+
* arena's scope, and is accessible from any thread. The size of the segment accepted
838+
* by the cleanup action is {@code newSize}.
839839
* <p>
840840
* If this segment is {@linkplain MemorySegment#isReadOnly() read-only},
841841
* the returned segment is also {@linkplain MemorySegment#isReadOnly() read-only}.
@@ -846,8 +846,8 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
846846
* @apiNote The cleanup action (if present) should take care not to leak the received
847847
* segment to external clients that might access the segment after its
848848
* backing region of memory is no longer available. Furthermore, if the
849-
* provided scope is the scope of an {@linkplain Arena#ofAuto() automatic arena},
850-
* the cleanup action must not prevent the scope from becoming
849+
* provided arena is an {@linkplain Arena#ofAuto() automatic arena},
850+
* the cleanup action must not prevent the arena from becoming
851851
* {@linkplain java.lang.ref##reachability unreachable}.
852852
* A failure to do so will permanently prevent the regions of memory
853853
* allocated by the automatic arena from being deallocated.

0 commit comments

Comments
 (0)