[FB-Discuss] Redundant nullcheck in SWITCH_TABLE

James Gula jlgula at papugh.com
Tue May 13 19:04:38 EDT 2008


I am frequently troubled by reports similar to the following which I
assume is a false positive triggered by the code that the compiler
generates for a switch table. In all the problem cases, I am switching
on an enum value but unfortunately, I can't get it to recreate in a
simple example. I have attached an example with the offending source
file and the resulting class file but unfortunately these can't be
compiled standalone without pulling in a bunch of additional stuff.

This problem is particularly annoying because the only way to turn off
the warning is to suppress RCN for the whole class. 

I am using Findbugs 1.3.4 20080506 with JSDK 1.6.0 u6 under Eclipse
3.3.3 and OpenSuse 10.3 although I've seen the problem through multiple
versions of everything.

L D RCN: Redundant nullcheck of
$dialog$MessageBoxIcon, which is known to be non-null in
$dialog$MessageBoxIcon()	dablr-0.0.3/src/main/java/org/dablr/lib/gui/swt
SwtMessageBox.java	line 26	1210717722362	58619

This is triggered by the following code.

	public static int convertIconToSwt(final MessageBoxIcon icon) {
		switch(icon) {
		case ERROR:
			return SWT.ICON_ERROR;
		case WARNING:
		case QUESTION:
		case WORKING:
			throw new EnhancedIllegalArgumentException("icon", "unexpected icon
value: " + icon.toString());


Can anyone shed some light on the issue?


James Gula
2018 Galaxy
Newport Beach, CA 92660
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cs.umd.edu/pipermail/findbugs-discuss/attachments/20080513/ac43e810/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SwtMessageBox.java
Type: text/x-java
Size: 4399 bytes
Desc: not available
URL: <https://mailman.cs.umd.edu/pipermail/findbugs-discuss/attachments/20080513/ac43e810/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SwtMessageBox.class
Type: application/x-java
Size: 4737 bytes
Desc: not available
URL: <https://mailman.cs.umd.edu/pipermail/findbugs-discuss/attachments/20080513/ac43e810/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3153 bytes
Desc: not available
URL: <https://mailman.cs.umd.edu/pipermail/findbugs-discuss/attachments/20080513/ac43e810/attachment-0002.bin>

More information about the Findbugs-discuss mailing list