Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8259741 | 17 | Maurizio Cimadamore | P3 | Resolved | Fixed | b06 |
JDK-8260129 | 16.0.1 | Maurizio Cimadamore | P3 | Resolved | Fixed | b03 |
Description
The Javadoc of MemorySegment::asByteBuffer says:
" The returned buffer's position (see Buffer.position() is initially set to zero, while the returned buffer's capacity and limit (see Buffer.capacity() and Buffer.limit(), respectively) are set to this segment' size (see byteSize()). For this reason, a byte buffer cannot be returned if this segment' size is greater than Integer.MAX_VALUE. "
That said, while this contract is respected by native segment, it does not hold for heap segments, where the resulting buffer has always the size of the underlying array.
" The returned buffer's position (see Buffer.position() is initially set to zero, while the returned buffer's capacity and limit (see Buffer.capacity() and Buffer.limit(), respectively) are set to this segment' size (see byteSize()). For this reason, a byte buffer cannot be returned if this segment' size is greater than Integer.MAX_VALUE. "
That said, while this contract is respected by native segment, it does not hold for heap segments, where the resulting buffer has always the size of the underlying array.
Attachments
Issue Links
- backported by
-
JDK-8259741 MemorySegment::asByteBuffer does not respect spatial bounds
- Resolved
-
JDK-8260129 MemorySegment::asByteBuffer does not respect spatial bounds
- Resolved