[foreign-jextract] RFR: 8263018: Improve API for lifecycle of native resources [v2]

Jorn Vernee jvernee at openjdk.java.net
Wed Mar 24 14:59:51 UTC 2021


On Wed, 24 Mar 2021 14:36:19 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Actually, I think the code is correct, as the generated "main" method will either have no allocator argument (in case return is not a struct) or will have allocator parameter (in case return is struct). The issue with the code is that, when no  allocator argument is present, we should pass DEFAULT_ALLOCATOR to the underlying MH.
>
> Scratch that - we don't need a new allocator parameter when struct is not returned as the underlying MH doesn't take an allocator.
> 
> I think the code is fine as is.

Ah, right. I see now we get:
MS func(SegmentAllocator, ...)
MS func(...) // uses default scope
MS func(ResourceScope, ...)

I misread this as the first overload not taking an allocator. What you have looks good.

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

PR: https://git.openjdk.java.net/panama-foreign/pull/474


More information about the panama-dev mailing list