Bug 242131 - [null][compiler] False warning that "instanceof always yields false".
Summary: [null][compiler] False warning that "instanceof always yields false".
Status: VERIFIED DUPLICATE of bug 305590
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P5 normal (vote)
Target Milestone: 3.6 M7   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-25 18:39 EDT by Brian Miller CLA
Modified: 2011-03-07 05:28 EST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Miller CLA 2008-07-25 18:39:16 EDT
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;
		}
	}
}
Comment 1 Jonathan Amir CLA 2008-10-22 16:12:58 EDT
I run into the same problem.
Here's the code snippet:

Object obj = null;
if ((obj = "") instanceof String) {
}
Comment 2 Stephan Herrmann CLA 2011-02-28 07:10:34 EST

*** This bug has been marked as a duplicate of bug 305590 ***
Comment 3 Ayushman Jain CLA 2011-03-07 05:28:49 EST
Verified for 3.7M6 using build I20110301-1537