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 246658 - "Type cast to X is too strong" hint leads to incorrect cast
Summary: "Type cast to X is too strong" hint leads to incorrect cast
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-23 12:32 UTC by _ gtzabari
Modified: 2015-09-17 01:27 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2014-08-23 12:32:21 UTC
Product Version: NetBeans IDE Dev (Build 201408220001)
Java: 1.8.0_20; Java HotSpot(TM) 64-Bit Server VM 25.20-b23
Runtime: Java(TM) SE Runtime Environment 1.8.0_20-b26
System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev

Given:

public void fire(Connection connection, Object[] oldRow, Object[] newRow)
{
	if ((Byte) newRow[0] != 0)
		return;
	[...]
}

Netbeans suggests "Type cast to Byte is too strong. int should be used instead" which is incorrect because the array element is a Byte. Casting it to an "int" will result in a ClassCastException.
Comment 1 Svata Dedic 2015-09-15 12:57:20 UTC
Should be fixed in jet-main#2ef72f2565fb; the hint should disappear in ambiguous situations.
Comment 2 Quality Engineering 2015-09-17 01:27:13 UTC
Integrated into 'main-silver', will be available in build *201509170002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/2ef72f2565fb
User: Svata Dedic <sdedic@netbeans.org>
Log: #246658: wrong test for incompatible upcasts