jextract looses type safety in generated bindings

Michael Böckling michael at boeckling.net
Wed Apr 7 10:13:35 UTC 2021


Hi!

I'm currently evaluating the different FFI options on the JVM. I have
noticed that the Java type signatures emitted by jextract are somewhat
lossy. I'll provide an example:

radar_processor.h:
    void process_radar(t_radar_measurement* in, t_radar_decision* out);

maps to:

public final class radar_processor_h  {
    public static void create_radar_measurement ( Addressable measurement)
{ ... }
}

Contrast this with JNAerator, which generates the following binding:

public static void create_radar_measurement(Pointer<t_radar_measurement >
measurement) { ... }

Notice how the t_radar_measurement* type has been erased with a generic
Addressable in the case of jextract.
What I want to do is determine function argument types of generated java
bindings via reflection and auto-instantiate the mapped structs. This works
fine in JNAerator, due to the way the bindings are generated, but not with
jextract. Is there a specific reason to use generic types like Addressable
instead of the known, more specific one like t_radar_measurement*?

Best regards,
Michael


More information about the panama-dev mailing list