JDK-6711619 : javac doesn't allow access to protected members in intersection types
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-06-06
  • Updated: 2012-03-22
  • Resolved: 2011-05-17
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.
7 b40Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
javac doesn't seem to handle intersection types membership in a consistent way (it allows access to protected members but forbids access to package private members)
there are several tck tests regarding this issue:
allows access to protected members:
forbits access to package private members:
There's also another related problem:

class X<E extends X<E>> {
             private static int i;
             int f() {
                     return E.i;

'i' shouldn't be accessible from E since is private (and type variable should not inherit private members).

SUGGESTED FIX A webrev of this fix is available at the following URL http://hg.openjdk.java.net/jdk7/tl/langtools/rev/4d2d8b6459e1

EVALUATION There are two problems here: 1) accessibility doesn't seem to work in complex scenario in which a member is accessed on an intersection type whose supertype is a captured type variable. 2) No accessibility check is performed when accessing a member of a plain type variable, as in T.e The problem in 1) is directly related to the one described in 6531090; in that CR it has been described a similar problem affecting method resolution; a similar patch should be applied to accessibility check as well. The problem 2) is a relatively straightforward bug during attribution.

EVALUATION Will fix. Now we have a better idea of intersection type membership.