| Summary: | [null][compiler] False warning that "instanceof always yields false". | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Brian Miller <Brian.Miller> |
| Component: | Core | Assignee: | Stephan Herrmann <stephan.herrmann> |
| Status: | VERIFIED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P5 | CC: | amj87.iitr, jarthana, jonathan_amir, markus.kell.r, Olivier_Thomann, remy.suen, stephan.herrmann |
| Version: | 3.4 | ||
| Target Milestone: | 3.6 M7 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
I run into the same problem.
Here's the code snippet:
Object obj = null;
if ((obj = "") instanceof String) {
}
*** This bug has been marked as a duplicate of bug 305590 *** Verified for 3.7M6 using build I20110301-1537 |
Build ID: I20080617-2000 (3.4.0) Steps To Reproduce: 1. Please see that there are no warnings in class Bug. 2. Disable LINE 11 by commenting it out. 3. Enable LINE 12 by uncommenting it. See the bogus warning. ---------------- Bug.java -------------------- import static java.beans.Introspector.getBeanInfo; import java.beans.PropertyDescriptor; import java.lang.reflect.*; import java.util.List; class Bug { void method() throws Exception{ for(PropertyDescriptor prop:getBeanInfo( Bug.class).getPropertyDescriptors()){ final Method get= prop.getReadMethod(); final Type type; //LINE 11 //Type type=null; //LINE 12 final ParameterizedType kind; if(null!=get&&(type=get.getGenericReturnType())instanceof ParameterizedType&& List.class==(kind=(ParameterizedType)type).getRawType()&&Bug.class==kind.getActualTypeArguments()[0]) return; } } }