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

Summary: Erroneous hint: Type cast to X is too strong. Y should be used instead.
Product: java Reporter: _ gtzabari <gtzabari>
Component: HintsAssignee: Svata Dedic <sdedic>
Status: RESOLVED WORKSFORME    
Severity: normal    
Priority: P3    
Version: 8.0   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:

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.