On Tue, 12 Dec 2023 11:45:22 GMT, Per Minborg <pminb...@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