jextract on large Windows header files
Duncan Gittins
duncan.gittins at gmail.com
Sun Jan 31 15:54:29 UTC 2021
I've downloaded jdk/panama-foreign and experimented with some changes to
jextract in order to help with the footprint of jars generated from the
large Windows header files that I mentioned in the thread: Feedback /
query on jextract for Windows 10.
1) Added command line args: --symbol {symbol-to-include} and --symbols
{file-of-symbols-to-include} which eliminates all top level symbols not
in the parameter list or symbol file(s). This avoids the need to
generate huge amounts of unnecessary methods.
For example in my application, "jextract shlobj_core.h" gives ~ 11MB jar
(~ 49k top level symbols), adding -filter for required small group of
header files cuts this to 880k (5k symbols), and with the --symbols
filter that is down to a 10K jar (9 symbols) which is much more
managable size to use. Also the lack of lazy load in --source output is
also no longer a problem because all static field method handles are
generally used.
2) Changed "jextract --source" so that identical FunctionDescriptor
declarations are re-used. This makes the compiled source jar a little
bit smaller than the generated class jar. For example many of the
Windows functions such as SetUserObjectInformationA /
SetUserObjectInformationW have the same descriptor, so jextract can emit
just one FUNC_ declaration and make MH_ / $FUNC() of the second refer
to the earlier declaration like this:
/** DUPLICATE => SetUserObjectInformationA$FUNC_
static final FunctionDescriptor SetUserObjectInformationW$FUNC_ =
FunctionDescriptor.of(C_INT,C_POINTER,C_INT,C_POINTER,C_LONG);
*/
static final jdk.incubator.foreign.FunctionDescriptor
SetUserObjectInformationW$FUNC() { return
SetUserObjectInformationA$FUNC_; }
If you think either of these will help, I can share the small set of
changes I made.
Duncan
More information about the panama-dev
mailing list