On Fri, 14 Aug 2026 11:04:41 GMT, Liam Miller-Cushon <[email protected]> wrote:
> See > > * [panama-dev@ thread 'String processing and Vector > APIs'](https://mail.openjdk.org/archives/list/[email protected]/thread/YSPX3TBXZTZEFZNXWDYOZCWLUQPC62P6/) > * [JDK-8390049: Immutable zero-copy String views of a String's code > units](https://bugs.openjdk.org/browse/JDK-8390049) > > > > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). src/java.base/share/classes/java/lang/System.java line 2229: > 2227: public MemorySegment asReadOnlyMemorySegment(String str) { > 2228: return MemorySegment.ofArray(str.value()).asReadOnly(); > 2229: } Note that it’s generally preferred for `*Access` methods to keep their implementations trivial, that is, do: Suggestion: public MemorySegment asReadOnlyMemorySegment(String str) { return str.asReadOnlyMemorySegment(); } And add the following method to `java.lang.String`: /* package-private */ MemorySegment asReadOnlyMemorySegment() { return MemorySegment.ofArray(this.value).asReadOnly(); } ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/32373#discussion_r3984542191
