Lazy statics (was: Feedback / query on jextract for Windows 10)
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Feb 4 13:08:09 UTC 2021
On Wed, 2021-02-03 at 14:17 -0800, John Rose wrote:
> Seems like a clean story for the JVM and the user. It’s odd
>
> that it only applies to zero-argument methods, but it’s a plus
>
> that they *are* real methods, not some new kind of API point.
It is indeed a clean story. If I can nitpick, one bit that is missing,
or not conveyed adequately, by the once-only/cached methods is the
constant-ness property. E.g. are the results of these once-off (static)
methods true constants that C2 can rely upon? If we implement with
condy, yes, of course - but I think it is less clear that that's the
case when _reading_ the code.
E.g.
```
static MethodHandle handle1() {
MethodHandles.lookup(...);
}
one-off static MethodHandle handle2() {
MethodHandles.lookup(...);
}
handle1().invokeExact(...) // not inlined
handle2().invokeExact(...) // full speed
```
This seems subtle, as the constant-ness property doesn't strike me as
an obvious consequence of `handle2` being "one-off".
Maurizio
More information about the panama-dev
mailing list