Community
Participate
Working Groups
Build Identifier: I20100129-1300 Eclipse gives a compiler error in the "test()" method of the following class: class OuterClass<T> { class BaseClass { } class SubClass extends BaseClass { } public void test(BaseClass myObject) { boolean b = (myObject instanceof OuterClass.SubClass); } } The error is: "Incompatible conditional operand types MyOuterClass<T>.MyBaseClass and MyOuterClass.MySubClass" However, Sun's JVM (build 1.6.0_22-b04), which Eclipse is using, compiles the class without an error. This bug HAS ALREADY BEEN FIXED: it does not occur in Eclipse build M20110210-1200. I am only entering this bug to document it. Reproducible: Always
Just for the record, Eclipse correctly flags the following lines as errors: boolean b1 = (myObject instanceof SubClass); boolean b2 = (myObject instanceof SubClass<T>); boolean b3 = (myObject instanceof SubClass<?>); boolean b4 = (myObject instanceof OuterClass<T>.SubClass); boolean b5 = (myObject instanceof OuterClass.SubClass<T>); boolean b6 = (myObject instanceof OuterClass.SubClass<?>); Also for the record, I initially posted a question about this to StackOverflow: http://stackoverflow.com/questions/6849591/problem-with-instanceof-with-generic-outer-class
Because this bug does not occur in build M20110210-1200, I am marking this bug resolved.
(In reply to comment #0) > However, Sun's JVM (build 1.6.0_22-b04), which Eclipse is using, compiles the > class without an error. Just to clarify: JVM does not "compile" code. The compiler does. And if you did mean the compiler, note that Eclipse does not use the Sun javac compiler. We have our own Eclipse Compiler for Java(ECJ). > This bug HAS ALREADY BEEN FIXED: it does not occur in Eclipse build > M20110210-1200. I am only entering this bug to document it. I guess there's no point opening a bug when you don't see it any more. We always fix bugs in the open so there will always be a bug that has been used to fix this patch. Thanks anyway.