You're right. I can confirm this works like a charm on JDK 9:
MethodHandles.Lookup lookup =
MethodHandles.privateLookupIn(loadedClass,
MethodHandles.lookup());
CallSite site = LambdaMetafactory.metafactory(lookup,
Hi Geoffrey,
since 9 there's MethodHandles.privateLookup(Class, Lookup)[1] to get
hold of a Lookup with the full, private capabilities of a specific
class, as required by LambdaMetafactory.
Replacing line 62 in your sample with the following should work:
MethodHandles.Lookup lookup
Hi all,
As a developer for a Java framework, I 'd like to use the MethodHandle API
or the LambdaMetafactory as an alternative to code generation or reflection
to call getter/setters on my user's classes, often loaded by another
classloader.
Because non-static MethodHandles are currently too slow