Windows API Generator

Paul Sandoz paul.sandoz at oracle.com
Wed Jun 4 20:16:42 UTC 2025


Hi Manuel,

Very interesting approach, and I think a good one when a rich platform/framework provides metadata that cannot be or not easily be represented in C header files. A specific tool in these cases should result in superior binding APIs.

I have seen a very similar approach applied to generate Java bindings to Gtk, GStreamer etc, operating on the GObject introspection files rather than the C header files.

  https://jwharm.github.io/java-gi/

So you are in good company here :-)

Paul.


On Jun 4, 2025, at 9:12 AM, Manuel Bleichenbacher <manuel.bleichenbacher at gmail.com> wrote:

Dear Panama team

Here is a project I would like to bring to your attention: Windows API Generator (https://github.com/manuelbl/WindowsApiGenerator) generates Java code for accessing the Windows API using the FFM API.

For the Windows API, it achieves something similar to jextract. Unlike jextract, it does not process C header files. Instead, the generator processes rich metadata curated by Microsoft. And it takes full advantage of it...

The generator produces code for functions, structs, unions, callback functions, constants, enumerations and COM interfaces. It adds the call state capture parameter where necessary, produces code for structs of variable size, automatically initializes the "cbSize" field etc. COM objects can be called from Java, and they can be implemented in Java. Constants do not just cover integer constants, but also strings, GUIDs, DEVPKEYs and more.

The generator is easy to use as it is available both as a Maven and Gradle plugin. And it is sufficient to specify a small number of functions and structs in pom.xml or build.gradle. The related types such a function parameter types or types referenced by structs will be added automatically.

For the Java Does USB project (https://github.com/manuelbl/JavaDoesUSB), it has tremendously helped to remove manually written code that was beyond the capability of jextract, and to simplify the code using variable size structs and non-integer constants.

Regards
Manuel


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20250604/dfed6801/attachment-0001.htm>


More information about the panama-dev mailing list