[foreign-memaccess+abi] RFR: 8296417: Make memory session a pure lifetime abstraction [v3]

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Nov 4 22:27:12 UTC 2022


On Fri, 4 Nov 2022 19:24:04 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Fix vector tests
>
> test/jdk/java/foreign/TestSegmentAllocators.java line 90:
> 
>> 88:                     } catch (IndexOutOfBoundsException | IllegalStateException ex) {
>> 89:                         //failure is expected if bound
>> 90:                         assertTrue(isBound);
> 
> Not sure I get this `catch`. AFAICS only a slicing allocator is bound, which should result in `NULL` being returned, not an exception, right?

You are correct in the sense that slicing allocator returns NULL when it cannot allocate. However, if we allocate using e.g. `SegmentAllocator.allocate(ValueLayout.OfInt, int)` there will be issues because the returned segment has zero size and we will be trying to set a value on it. I think returning NULL here is perhaps too clever, we should just throw IOOBE on the allocate method - agree?

-------------

PR: https://git.openjdk.org/panama-foreign/pull/750


More information about the panama-dev mailing list