Is the plan that every method handle created either via a field/constructor/executable or via java.lang.invoke.MethodHandles as part of an image's build time will work at runtime without any additional configuration?
Method handles will require some configuration. Whether it will be the existing reflection configuration or a separate one is still open.
I'm not sure I understand why you need any configuration. MethodHandles that are strongly reachable after the image creation phase will in 99.99% of all cases be meant for invocation at runtime.
MethodHandles that are strongly reachable after the image creation phase will in 99.99% of all cases be meant for invocation at runtime.
Yes, and such method handles will work without configuration. Same as reflection: if you have a java.lang.reflect.Method instance strongly reachable in the image heap, it works without further configuration.
But if you create new method method handle at run time, then you need configuration at image build time.
Sounds great. I must admit the more I work with MHs the less my need for runtime support for them. Transformations via the various static methods on MethodHandles can mostly be done at image creation time. The only thing I actually miss is being able to bind object instances that cannot be created until runtime. For example, via MethodHandle#bindTo or MethodHandles#insertArguments
Are invokedynamic instructions supported whose bootstrap method returns a dynamically computed ConstantCallSite?
When everything is finished, all aspects of method handles including bootstrap methods will be supported.
I'm aware MethodHandle support is not complete, but there's something about the current status that found slightly surprising and wondered if in the future it'd be improved: @yrodiere was playing with MethodHandle.Lookup.findVirtual and it didn't work when used on a non-final method on a non-final class that was not extended in the codebase. You'd get error ...could not be reduced to at most a single call or single field access.... The example worked when either the class or method was made final, but I wondered: if the class is not extended by anyone, couldn't the close world analysis deduce that the class and method were virtually final?
about how to proceed, I try to analyse how to implement it, am I right ?:
Most helpful comment
When everything is finished, all aspects of method handles including bootstrap methods will be supported.