"#define" constants as methods

Klaus Malorny Klaus.Malorny at knipp.de
Thu Apr 4 14:00:20 UTC 2024


Hi,

I have two projects which currently use JNI and which need to be 
migrated eventually, so I started playing around with Java 22's foreign 
package and the jextract code generator (Build 22-jextract+3-13). What 
puzzles me so far is the fact that constants are generated as methods 
(which actually use static private member variables with the same name). 
This seems to be cumbersome, especially if they are error codes like in 
my case and I want to use them in a switch statement. Maybe there is a 
reasoning behind it, but I can't imagine it ;-)

Besides this, another (dumb) question: How will the tool be finally 
published? Will it become part of the JDK?

Regards,
Klaus



More information about the jextract-dev mailing list