After JDK-8131742 was fixed the following code with syntax error won't compile any more:
class A {
static Runnable r = (__GAR BAGE__.this) -> { };
}
Compilation error:
A.java:2: error: ',', ')', or '[' expected
static Runnable r = (__GAR BAGE__.this) -> { };
^
A.java:2: error: as of release 8, 'this' is allowed as the parameter name for the receiver type only, which has to be the first parameter
static Runnable r = (__GAR BAGE__.this) -> { };
^
A.java:2: error: ';' expected
static Runnable r = (__GAR BAGE__.this) -> { };
^
3 errors
I believe the second message is confusing because receiver parameter is not allowed in FormalParameters of a lambda expression (JLS 15.27.1. Lambda Parameters) at all.