RFR: 7903597: Slim down RuntimeHelper

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Dec 1 22:20:35 UTC 2023


On Fri, 1 Dec 2023 17:25:08 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Remove some of the helper methods in RuntimeHelper. They can be moved inline in the generated code.
>> 
>> Also: I've elected to move the `System.load(Library)` directives we generated inside RuntimeHelper into the first header class, in order to have it more localized to the actual code that a user sees. That also makes RuntimeHelper more 'dumb'. Only the package declaration is now injected into the template, which makes it easier for users to combined multiple extraction runs (they can just discard one of the generated RuntimeHelpers).
>
> src/main/resources/org/openjdk/jextract/impl/resources/RuntimeHelper.java.template line 67:
> 
>> 65:         try {
>> 66:             return MH_LOOKUP.findVirtual(fi, name, fdesc.toMethodType());
>> 67:         } catch (ReflectiveOperationException ex) {
> 
> I've left this `upcallHandle` method since we use it to initialize a class-level constant in the FI classes. It's useful to have the try/catch be out-of-line like this so we don't have to emit `static` blocks.

I don't disagree. In fact I think I'm in favor of also leaving downcall handle (especially the variadic variant), to avoid the repeated code.

-------------

PR Review Comment: https://git.openjdk.org/jextract/pull/150#discussion_r1412618387


More information about the jextract-dev mailing list