[Fb-contrib-commit] SF.net SVN: fb-contrib: [846] trunk/fb-contrib
Brought to you by:
dbrosius
From: <dbr...@us...> - 2007-02-09 22:57:05
|
Revision: 846 http://svn.sourceforge.net/fb-contrib/?rev=846&view=rev Author: dbrosius Date: 2007-02-09 14:57:00 -0800 (Fri, 09 Feb 2007) Log Message: ----------- Fix for [ 1655774 ] NAB_NEEDLESS_AUTOBOXING_PARSE for boolean? Boolean.parseBoolean(String s) wasn't introduced until 1.5, so don't report before then. Modified Paths: -------------- trunk/fb-contrib/samples/NAB_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java Modified: trunk/fb-contrib/samples/NAB_Sample.java =================================================================== --- trunk/fb-contrib/samples/NAB_Sample.java 2007-02-08 03:40:25 UTC (rev 845) +++ trunk/fb-contrib/samples/NAB_Sample.java 2007-02-09 22:57:00 UTC (rev 846) @@ -43,6 +43,7 @@ public void testNeedsParse(String data) { + //The first one is a false positive for < 1.5 boolean bo = Boolean.valueOf(data).booleanValue(); byte b = Byte.valueOf(data).byteValue(); short s = Short.valueOf(data).shortValue(); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-02-08 03:40:25 UTC (rev 845) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-02-09 22:57:00 UTC (rev 846) @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.Map; +import org.apache.bcel.Constants; import org.apache.bcel.classfile.Method; import edu.umd.cs.findbugs.BugInstance; @@ -96,7 +97,8 @@ boxClass = getClassConstantOperand(); if (boxClasses.containsKey(boxClass)) { if ("valueOf".equals(getNameConstantOperand()) && getSigConstantOperand().startsWith("(Ljava/lang/String;)")) { - state = SEEN_VALUEOF; + if (!"java/lang/Boolean".equals(boxClass) || (getClassContext().getJavaClass().getMajor() >= Constants.MAJOR_1_5)) + state = SEEN_VALUEOF; } else { String parseSig = parseClasses.get(boxClass); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |