RFR: 8369564: Provide a MemorySegment API to read strings with known lengths [v8]
Liam Miller-Cushon
cushon at openjdk.org
Fri Nov 21 10:47:50 UTC 2025
On Thu, 20 Nov 2025 15:55:30 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> 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'
Done, and I added a test to cover the IAE
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28043#discussion_r2549317693
More information about the core-libs-dev
mailing list