implementation inconsistency with scope rules for Java generic types

Nick Radov nradov at axolotl.com
Wed Jun 18 10:27:53 PDT 2008


I've run across an interesting inconsistency between javac and the Java 
compiler built in to the Eclipse 3.3.2 IDE. Try compiling this piece of 
code.

        public class X<T> {
        }
        class Subclass extends X<Subclass.NestedSubclass> {
                @SuppressWarnings("unchecked")
                private final class NestedSubclass extends X {
                }
        } 

The javac compiler reports one error because the generic type parameter of 
the Subclass class has private access, but Eclipse reports no errors. I 
had reported this as an Eclipse bug, but one of the Eclipse team thinks it 
may be a javac bug. You can see the Eclipse bug report here: <
https://bugs.eclipse.org/bugs/show_bug.cgi?id=237656>.

Does anyone know for sure which is correct? As far as I can tell the JLS 
doesn't explicitly state whether this is allowed, although it may be 
implicit in the scope rules.

Nick Radov | Director, Research & Development | Axolotl Corp
www.axolotl.com, d: 408.920.0800 x116, f: 408.920.0880
160 West Santa Clara St., Suite 1000, San Jose, CA, 95113
 
THE MARKET LEADER IN HEALTH INFORMATION EXCHANGE ? PROVIDING PATIENT 
INFORMATION WHEN AND WHERE IT IS NEEDED.
 
The information contained in this e-mail transmission may contain 
confidential information. It is intended for the use of the addressee. If 
you are not the intended recipient, any disclosure, copying, or 
distribution of this information is strictly prohibited. If you receive 
this message in error, please inform the sender immediately and remove any 
record of this message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20080618/90ff1bb1/attachment.html 


More information about the compiler-dev mailing list