JDK-8059921 : Missing compile error in Java 8 mode for Interface.super.field access
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u20,8u40
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2014-09-30
  • Updated: 2015-06-04
  • Resolved: 2014-11-20
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
8u40Fixed 9 b42Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b20)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b20, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows.
All

A DESCRIPTION OF THE PROBLEM :
interface T2 { int f = 0; }
interface T extends T2 { int f = 0; }
class X  implements T {	
	int i = T.super.f;
}

The compiler compiles the code without any issues. 

JLS 15.11.2. Accessing Superclass Members using super
"The form T.super.Identifier refers to the field named Identifier of the lexically enclosing instance corresponding to T, but with that instance viewed as an instance of the superclass of T."
The statement does not mention anything about Interfaces. 

In my opinion the compiler should throw for T.super.f.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
interface T2 { int f = 0; }
interface T extends T2 { int f = 0; }
class X  implements T {	
	int i = T.super.f;
}

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The compiler should throw for T.super.f.
ACTUAL -
The code compiles fine without any issues.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
interface T2 { int f = 0; }
interface T extends T2 { int f = 0; }
class X  implements T {	
	int i = T.super.f;
}
---------- END SOURCE ----------


Comments
This regression has been introduced by JDK-7192246
30-10-2014

This is probably caused by the fact that the compiler has been changed in 8 to allow default method super calls as in T.super.m() Apparently, the compiler now always allow qualified super, even for fields.
14-10-2014

This seems a regression as the compiler threw an error for T.super.f identifier with JDK 6u45, and 7u67, whereas it compiled fine with 8u20 and 8u40 (build8).
08-10-2014