[foreign] RFC: Lazy symbol resolution

Jorn Vernee jbvernee at xs4all.nl
Thu Jan 17 13:04:50 UTC 2019


Hi,

Currently HeaderImplGenerator eagerly resolves symbols from the native 
header interface while generating the backing implementation. Sometimes 
the symbols defined in a single header are compiled into multiple shared 
libraries. All of those libraries have to be included when jextracting 
the header with `-l`, and all of them have to be loaded when generating 
the header interface implementation. Because symbols are eagerly 
resolved, every symbol in a header has to be loaded at the time of 
header generation.

I've thrown together a patch which trades in the eager resolution for 
lazy resolution using dynamic constants that were recently added to the 
jdk. Using the flag java.foreign.binder.LAZY_RESOLUTION=true the 
bahaviour can be turned on. The main advantage is that not every symbol 
in a header interface has to be present at runtime, while symbols that 
_are_ present can still be used.

Webrev: 
http://cr.openjdk.java.net/~jvernee/panama/webrevs/lazyresolution/webrev.00/

What do you think of this idea? Is lazy resolution desirable?

Jorn


More information about the panama-dev mailing list