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: 2023-10-16
  • 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.
JDK 7
7 b40Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
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:
JCK-compiler-7/tests/lang/TYPE/type154/type15406/type15406.html
forbits access to package private members:
JCK-compiler-7/tests/lang/CONV/conv148/conv148.html
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).

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

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.
30-09-2008

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