Please reply to my JDK-8059640 issue comment

Dan Smith daniel.smith at
Thu Sep 3 19:12:37 UTC 2015

> On Jul 22, 2015, at 11:14 AM, Georgiy Rakov <georgiy.rakov at> wrote:
> In the example you provided inconsistency occurs at the point of *invocation of* the method of an object derived from a method reference expression. But we can consider another example which contains inconsistency occurring at the point of *evaluation of* a method reference expression:
> interface MethodSupplier {    void m(int a); }
> interface MyFunctionalInterface { int invokeMethodReference(int a); }
> class MethodSupplierImpl implements MethodSupplier {
>     @Override
>     public void m(int a) {}
> }
> MyFunctionalInterface instance = null;
> MethodSupplier ms = new MethodSupplierImpl();
> instance = ms::<Integer>m; //inconsistency occurs here
> instance.invokeMethodReference(1);
> Currently the behavior is Ok, that is provided MethodSupplierImpl is recompiled without implementing MethodSupplier, ICCE is thrown when executing "instance.invokeMethodReference(1)". But potentially it looks possible for the error to be thrown during executing "instance = ms::<Integer>m" and suggested spec change doesn't encompass this case. So I wonder if it's worth encompassing such case for the suggested spec change.

Would it be possible to detect the error at that point?  Sure.  Do we want to change the spec to do so?  No.

The currently-specified behavior is consistent with actual behavior, and is fine: the check that the receiver implements an interface happens at the point that the invocation is about to happen.

> Could you please also tell if I understand correctly that suggested spec change specifies the possibility of throwing LinkageError during *evaluation of* method reference and not during *invocation of* the method of an object derived from a method reference expression.

Yep.  JDK-8059640 is only concerned with behavior that occurs during evaluation.

The possibility of LinkageErrors occurring during invocation is already covered by the spec -- 15.13.3 says: "Run-time evaluation of the method invocation expression is as specified in §, §, and §".


More information about the compiler-dev mailing list