RFR: 8369564: Provide a MemorySegment API to read strings with known lengths [v8]
Jorn Vernee
jvernee at openjdk.org
Thu Nov 20 16:07:26 UTC 2025
On Thu, 20 Nov 2025 15:47:18 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> Liam Miller-Cushon has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Review feedback
>
> src/java.base/share/classes/jdk/internal/foreign/StringSupport.java line 68:
>
>> 66: @ForceInline
>> 67: public static String readBytes(AbstractMemorySegmentImpl segment, long offset, Charset charset, long length) {
>> 68: final int lengthBytes = (int) length;
>
> I think we should do something more here than just ignore the upper bits. We probably need to throw an exception when the value is > Integer.MAX_VALUE
Looks like we are already specified to throw IAE if 'the size of the string is greater than the largest string supported by the platform'
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28043#discussion_r2546639764
More information about the core-libs-dev
mailing list