This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 199169 - instanceof Will Not Allow Comparison to a Method's Return Value
Summary: instanceof Will Not Allow Comparison to a Method's Return Value
Status: RESOLVED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.0
Hardware: PC Windows 7 x64
: P1 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-05 03:34 UTC by cbush06
Modified: 2011-11-16 16:41 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot of NetBeans syntax error (333.94 KB, image/jpeg)
2011-06-05 03:34 UTC, cbush06
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cbush06 2011-06-05 03:34:06 UTC
Created attachment 108730 [details]
Screenshot of NetBeans syntax error

I have a method titled "getSupportedClass()" that returns the Class object representing an object's class (e.g. o.getClass()).

I cannot use the method with the instanceof operator.

For example:

if(anObject instanceof anotherObject.getSupportedClass())

I believe the issue lies in the parser used by netbeans. I even tried having the method return a Type object (although Class objects implement Type). Either way, I receive a syntax error from NetBeans. NetBeans seems to expect only the name of the class instanceof is comparing an object to.

I have attached a screenshot with the error to this.
Comment 1 Jan Lahoda 2011-06-05 08:56:37 UTC
Sorry, but the Java language requires the second parameter of the instanceof operator to be a reference type, e.g. "String" or "java.util.List" (JSL 15.20.2). The second parameter cannot be an expression. Please see java.lang.Class.isAssignable.