JDK-6493167 : Illegal access to static member in parameterized type
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-11-13
  • Updated: 2014-02-26
  • Resolved: 2013-09-06
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 7 JDK 8
7Fixed 8Fixed
Related Reports
Relates :  
Description
"If a type name is of the form Q.Id, then Q must be either a type name 
or a package name. If Id names exactly one type that is a member of the 
type or package denoted by Q, then the qualified type name denotes that 
type.

If Id does not name a member type within Q (8.5,9.5), or the member type 
named Id within Q is not accessible (6.6), or Id names more than one 
member type within Q, ***or Id names a static member type (8.5.2) within 
Q and Q is parameterized***, then a compile-time error occurs."

Comments
The change made to 6.5.5.2 in JLS7 was inappropriate because TypeNames, as considered in massive detail by 6.5, are never parameterized. Therefore, 6.5.5.2 should revert to its JLS3 text: "If a type name is of the form Q.Id, then Q must be either a type name or a package name. If Id names exactly one accessible type that is a member of the type or package denoted by Q, then the qualified type name denotes that type. [The following paragraph reverts to JLS3] *** If Id does not name a member type within Q, or the member type named Id within Q is not accessible, or Id names more than one member type within Q, then a compile-time error occurs. ***" Instead, the rule prohibiting Foo<...>.Bar when Bar is static should be given in 4.5.2 "Members and Constructors of Parameterized Types": "*** A static member that is declared in a generic type declaration must be referred to using the non-generic type that corresponds to the generic type (6.1), or a compile-time error occurs. // In other words, it is illegal to refer to a static member declared in a generic type declaration by using a parameterized type. ***" (The "non-generic type" concept is being introduced by JSR 308 to clarify where types are used versus type names.)
17-07-2013

EVALUATION Will update JLS 6.5.5.2 in due course. In the clause "or Id names a static member type (8.5.2) within Q and Q is parameterized", the intent is that the term Q is parameterized, regardless of whether the type that Q names is generic. The type that Q names *can* be generic. Thus given the legal code: class Foo<T> { static Bar {} } the typename Foo.Bar is legal but the typename Foo<...anything...>.Bar is illegal.
13-11-2006