RFR: 8321786: SegmentAllocator:allocateFrom(ValueLayout, MemorySegment,ValueLayout,long,long) spec mismatch in exception scenario
Per Minborg
pminborg at openjdk.org
Tue Dec 12 11:52:31 UTC 2023
On Tue, 12 Dec 2023 11:45:22 GMT, Per Minborg <pminborg at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/foreign/SegmentAllocator.java line 737:
>>
>>> 735: private MemorySegment allocateNoInit(MemoryLayout layout, long size) {
>>> 736: long byteSize;
>>> 737: try {
>>
>> I don't think we want this. While it is more correct, that would negatively affect performance. If there's an overflow, let it go negative, it will be caught anyway
>
> True. But we will get the wrong type of exception.
We could change the exception type to `ArithmeticException` in this case and get performance and correctness at the same time.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17079#discussion_r1423880997
More information about the core-libs-dev
mailing list