JDK-8131742 : Syntactically meaningless code accepted by javac
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8,9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_8
  • CPU: x86
  • Submitted: 2015-07-16
  • Updated: 2015-11-03
  • Resolved: 2015-07-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b76Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows

A DESCRIPTION OF THE PROBLEM :
The following code has a syntax error, but is nonetheless accepted by javac:

class A {
    static Runnable r = (__GAR BAGE__.this) -> { };
}


REGRESSION.  Last worked in version 7u85

ADDITIONAL REGRESSION INFORMATION: 
This was a syntax error in previous versions.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac A.java

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Syntax error
ACTUAL -
No error and class file produced

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
class A {
    static Runnable r = (__GAR BAGE__.this) -> { };
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
If it hurts, don't do that.


Comments
The issue is being reproduced with jdk8 b132 on Window 8.1 x64 (spb23155) C:\jdk>c:/jdk/jdk1.8.0b132/bin/java -version java version "1.8.0" Java(TM) SE Runtime Environment (build 1.8.0-b132) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode) C:\jdk>c:/jdk/jdk1.8.0b132/bin/javac A.java C:\jdk>
02-11-2015

Maxim S, please find out in what JDK 8 release was the issue introduced.
02-11-2015

Receiver parameter logic for type annotations is not disabled when parsing lambda formals, hence the issue.
21-07-2015

Checked this (A.java) for 7u80, 8u51, 8u60 ea b23, and 9 ea b72. The code compiles fine with all JDK 8 versions with a class file generated. However the code fails to compile with JDK 7u80 with syntax error: > javac A.java A.java:2: error: ')' expected static Runnable r = (__GAR BAGE__.this) -> { }; ^ A.java:2: error: ';' expected static Runnable r = (__GAR BAGE__.this) -> { }; ^ 2 errors ------------------------------------------------------------------------
17-07-2015