[foreign-jextract] Missing getters/setters for pointers within generated classes

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Jun 26 17:55:00 UTC 2020


On 26/06/2020 16:57, Filip Krakowski wrote:
> Hi,
>
> since this is a real problem for us, I would like to ask if I can help 
> in any way.
>
> I ran jextract through IntelliJ with a debugger attached and found 
> that OutputFactory#visitVariable specifically checks for pointer 
> fields and skips them 
> <https://github.com/openjdk/panama-foreign/blob/d8febd61c206db4f2d94dba3b5be48b701b28f1c/src/jdk.incubator.jextract/share/classes/jdk/incubator/jextract/tool/OutputFactory.java#L401-L405>. 
> Does this mean getting and setting pointer fields is not supported by 
> design? By removing the mentioned check (clazz == 
> MemoryAddress.class), the expected methods are generated, but fail 
> when called with an IllegalArgumentException.

The IAE is issued because the underlying VarHandle is created with a 
MemoryAddress carrier, which is not supported. Like the synthetic 
Cpointer class does, a `long` VarHandle should be created and then 
adapted using the MemoryHandles.asAddressVarHandle adapter.

Maurizio

>
> Is there an issue within the Java Bug System I can follow regarding 
> this problem?
>
> Best regards,
> Filip
> Email Signature
> On 6/22/20 12:59 PM, sundararajan.athijegannathan at oracle.com wrote:
>> Hi Filip,
>>
>> I tried with a simple struct with one pointer type field.  As you 
>> mentioned, getters/setters are not generated for pointer fields. 
>> Thanks for reporting the issue.
>>
>> Thanks
>>
>> -Sundar
>>
>> On 22/06/20 3:46 pm, Filip Krakowski wrote:
>>> Hi,
>>>
>>> I am currently experimenting with Project Panama and using jextract 
>>> to generate bindings for the ibverbs library. I just noticed that 
>>> within the generated classes pointers are skipped since no 
>>> getter/setters are created for them. The header file parsed by 
>>> jextract can be found here :
>>>
>>> https://github.com/linux-rdma/rdma-core/blob/55b51135cab1c0a7f28516a636d5790c2cfca225/libibverbs/verbs.h 
>>>
>>>
>>>
>>> As an example you can look at the struct ibv_mw :
>>>
>>> https://github.com/linux-rdma/rdma-core/blob/55b51135cab1c0a7f28516a636d5790c2cfca225/libibverbs/verbs.h#L646-L652 
>>>
>>>
>>>
>>> The generated class Cibv_mw contains getters and setters for rkey, 
>>> handle and type but is missing them for context and pd. In some 
>>> places the ibverbs API requires setting pointers within structs. Are 
>>> these missing methods the normal behavior or am I doing something 
>>> wrong here?
>>>
>>> Best regards,
>>> Filip
>


More information about the panama-dev mailing list