New JEP: Concise Method Bodies
alex.buckley at oracle.com
Mon Sep 24 17:17:18 UTC 2018
On 9/21/2018 4:07 PM, Kevin Bourrillion wrote:
> "The method reference form can use most kinds of method references after
> the = sign: static and unbound method references, bound method
> references (if the receiver *variable* is in scope for the method
> Can we still bind to any expression?
> private String a(String b, int c)
> throws SomeCheckedException = *d.e()*::f;
No limitation is intended on the receiver, as long as the method
reference expression would be legal if it appeared in the traditional
body of method `a`. (Details of this translation remain to be worked out.)
Scope isn't the right concept to appeal to; for example, an instance
variable is in scope throughout a static method, but that doesn't mean
the variable can be used in the body of the static method. I'll remove
the troublesome clause. Array creation references should also be
mentioned alongside constructor references.
> ... and would this be valid whether it is `e()` or `f()` (or both) that
> throws SomeCheckedException?
I expect so. Do you have a situation that suggests otherwise?
More information about the amber-spec-experts