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 251229

Summary: Incorrect NetBeans Java hint for instanceof
Product: third-party Reporter: gooddreams <gooddreams>
Component: -- Other --Assignee: issues@third-party <issues>
Status: RESOLVED FIXED    
Severity: normal CC: sdedic
Priority: P3    
Version: 8.0.2   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description gooddreams 2015-03-17 09:29:16 UTC
Product Version = NetBeans IDE 8.0.2 (Build 201411181905)
Operating System = Mac OS X version 10.9.5 running on x86_64
Java; VM; Vendor = 1.8.0_20
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.20-b23

Recently I updated NetBeans (updated some modules automatically), today I noticed it now show warning on all "instance of" conditions.
For example:
if (o instance of BigDecimal) {
    return (BigDecimal) o;
}
The warning (NetBeans hint) as below:
Dead instanceof. Object cannot be assigned to BigDecimal
----
(Alt-Enter shows hints)
Comment 1 gooddreams 2015-03-17 09:40:53 UTC
sorry, example code is:
if (o instanceof BigDecimal) {
    return (BigDecimal) o;
}
Comment 2 airdrik 2015-03-26 14:14:24 UTC
I can confirm this, using Netbeans 8.0.2 on Ubuntu Linux 14.04, using Oracle java 7, all x86_64.
The hint is flagging instanceof statements where the instance under test is an Object, or at least is a Supertype of the class being tested.
Comment 3 airdrik 2015-03-26 14:30:30 UTC
I checked the github repository for the hints plugin: https://github.com/markiewb/nb-additional-hints, and found that this bug was already submitted (issue #50 on github) and fixed in versions 1.4.1.1 and 1.5 of the nb-additional-hints plugin.

I updated the plugin to 1.5 and no longer see the false-positives.
Comment 4 Svata Dedic 2015-03-30 14:21:15 UTC
According to comment #3, marking as fixed (in the 3rd party plugin)