[foreign-jextract] Missing getters/setters for pointers within generated classes
Filip Krakowski
krakowski at hhu.de
Fri Jun 26 16:45:25 UTC 2020
Hi,
thanks for filing an issue!
Since the TypeTranslator#visitDelegated
<https://github.com/openjdk/panama-foreign/blob/9014cc5b12fef619713fcadd2d952eed8643b9ee/src/jdk.incubator.jextract/share/classes/jdk/incubator/jextract/tool/TypeTranslator.java#L87-L91>
method returns MemoryAddress.class for delegated types of kind
"POINTER", I tried changing it so it returns MemorySegment.class
instead. In a small and simple example I wrote
(https://i.imgur.com/Alkw5oJ.png), it seems to be working fine, but I
can't really estimate the impact of changing the return value at this
location. Could this be a potential fix or are there other places than
the check mentioned in the previous mail relying on the method's return
value?
Best regards,
Filip
On 26.06.20 18:09, sundararajan.athijegannathan at oracle.com wrote:
>
> Filed an issue https://bugs.openjdk.java.net/browse/JDK-8248415
>
> Thanks
>
> -Sundar
>
> On 26/06/20 9:27 pm, 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.
>>
>> 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