JDK-8035890 : jdk8 javac -source 7 compiles test case it should not
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-02-26
  • Updated: 2014-07-29
  • Resolved: 2014-03-31
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 8 JDK 9
8u20Fixed 9 b08Fixed
Related Reports
Relates :  
Description
This test case used to result in a crash. The crash was fixed in b120 and this test case now unexpectedly compiles when using jdk8 javac and -source 7.

@interface Simple {}
class Test { 
void m1() { Integer i = new @Simple Integer(10); }
void m2() { throw new @Simple RuntimeException(); } 
}


It fails to compile as expected with jdk7 and jdk8.
Comments
Another annotation-related case which javac accepts with -source 7, while it should not accept it: --- public class AnnotAfterTypeParams { public <T> @Decl int foo() { return 0; } } @interface Decl { } ---
14-03-2014

Release team: Approved for deferral.
11-03-2014

ILW=HLH=P2 (I: breaks specification=H; L: attempts to compile programs with type annotations only in new-class expressions with source level <= 7 seem unlikely =L; W: when this happens, javac will accept the code and produce executable code for it, the only workaround is not to pass programs like this into javac with source level < 8=H)
10-03-2014

lang/ANNOT/annot110/annot11001mf/annot11001mf lang/ANNOT/annot110/annot11001mi/annot11001mi
26-02-2014

May simply be a missing source level check in JavacParser. Seems that it may possibly be related to: http://hg.openjdk.java.net/type-annotations/type-annotations/langtools/rev/53a635e47bda
26-02-2014

I'm guessing it started with the fix for JDK-8028699
26-02-2014

Looks like a serious bug to me that should be fixed sooner rather than later.
26-02-2014