RFR: 7903660: Drop layout-inferring varargs invoker + add method handle factory [v3]

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Feb 12 17:18:06 UTC 2024


On Mon, 12 Feb 2024 17:00:35 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> (1), I noticed at least IntelliJ also shows the `MemoryLayout...` argument type when auto-completing, so that helps to understand what's going on. It's true that having a top-level function makes it easier to do 'one line invocations'. But, maybe we want to push people towards stashing invokers into `static final` fields? i.e. I think the fact that this:
> 
> ```
> printf.invoker(C_INT).apply(formatSegment, 42);
> ```
> 
> looks a bit weird is actually a good thing. Fine for quick and dirty use, but clients should really re-use the invoker. (we could use the name `makeInvoker` to signal that this is an expensive operation as well).
> 
> (2). I agree with that reasoning

I don't have a strong opinion on (1). I suppose that, as long as `invoker` is the _only_ static method in `printf`, auto-completion should work fine (and hide the other methods, such as the descriptor accessor). The only issue is, perhaps, that it might be surprising for the user to realize that `printf` is not a method. For instance, when auto-completing `print`, the auto-completion pop up will likely just show that there's some `printf` (a type) and complete up to there. So the user will have to press `.` again, to discover that there's a factory in there worth calling.

That said, variadic functions are just different from regular functions in many ways. So I could go either way.

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

PR Comment: https://git.openjdk.org/jextract/pull/205#issuecomment-1939180575


More information about the jextract-dev mailing list