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 242255 - Erroneous hint: Type cast to X is too strong. Y should be used instead.
Summary: Erroneous hint: Type cast to X is too strong. Y should be used instead.
Status: RESOLVED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-24 04:57 UTC by _ gtzabari
Modified: 2014-08-13 14:56 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-02-24 04:57:19 UTC
Product Version: NetBeans IDE Dev (Build 201402190001)
Java: 1.8.0-ea; Java HotSpot(TM) 64-Bit Server VM 25.0-b66
Runtime: Java(TM) SE Runtime Environment 1.8.0-ea-b124
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

1. Given:

	/**
	 * @param value the parameter value
	 * @param name  the parameter name
	 * @return the BigInteger representation of the parameter
	 * @throws NumberFormatException if value is not a valid representation of BigInteger
	 */
	private static BigInteger requireBigInteger(String value, String name)
		throws NumberFormatException
	{
		try
		{
			return new BigInteger(value);
		}
		catch (NumberFormatException e)
		{
			throw (NumberFormatException) new NumberFormatException("Invalid " + name + ": " + value).
				initCause(e);
		}
	}

2. Netbeans annotates the line containing the throw statement with: "Type cast to NumberFormatException is too strong. RuntimeException should be used instead" which is incorrect.
Comment 1 Svata Dedic 2014-08-13 14:56:35 UTC
Worksforme in Dev version; most likely works in 8.0.1RC as well - there were some changes to the "Too strong cast" hint, although I cannot pinpoint the exact version changing the behaviour for this case.