fb-contrib-commit Mailing List for fb-contrib (Page 38)
Brought to you by:
dbrosius
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(56) |
Oct
(60) |
Nov
(58) |
Dec
(89) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(66) |
Feb
(55) |
Mar
(85) |
Apr
(115) |
May
(35) |
Jun
(28) |
Jul
(3) |
Aug
(48) |
Sep
(37) |
Oct
(22) |
Nov
(14) |
Dec
(66) |
2007 |
Jan
(45) |
Feb
(63) |
Mar
(10) |
Apr
(1) |
May
(1) |
Jun
(12) |
Jul
|
Aug
|
Sep
(25) |
Oct
(21) |
Nov
(39) |
Dec
|
2008 |
Jan
(7) |
Feb
|
Mar
(26) |
Apr
(5) |
May
(2) |
Jun
(32) |
Jul
(9) |
Aug
(10) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
|
2009 |
Jan
(10) |
Feb
(31) |
Mar
(32) |
Apr
(35) |
May
(25) |
Jun
|
Jul
(31) |
Aug
(10) |
Sep
(95) |
Oct
(35) |
Nov
(10) |
Dec
(34) |
2010 |
Jan
(90) |
Feb
(4) |
Mar
(7) |
Apr
(20) |
May
(20) |
Jun
(13) |
Jul
(7) |
Aug
(18) |
Sep
(25) |
Oct
(4) |
Nov
(16) |
Dec
(2) |
2011 |
Jan
(1) |
Feb
|
Mar
(11) |
Apr
(3) |
May
(2) |
Jun
(26) |
Jul
(10) |
Aug
(2) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
2012 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(14) |
Nov
(3) |
Dec
(4) |
2013 |
Jan
(3) |
Feb
(2) |
Mar
(1) |
Apr
(4) |
May
|
Jun
(1) |
Jul
(3) |
Aug
|
Sep
|
Oct
(4) |
Nov
(3) |
Dec
(3) |
2014 |
Jan
(4) |
Feb
(2) |
Mar
(4) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(3) |
Dec
(3) |
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
(2) |
Nov
(7) |
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
(5) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(3) |
2018 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(5) |
Jun
(2) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dbr...@us...> - 2007-09-19 04:45:52
|
Revision: 916 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=916&view=rev Author: dbrosius Date: 2007-09-18 21:45:54 -0700 (Tue, 18 Sep 2007) Log Message: ----------- find new StringBuilder(a + "1") Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-09-19 01:52:13 UTC (rev 915) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-09-19 04:45:54 UTC (rev 916) @@ -81,18 +81,27 @@ if (seen == INVOKESPECIAL) { String calledClass = getClassConstantOperand(); + String signature = getSigConstantOperand(); if (("java/lang/StringBuffer".equals(calledClass) || "java/lang/StringBuilder".equals(calledClass)) - && "<init>".equals(getNameConstantOperand()) - && "()V".equals(getSigConstantOperand())) { - OpcodeStack.Item itm = getStringBufferItemAt(2); - if (itm != null) { - nestedSB = Boolean.TRUE; - } else { - itm = getStringBufferItemAt(1); + && "<init>".equals(getNameConstantOperand())) { + if ("()V".equals(signature)) { + OpcodeStack.Item itm = getStringBufferItemAt(2); if (itm != null) { nestedSB = Boolean.TRUE; } + } else if ("(Ljava/lang/String;)V".equals(signature)) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + nestedSB = (Boolean)itm.getUserValue(); + if (nestedSB != null) { + bugReporter.reportBug( + new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } } } } else if (seen == INVOKEVIRTUAL) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-19 01:52:10
|
Revision: 915 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=915&view=rev Author: dbrosius Date: 2007-09-18 18:52:13 -0700 (Tue, 18 Sep 2007) Log Message: ----------- Look for new StringBuffer(a + "1") Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-09-19 01:40:44 UTC (rev 914) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-09-19 01:52:13 UTC (rev 915) @@ -88,6 +88,11 @@ OpcodeStack.Item itm = getStringBufferItemAt(2); if (itm != null) { nestedSB = Boolean.TRUE; + } else { + itm = getStringBufferItemAt(1); + if (itm != null) { + nestedSB = Boolean.TRUE; + } } } } else if (seen == INVOKEVIRTUAL) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-19 01:40:40
|
Revision: 914 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=914&view=rev Author: dbrosius Date: 2007-09-18 18:40:44 -0700 (Tue, 18 Sep 2007) Log Message: ----------- add extra case Modified Paths: -------------- trunk/fb-contrib/samples/ISB_Sample.java Modified: trunk/fb-contrib/samples/ISB_Sample.java =================================================================== --- trunk/fb-contrib/samples/ISB_Sample.java 2007-09-19 01:30:49 UTC (rev 913) +++ trunk/fb-contrib/samples/ISB_Sample.java 2007-09-19 01:40:44 UTC (rev 914) @@ -70,6 +70,12 @@ return sb.toString(); } + public void testCtorIssue(String a) + { + StringBuffer sb1 = new StringBuffer(a + "1"); + StringBuilder sb2 = new StringBuilder("2" + a); + } + public String testFPISB9(String a, String b, String c) { String d = a + c; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-19 01:30:47
|
Revision: 913 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=913&view=rev Author: dbrosius Date: 2007-09-18 18:30:49 -0700 (Tue, 18 Sep 2007) Log Message: ----------- go back to 3.3.0 dev Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2007-09-19 01:29:54 UTC (rev 912) +++ trunk/fb-contrib/build.xml 2007-09-19 01:30:49 UTC (rev 913) @@ -20,7 +20,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="3.2.5"/> + <property name="fb-contrib.version" value="3.3.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2007-09-19 01:29:54 UTC (rev 912) +++ trunk/fb-contrib/etc/findbugs.xml 2007-09-19 01:30:49 UTC (rev 913) @@ -277,23 +277,19 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousJDKVersionUse" speed="slow" - reports="SJVU_SUSPICIOUS_JDK_VERSION_USE" - disabled="true" /> + reports="SJVU_SUSPICIOUS_JDK_VERSION_USE" /> <Detector class="com.mebigfatguy.fbcontrib.detect.UseAddAll" speed="fast" - reports="UAA_USE_ADD_ALL" - disabled="true" /> + reports="UAA_USE_ADD_ALL" /> <Detector class="com.mebigfatguy.fbcontrib.detect.MethodReturnsConstant" speed="fast" - reports="MRC_METHOD_RETURNS_CONSTANT" - disabled="true" /> + reports="MRC_METHOD_RETURNS_CONSTANT" /> <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessCustomSerialization" speed="fast" - reports="NCS_NEEDLESS_CUSTOM_SERIALIZATION" - disabled="true"/> + reports="NCS_NEEDLESS_CUSTOM_SERIALIZATION" /> <!-- BugPattern --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-19 01:29:51
|
Revision: 912 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=912&view=rev Author: dbrosius Date: 2007-09-18 18:29:54 -0700 (Tue, 18 Sep 2007) Log Message: ----------- Tag version 3.2.5 Added Paths: ----------- tags/v3_2_5/ Copied: tags/v3_2_5 (from rev 911, trunk/fb-contrib) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-19 01:14:43
|
Revision: 911 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=911&view=rev Author: dbrosius Date: 2007-09-18 18:14:46 -0700 (Tue, 18 Sep 2007) Log Message: ----------- prepare for version 3.2.5 Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2007-09-19 01:12:09 UTC (rev 910) +++ trunk/fb-contrib/build.xml 2007-09-19 01:14:46 UTC (rev 911) @@ -20,7 +20,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="3.3.0"/> + <property name="fb-contrib.version" value="3.2.5"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2007-09-19 01:12:09 UTC (rev 910) +++ trunk/fb-contrib/etc/findbugs.xml 2007-09-19 01:14:46 UTC (rev 911) @@ -277,19 +277,23 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousJDKVersionUse" speed="slow" - reports="SJVU_SUSPICIOUS_JDK_VERSION_USE" /> + reports="SJVU_SUSPICIOUS_JDK_VERSION_USE" + disabled="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.UseAddAll" speed="fast" - reports="UAA_USE_ADD_ALL" /> + reports="UAA_USE_ADD_ALL" + disabled="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.MethodReturnsConstant" speed="fast" - reports="MRC_METHOD_RETURNS_CONSTANT" /> + reports="MRC_METHOD_RETURNS_CONSTANT" + disabled="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessCustomSerialization" speed="fast" - reports="NCS_NEEDLESS_CUSTOM_SERIALIZATION" /> + reports="NCS_NEEDLESS_CUSTOM_SERIALIZATION" + disabled="true"/> <!-- BugPattern --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-19 01:12:13
|
Revision: 910 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=910&view=rev Author: dbrosius Date: 2007-09-18 18:12:09 -0700 (Tue, 18 Sep 2007) Log Message: ----------- add version number to jar file name Modified Paths: -------------- trunk/fb-contrib/build.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2007-09-17 20:15:44 UTC (rev 909) +++ trunk/fb-contrib/build.xml 2007-09-19 01:12:09 UTC (rev 910) @@ -26,8 +26,8 @@ <delete dir="${classes.dir}"/> <delete dir="${javadoc.dir}"/> <delete file="${htdocs.dir}/bugdescriptions.html"/> - <delete file="${basedir}/fb-contrib.jar"/> - <delete file="${basedir}/fb-contrib-src.zip"/> + <delete file="${basedir}/fb-contrib-${fb-contrib.version}.jar"/> + <delete file="${basedir}/fb-contrib-src-${fb-contrib.version}.zip"/> <delete> <fileset dir="${samples.dir}"> <include name="**/*.class"/> @@ -96,7 +96,7 @@ </target> <target name="jar" depends="compile" description="produces the fb-contrib jar file"> - <jar destfile="${basedir}/fb-contrib.jar"> + <jar destfile="${basedir}/fb-contrib-${fb-contrib.version}.jar"> <fileset dir="etc"> <include name="findbugs.xml"/> <include name="messages*.xml"/> @@ -123,7 +123,7 @@ </target> <target name="srczip" description="builds the source distribution zip file"> - <zip destfile="${basedir}/fb-contrib-src.zip" basedir="${basedir}"> + <zip destfile="${basedir}/fb-contrib-src-${fb-contrib.version}.zip" basedir="${basedir}"> <fileset dir="${src.dir}"> <include name="**/*.java"/> <include name="**/*.xml"/> @@ -148,7 +148,7 @@ <target name="check14" depends="jar" description="Check for 1.5 only methods"> <mkdir dir="${basedir}/plugin"/> - <copy file="${basedir}/fb-contrib.jar" todir="${basedir}/plugin"/> + <copy file="${basedir}/fb-contrib-${fb-contrib.version}.jar" todir="${basedir}/plugin"/> <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${lib.dir}/findbugs-ant.jar;${lib.dir}/findbugs.jar;${lib.dir}/bcel.jar;${lib.dir}/dom4j-full.jar;${lib.dir}/asm-3.0.jar"/> @@ -160,7 +160,7 @@ outputFile="${basedir}/plugin/findbugs.xml" jvmargs="-Xmx800m -Dfb-contrib.sjvu.jdkhome=${jdk14.home}" failOnError="true"> - <class location="${basedir}/fb-contrib.jar"/> + <class location="${basedir}/fb-contrib-${fb-contrib.version}.jar"/> </findbugs> <delete dir="${basedir}/plugin"/> </target> @@ -172,7 +172,7 @@ <property environment="env"/> <copy todir="${env.FINDBUGS_HOME}/plugin"> <fileset dir="${basedir}"> - <include name="fb-contrib.jar"/> + <include name="fb-contrib-${fb-contrib.version}.jar"/> </fileset> </copy> </target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-17 20:15:41
|
Revision: 909 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=909&view=rev Author: dbrosius Date: 2007-09-17 13:15:44 -0700 (Mon, 17 Sep 2007) Log Message: ----------- sort Modified Paths: -------------- trunk/fb-contrib/etc/bugdescriptions.xsl Modified: trunk/fb-contrib/etc/bugdescriptions.xsl =================================================================== --- trunk/fb-contrib/etc/bugdescriptions.xsl 2007-09-16 02:41:19 UTC (rev 908) +++ trunk/fb-contrib/etc/bugdescriptions.xsl 2007-09-17 20:15:44 UTC (rev 909) @@ -11,14 +11,17 @@ <h1>fb-contrib: Bug Descriptions</h1> <table border="1" width="100%"> - <xsl:apply-templates select="BugCode"/> + <xsl:for-each select="BugCode"> + <xsl:sort select="@abbrev"/> + <xsl:call-template name="BugCode"/> + </xsl:for-each> </table> </div> </body> </html> </xsl:template> - <xsl:template match="BugCode"> + <xsl:template match="BugCode" name="BugCode"> <xsl:call-template name="Pattern"> <xsl:with-param name="abbrev"><xsl:value-of select="@abbrev"/></xsl:with-param> </xsl:call-template> @@ -27,6 +30,7 @@ <xsl:template name="Pattern"> <xsl:param name="abbrev"/> <xsl:for-each select="//BugPattern[starts-with(@type,$abbrev)]"> + <xsl:sort select="."/> <tr><td><b><xsl:value-of select="@type"/></b></td></tr> <xsl:variable name="desc1"><xsl:value-of select="normalize-space(Details/text())"/></xsl:variable> <xsl:variable name="desc2"><xsl:value-of select="substring($desc1, 9)"/></xsl:variable> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-16 02:41:22
|
Revision: 908 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=908&view=rev Author: dbrosius Date: 2007-09-15 19:41:19 -0700 (Sat, 15 Sep 2007) Log Message: ----------- document NCS Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2007-09-16 00:27:48 UTC (rev 907) +++ trunk/fb-contrib/htdocs/index.html 2007-09-16 02:41:19 UTC (rev 908) @@ -63,7 +63,11 @@ source is an array, you can use Arrays.asList(array), and use that as the source to addAll.</li> <li><b>[MRC] Method returns Constant</b><br/> Looks for private methods that can only return one constant value. - Either the class should not return a value, or perhaps a branch was missed. + Either the class should not return a value, or perhaps a branch was missed.</li> + <li><b>[NCS] Needless Custom Serialization</b><br/> + Looks for classes that implement Serializable and implements readObject and writeObject + by just calling the readDefaultObject or writeDefaultObject of the stream parameter. + As this is the standard behavior, implementing these methods is not needed.</li> </ul> </div> <hr/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-16 00:27:48
|
Revision: 907 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=907&view=rev Author: dbrosius Date: 2007-09-15 17:27:48 -0700 (Sat, 15 Sep 2007) Log Message: ----------- if a method has a trinary, it makes it difficult to figure out whether a constant return is used, so marked these methods as not suspect, to avoid false positives. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2007-09-16 00:19:29 UTC (rev 906) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2007-09-16 00:27:48 UTC (rev 907) @@ -112,6 +112,10 @@ returnConstant = constant; } + } else if ((seen == GOTO) || (seen == GOTO_W)) { + if (stack.getStackDepth() > 0) { + methodSuspect = false; //Trinaries confuse us to much, if the code has a trinary well - oh well + } } } finally { stack.sawOpcode(this, seen); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-16 00:19:27
|
Revision: 906 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=906&view=rev Author: dbrosius Date: 2007-09-15 17:19:29 -0700 (Sat, 15 Sep 2007) Log Message: ----------- guard against npes Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2007-09-15 18:59:26 UTC (rev 905) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2007-09-16 00:19:29 UTC (rev 906) @@ -73,7 +73,7 @@ methodSuspect = true; returnPC = -1; super.visitCode(obj); - if (methodSuspect) { + if (methodSuspect && (returnConstant != null)) { BugInstance bi = new BugInstance(this, "MRC_METHOD_RETURNS_CONSTANT", NORMAL_PRIORITY) .addClass(this) .addMethod(this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-15 18:59:24
|
Revision: 905 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=905&view=rev Author: dbrosius Date: 2007-09-15 11:59:26 -0700 (Sat, 15 Sep 2007) Log Message: ----------- initial checkin - NCS detector Modified Paths: -------------- trunk/fb-contrib/etc/bugdescriptions.xsl trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/BAS_Sample.java trunk/fb-contrib/samples/DWI_Sample.java trunk/fb-contrib/samples/ITC_Sample.java trunk/fb-contrib/samples/LEST_Sample.java trunk/fb-contrib/samples/NMCS_Sample.java trunk/fb-contrib/samples/NOS_Sample.java trunk/fb-contrib/samples/NRTL_Sample.java trunk/fb-contrib/samples/PIS_Sample.java trunk/fb-contrib/samples/RMC_Sample.java trunk/fb-contrib/samples/S508C_Sample.java trunk/fb-contrib/samples/SACM_Sample.java trunk/fb-contrib/samples/SCII_Sample.java trunk/fb-contrib/samples/SC_Sample.java trunk/fb-contrib/samples/SIL_Sample.java trunk/fb-contrib/samples/SJVU_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/TR_Sample.java trunk/fb-contrib/samples/UAA_Sample.java trunk/fb-contrib/samples/UCPM_Sample.java trunk/fb-contrib/samples/UEC_Sample.java trunk/fb-contrib/samples/URV_Sample.java trunk/fb-contrib/samples/USS_Sample.java trunk/fb-contrib/samples/UTA_Sample.java Added Paths: ----------- trunk/fb-contrib/samples/NCS_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java Property Changed: ---------------- trunk/fb-contrib/build.properties trunk/fb-contrib/etc/bugdescriptions.xsl trunk/fb-contrib/samples/BAS_Sample.java trunk/fb-contrib/samples/DWI_Sample.java trunk/fb-contrib/samples/ITC_Sample.java trunk/fb-contrib/samples/LEST_Sample.java trunk/fb-contrib/samples/NMCS_Sample.java trunk/fb-contrib/samples/NOS_Sample.java trunk/fb-contrib/samples/NRTL_Sample.java trunk/fb-contrib/samples/PIS_Sample.java trunk/fb-contrib/samples/RMC_Sample.java trunk/fb-contrib/samples/S508C_Sample.java trunk/fb-contrib/samples/SACM_Sample.java trunk/fb-contrib/samples/SCII_Sample.java trunk/fb-contrib/samples/SC_Sample.java trunk/fb-contrib/samples/SIL_Sample.java trunk/fb-contrib/samples/SJVU_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/TR_Sample.java trunk/fb-contrib/samples/UAA_Sample.java trunk/fb-contrib/samples/UCPM_Sample.java trunk/fb-contrib/samples/UEC_Sample.java trunk/fb-contrib/samples/URV_Sample.java trunk/fb-contrib/samples/USS_Sample.java trunk/fb-contrib/samples/UTA_Sample.java trunk/fb-contrib/samples/samples-bugs.xml Property changes on: trunk/fb-contrib/build.properties ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/etc/bugdescriptions.xsl =================================================================== --- trunk/fb-contrib/etc/bugdescriptions.xsl 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/etc/bugdescriptions.xsl 2007-09-15 18:59:26 UTC (rev 905) @@ -1,38 +1,38 @@ -<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - - <xsl:template match="/MessageCollection"> - <html> - <head><title>fb-contrib: Bug Descriptions</title></head> - <body background="true"> - <div style="position:absolute;top:0;left:0;width:256;height:65535;z-index:1;background-image:url(blend.jpg);"> - </div> - - <div style="position:absolute;top:20;left:20;z-index:2;"> - <h1>fb-contrib: Bug Descriptions</h1> - - <table border="1" width="100%"> - <xsl:apply-templates select="BugCode"/> - </table> - </div> - </body> - </html> - </xsl:template> - - <xsl:template match="BugCode"> - <xsl:call-template name="Pattern"> - <xsl:with-param name="abbrev"><xsl:value-of select="@abbrev"/></xsl:with-param> - </xsl:call-template> - </xsl:template> - - <xsl:template name="Pattern"> - <xsl:param name="abbrev"/> - <xsl:for-each select="//BugPattern[starts-with(@type,$abbrev)]"> - <tr><td><b><xsl:value-of select="@type"/></b></td></tr> - <xsl:variable name="desc1"><xsl:value-of select="normalize-space(Details/text())"/></xsl:variable> - <xsl:variable name="desc2"><xsl:value-of select="substring($desc1, 9)"/></xsl:variable> - <xsl:variable name="desc"><xsl:value-of select="substring($desc2, 0, string-length($desc2) - 3)"/></xsl:variable> - <tr><td><xsl:copy-of select="$desc"/></td></tr> - </xsl:for-each> - </xsl:template> - +<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <xsl:template match="/MessageCollection"> + <html> + <head><title>fb-contrib: Bug Descriptions</title></head> + <body background="true"> + <div style="position:absolute;top:0;left:0;width:256;height:65535;z-index:1;background-image:url(blend.jpg);"> + </div> + + <div style="position:absolute;top:20;left:20;z-index:2;"> + <h1>fb-contrib: Bug Descriptions</h1> + + <table border="1" width="100%"> + <xsl:apply-templates select="BugCode"/> + </table> + </div> + </body> + </html> + </xsl:template> + + <xsl:template match="BugCode"> + <xsl:call-template name="Pattern"> + <xsl:with-param name="abbrev"><xsl:value-of select="@abbrev"/></xsl:with-param> + </xsl:call-template> + </xsl:template> + + <xsl:template name="Pattern"> + <xsl:param name="abbrev"/> + <xsl:for-each select="//BugPattern[starts-with(@type,$abbrev)]"> + <tr><td><b><xsl:value-of select="@type"/></b></td></tr> + <xsl:variable name="desc1"><xsl:value-of select="normalize-space(Details/text())"/></xsl:variable> + <xsl:variable name="desc2"><xsl:value-of select="substring($desc1, 9)"/></xsl:variable> + <xsl:variable name="desc"><xsl:value-of select="substring($desc2, 0, string-length($desc2) - 3)"/></xsl:variable> + <tr><td><xsl:copy-of select="$desc"/></td></tr> + </xsl:for-each> + </xsl:template> + </xsl:transform> \ No newline at end of file Property changes on: trunk/fb-contrib/etc/bugdescriptions.xsl ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/etc/findbugs.xml 2007-09-15 18:59:26 UTC (rev 905) @@ -287,6 +287,10 @@ speed="fast" reports="MRC_METHOD_RETURNS_CONSTANT" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessCustomSerialization" + speed="fast" + reports="NCS_NEEDLESS_CUSTOM_SERIALIZATION" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -377,4 +381,5 @@ <BugPattern abbrev="SJVU" type="SJVU_SUSPICIOUS_JDK_VERSION_USE" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="UAA" type="UAA_USE_ADD_ALL" category="STYLE" experimental="true" /> <BugPattern abbrev="MRC" type="MRC_METHOD_RETURNS_CONSTANT" category="STYLE" experimental="true" /> + <BugPattern abbrev="NCS" type="NCS_NEEDLESS_CUSTOM_SERIALIZATION" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/etc/messages.xml 2007-09-15 18:59:26 UTC (rev 905) @@ -778,7 +778,19 @@ </Details> </Detector> - <!-- BugPattern --> + <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessCustomSerialization"> + <Details> + <![CDATA[ + <p>looks for classes that implement the Serializable interface and implement the + standard readObject and writeObject methods by simply deferring to the Stream + parameter's defaultReadObject or defaultWriteObject and nothing else. As this is the + built in behavior, these methods are not needed.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> <ShortDescription>method passes simple concatenating string in StringBuffer or StringBuilder append</ShortDescription> @@ -1946,6 +1958,17 @@ </Details> </BugPattern> + <BugPattern type="NCS_NEEDLESS_CUSTOM_SERIALIZATION"> + <ShortDescription>method needlessly implements what is default streaming behavior</ShortDescription> + <LongDescription>method {1} needlessly implements what is default streaming behavior</LongDescription> + <Details> + <![CDATA[ + <p>This method implements the Serializable interface by performing the same operations that + would be done if this method did not exist. Since this is the case, this method is not needed.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -2012,4 +2035,5 @@ <BugCode abbrev="SJVU">Suspicious JDK Version Use</BugCode> <BugCode abbrev="UAA">Use Add All</BugCode> <BugCode abbrev="MRC">Method Returns Constant</BugCode> + <BugCode abbrev="NCS">Needless Custom Serialization</BugCode> </MessageCollection> \ No newline at end of file Modified: trunk/fb-contrib/samples/BAS_Sample.java =================================================================== --- trunk/fb-contrib/samples/BAS_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/BAS_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,91 +1,91 @@ -import java.util.List; - -public class BAS_Sample -{ - public void testIfScope(String s) - { - Object o = new Object(); - if (s.equals("Foo")) - { - s = o.toString(); - } - } - - public String testFPForScope(String s) - { - Object o = new Object(); - while (s.length() > 0) - { - o = s.substring(0, 1); - s = s.substring(1); - } - return s; - } - - public String testFP2Scopes(String s) - { - Object o = new Object(); - if (s.equals("Boo")) - s = o.toString(); - else if (s.equals("Hoo")) - s = o.toString(); - - return s; - } - - public String test2InnerScopes(String s) - { - Object o = new Object(); - if (s != null) - { - if (s.equals("Boo")) - s = o.toString(); - else if (s.equals("Hoo")) - s = o.toString(); - } - - return s; - } - - public String testFPLoopCond(List<String> in) - { - StringBuilder sb = new StringBuilder(); - for (String s : in) - { - sb.append(s); - } - return sb.toString(); - } - - public List<String> getList() - { - return null; - } - - public String testSwitch(int a) - { - String v = "Test"; - - switch (a) - { - case 1: - v = "Testa"; - break; - - case 2: - v = "Tesseract"; - break; - - case 3: - v = "Testy"; - break; - - default: - v = "Rossa"; - break; - } - - return null; - } - -} +import java.util.List; + +public class BAS_Sample +{ + public void testIfScope(String s) + { + Object o = new Object(); + if (s.equals("Foo")) + { + s = o.toString(); + } + } + + public String testFPForScope(String s) + { + Object o = new Object(); + while (s.length() > 0) + { + o = s.substring(0, 1); + s = s.substring(1); + } + return s; + } + + public String testFP2Scopes(String s) + { + Object o = new Object(); + if (s.equals("Boo")) + s = o.toString(); + else if (s.equals("Hoo")) + s = o.toString(); + + return s; + } + + public String test2InnerScopes(String s) + { + Object o = new Object(); + if (s != null) + { + if (s.equals("Boo")) + s = o.toString(); + else if (s.equals("Hoo")) + s = o.toString(); + } + + return s; + } + + public String testFPLoopCond(List<String> in) + { + StringBuilder sb = new StringBuilder(); + for (String s : in) + { + sb.append(s); + } + return sb.toString(); + } + + public List<String> getList() + { + return null; + } + + public String testSwitch(int a) + { + String v = "Test"; + + switch (a) + { + case 1: + v = "Testa"; + break; + + case 2: + v = "Tesseract"; + break; + + case 3: + v = "Testy"; + break; + + default: + v = "Rossa"; + break; + } + + return null; + } + +} Property changes on: trunk/fb-contrib/samples/BAS_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/DWI_Sample.java =================================================================== --- trunk/fb-contrib/samples/DWI_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/DWI_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,39 +1,39 @@ -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -public class DWI_Sample -{ - Set<String> avail; - - public void deleteOdds(Set<Integer> bagOInts) - { - Iterator<Integer> it = bagOInts.iterator(); - while (it.hasNext()) - { - Integer i = it.next(); - if ((i.intValue() & 0x01) == 1) - bagOInts.remove(i); - } - } - - public void addIf(Set<String> s, Collection<String> c) { - for (String ss : s) - { - if (ss.equals("addem")) - s.addAll(c); - } - } - - public void fpUnaliased() - { - Iterator<String> it = avail.iterator(); - avail = new HashSet<String>(); - - while (it.hasNext()) - { - avail.add(it.next() + "booya"); - } - } -} +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class DWI_Sample +{ + Set<String> avail; + + public void deleteOdds(Set<Integer> bagOInts) + { + Iterator<Integer> it = bagOInts.iterator(); + while (it.hasNext()) + { + Integer i = it.next(); + if ((i.intValue() & 0x01) == 1) + bagOInts.remove(i); + } + } + + public void addIf(Set<String> s, Collection<String> c) { + for (String ss : s) + { + if (ss.equals("addem")) + s.addAll(c); + } + } + + public void fpUnaliased() + { + Iterator<String> it = avail.iterator(); + avail = new HashSet<String>(); + + while (it.hasNext()) + { + avail.add(it.next() + "booya"); + } + } +} Property changes on: trunk/fb-contrib/samples/DWI_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/ITC_Sample.java =================================================================== --- trunk/fb-contrib/samples/ITC_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/ITC_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,19 +1,19 @@ -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Vector; - -public class ITC_Sample -{ - public String test(List<String> l) - { - if (l instanceof ArrayList) - return (String)((ArrayList)l).remove(0); - else if (l instanceof LinkedList) - return (String)((LinkedList) l).removeFirst(); - else if (l instanceof Vector) - return (String)((Vector) l).remove(0); - else - return null; - } -} +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Vector; + +public class ITC_Sample +{ + public String test(List<String> l) + { + if (l instanceof ArrayList) + return (String)((ArrayList)l).remove(0); + else if (l instanceof LinkedList) + return (String)((LinkedList) l).removeFirst(); + else if (l instanceof Vector) + return (String)((Vector) l).remove(0); + else + return null; + } +} Property changes on: trunk/fb-contrib/samples/ITC_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/LEST_Sample.java =================================================================== --- trunk/fb-contrib/samples/LEST_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/LEST_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,61 +1,61 @@ -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -public class LEST_Sample -{ - public Date testLest1(String input) - { - try - { - DateFormat df = new SimpleDateFormat("YYYY"); - return df.parse(input); - } - catch (ParseException pe) - { - throw new IllegalArgumentException(pe.getMessage()); - } - } - - public Date testLest2(String input) - { - try - { - DateFormat df = new SimpleDateFormat("YYYY"); - return df.parse(input); - } - catch (ParseException pe) - { - throw new IllegalArgumentException(pe.getMessage(), pe); - } - } - - public Date testLestFP1(String input) throws ParseException - { - try - { - DateFormat df = new SimpleDateFormat("YYYY"); - return df.parse(input); - } - catch (ParseException pe) - { - throw pe; - } - } - - public Date testLestFP2(String input) - { - try - { - DateFormat df = new SimpleDateFormat("YYYY"); - return df.parse(input); - } - catch (ParseException pe) - { - IllegalArgumentException iae = new IllegalArgumentException(pe.getMessage()); - iae.initCause(pe); - throw iae; - } - } -} +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class LEST_Sample +{ + public Date testLest1(String input) + { + try + { + DateFormat df = new SimpleDateFormat("YYYY"); + return df.parse(input); + } + catch (ParseException pe) + { + throw new IllegalArgumentException(pe.getMessage()); + } + } + + public Date testLest2(String input) + { + try + { + DateFormat df = new SimpleDateFormat("YYYY"); + return df.parse(input); + } + catch (ParseException pe) + { + throw new IllegalArgumentException(pe.getMessage(), pe); + } + } + + public Date testLestFP1(String input) throws ParseException + { + try + { + DateFormat df = new SimpleDateFormat("YYYY"); + return df.parse(input); + } + catch (ParseException pe) + { + throw pe; + } + } + + public Date testLestFP2(String input) + { + try + { + DateFormat df = new SimpleDateFormat("YYYY"); + return df.parse(input); + } + catch (ParseException pe) + { + IllegalArgumentException iae = new IllegalArgumentException(pe.getMessage()); + iae.initCause(pe); + throw iae; + } + } +} Property changes on: trunk/fb-contrib/samples/LEST_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/fb-contrib/samples/NCS_Sample.java =================================================================== --- trunk/fb-contrib/samples/NCS_Sample.java (rev 0) +++ trunk/fb-contrib/samples/NCS_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -0,0 +1,18 @@ +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + + +public class NCS_Sample implements Serializable +{ + private void writeObject(ObjectOutputStream oos) throws IOException + { + oos.defaultWriteObject(); + } + + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException + { + ois.defaultReadObject(); + } +} Property changes on: trunk/fb-contrib/samples/NCS_Sample.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/NMCS_Sample.java =================================================================== --- trunk/fb-contrib/samples/NMCS_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/NMCS_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,57 +1,57 @@ -import java.util.HashSet; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; - -public class NMCS_Sample -{ - private static List<String> test1 = new Vector<String>(); - static { - test1.add("one"); - test1.add("two"); - test1.add("three"); - } - - private Map<String, String> test2 = new Hashtable<String, String>(); - - private Set<String> test3 = new HashSet<String>(); - - private List<String> test4 = new Vector<String>(); - - public String test1() - { - StringBuffer sb = new StringBuffer(); - String comma = ""; - for (String s : test1) - { - sb.append(comma); - comma = ","; - sb.append(s); - } - - return sb.toString(); - } - - public String test2() - { - test2 = new Hashtable<String, String>(); - - return test2.get("foo"); - } - - public Set<String> test3() - { - Set<String> temp = test3; - temp.add("Foo"); - return temp; - } - - public List<String> test4(boolean b1, boolean b2) - { - return b1 ? test4 : - b2 ? new Vector<String>() : test4; - } - -} +import java.util.HashSet; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +public class NMCS_Sample +{ + private static List<String> test1 = new Vector<String>(); + static { + test1.add("one"); + test1.add("two"); + test1.add("three"); + } + + private Map<String, String> test2 = new Hashtable<String, String>(); + + private Set<String> test3 = new HashSet<String>(); + + private List<String> test4 = new Vector<String>(); + + public String test1() + { + StringBuffer sb = new StringBuffer(); + String comma = ""; + for (String s : test1) + { + sb.append(comma); + comma = ","; + sb.append(s); + } + + return sb.toString(); + } + + public String test2() + { + test2 = new Hashtable<String, String>(); + + return test2.get("foo"); + } + + public Set<String> test3() + { + Set<String> temp = test3; + temp.add("Foo"); + return temp; + } + + public List<String> test4(boolean b1, boolean b2) + { + return b1 ? test4 : + b2 ? new Vector<String>() : test4; + } + +} Property changes on: trunk/fb-contrib/samples/NMCS_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/NOS_Sample.java =================================================================== --- trunk/fb-contrib/samples/NOS_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/NOS_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,30 +1,30 @@ -import java.util.Map; - -public class NOS_Sample { - private Object lock = new Object(); - - public String test(Object o) { - synchronized(o) { - return o.toString(); - } - } - - public String test2(Object o) { - synchronized(this) { - return o.toString(); - } - } - - public String test3(Map m) { - String v = (String)m.get("boo"); - synchronized (v) { - return v.substring(0,1); - } - } - - public String test4(Object o) { - synchronized(lock) { - return o.toString(); - } - } -} +import java.util.Map; + +public class NOS_Sample { + private Object lock = new Object(); + + public String test(Object o) { + synchronized(o) { + return o.toString(); + } + } + + public String test2(Object o) { + synchronized(this) { + return o.toString(); + } + } + + public String test3(Map m) { + String v = (String)m.get("boo"); + synchronized (v) { + return v.substring(0,1); + } + } + + public String test4(Object o) { + synchronized(lock) { + return o.toString(); + } + } +} Property changes on: trunk/fb-contrib/samples/NOS_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/NRTL_Sample.java =================================================================== --- trunk/fb-contrib/samples/NRTL_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/NRTL_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,34 +1,34 @@ -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.JspTagException; -import javax.servlet.jsp.tagext.TagSupport; - -public class NRTL_Sample extends TagSupport { - private String sample; - private String sample2; - - public void setSample(String s) { - sample = s; - } - - @Override - public int doStartTag() throws JspException { - try { - sample += Math.random(); - sample2 += sample; - pageContext.getOut().print(sample2); - } catch (Exception ex) { - throw new JspTagException("NRTL_Sample: " + ex.getMessage()); - } - return SKIP_BODY; - } - - public void setSample2(String s) { - sample2 = s; - } - - @Override - public int doEndTag() { - return EVAL_PAGE; - } - -} +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.JspTagException; +import javax.servlet.jsp.tagext.TagSupport; + +public class NRTL_Sample extends TagSupport { + private String sample; + private String sample2; + + public void setSample(String s) { + sample = s; + } + + @Override + public int doStartTag() throws JspException { + try { + sample += Math.random(); + sample2 += sample; + pageContext.getOut().print(sample2); + } catch (Exception ex) { + throw new JspTagException("NRTL_Sample: " + ex.getMessage()); + } + return SKIP_BODY; + } + + public void setSample2(String s) { + sample2 = s; + } + + @Override + public int doEndTag() { + return EVAL_PAGE; + } + +} Property changes on: trunk/fb-contrib/samples/NRTL_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/PIS_Sample.java =================================================================== --- trunk/fb-contrib/samples/PIS_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/PIS_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,60 +1,60 @@ -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -public class PIS_Sample -{ - public static void main(String[] args) - { - try - { - B b = new B(); - b.a = 100; - b.b = 100; - D d = new D(); - d.a = 100; - d.b = 100; - d.c = 100; - d.d = 100; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(b); - oos.writeObject(d); - oos.flush(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream ois = new ObjectInputStream(bais); - B b2 = (B)ois.readObject(); - D d2 = (D)ois.readObject(); - if ((b.a == b2.a) && (b.b == b2.b)) - System.out.println("Equal!"); - if ((d.a == d2.a) && (d.b == d2.b) && (d.c == d2.c) && (d.d == d2.d)) - System.out.println("Equal!"); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public static class A - { - public int a = 0; - } - - public static class B extends A implements Serializable - { - public int b = 1; - } - - public static class C extends B - { - public int c = 2; - } - - public static class D extends C - { - public int d = 3; - } -} +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +public class PIS_Sample +{ + public static void main(String[] args) + { + try + { + B b = new B(); + b.a = 100; + b.b = 100; + D d = new D(); + d.a = 100; + d.b = 100; + d.c = 100; + d.d = 100; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(b); + oos.writeObject(d); + oos.flush(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + ObjectInputStream ois = new ObjectInputStream(bais); + B b2 = (B)ois.readObject(); + D d2 = (D)ois.readObject(); + if ((b.a == b2.a) && (b.b == b2.b)) + System.out.println("Equal!"); + if ((d.a == d2.a) && (d.b == d2.b) && (d.c == d2.c) && (d.d == d2.d)) + System.out.println("Equal!"); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public static class A + { + public int a = 0; + } + + public static class B extends A implements Serializable + { + public int b = 1; + } + + public static class C extends B + { + public int c = 2; + } + + public static class D extends C + { + public int d = 3; + } +} Property changes on: trunk/fb-contrib/samples/PIS_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/RMC_Sample.java =================================================================== --- trunk/fb-contrib/samples/RMC_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/RMC_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,33 +1,33 @@ -import java.nio.ByteBuffer; -import java.util.Calendar; -import java.util.Date; - -public class RMC_Sample -{ - String data; - - public boolean test1(Calendar c) - { - Date d = c.getTime(); - long l = d.getTime(); - Date e = c.getTime(); - long j = e.getTime(); - return l == j; - } - - public void rmcFP(ByteBuffer bb) - { - int i = bb.getInt(); - int j = bb.getInt(); - } - - @Override - public boolean equals(Object o) - { - RMC_Sample rmc = (RMC_Sample)o; - if (data.equals("INF") || rmc.data.equals("INF")) - return false; - - return data.equals(rmc.data); - } -} +import java.nio.ByteBuffer; +import java.util.Calendar; +import java.util.Date; + +public class RMC_Sample +{ + String data; + + public boolean test1(Calendar c) + { + Date d = c.getTime(); + long l = d.getTime(); + Date e = c.getTime(); + long j = e.getTime(); + return l == j; + } + + public void rmcFP(ByteBuffer bb) + { + int i = bb.getInt(); + int j = bb.getInt(); + } + + @Override + public boolean equals(Object o) + { + RMC_Sample rmc = (RMC_Sample)o; + if (data.equals("INF") || rmc.data.equals("INF")) + return false; + + return data.equals(rmc.data); + } +} Property changes on: trunk/fb-contrib/samples/RMC_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/S508C_Sample.java =================================================================== --- trunk/fb-contrib/samples/S508C_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/S508C_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,36 +1,36 @@ -import java.awt.Color; -import java.awt.Container; - -import javax.swing.ImageIcon; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JLabel; - -public class S508C_Sample extends JFrame -{ - private JLabel fLabel = new JLabel("Hello"); - private JLabel imgLabel = new JLabel(new ImageIcon("/boo.gif")); - private JComponent c = new MyComponent(); - - public S508C_Sample() { - Container cp = getContentPane(); - cp.setLayout(null); - - cp.add(fLabel); - JLabel lLabel = new JLabel("there"); - lLabel.setBackground(new Color(255, 0, 0)); - lLabel.setForeground(new Color(255, 255, 100)); - cp.add(lLabel); - - JLabel picLabel = new JLabel(new ImageIcon("/foo.gif")); - cp.add(picLabel); - cp.add(c); - - setSize(300, 200); - } -} - -class MyComponent extends JComponent -{ - -} +import java.awt.Color; +import java.awt.Container; + +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; + +public class S508C_Sample extends JFrame +{ + private JLabel fLabel = new JLabel("Hello"); + private JLabel imgLabel = new JLabel(new ImageIcon("/boo.gif")); + private JComponent c = new MyComponent(); + + public S508C_Sample() { + Container cp = getContentPane(); + cp.setLayout(null); + + cp.add(fLabel); + JLabel lLabel = new JLabel("there"); + lLabel.setBackground(new Color(255, 0, 0)); + lLabel.setForeground(new Color(255, 255, 100)); + cp.add(lLabel); + + JLabel picLabel = new JLabel(new ImageIcon("/foo.gif")); + cp.add(picLabel); + cp.add(c); + + setSize(300, 200); + } +} + +class MyComponent extends JComponent +{ + +} Property changes on: trunk/fb-contrib/samples/S508C_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/SACM_Sample.java =================================================================== --- trunk/fb-contrib/samples/SACM_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/SACM_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,12 +1,12 @@ - -public class SACM_Sample -{ - public String test(int i) - { - String[] giantSounds = new String[] { "fee", "fi", "fo", "fum", "burp", "fart" }; - if ((i < 0) || (i >= giantSounds.length)) - return ""; - - return giantSounds[i]; - } -} + +public class SACM_Sample +{ + public String test(int i) + { + String[] giantSounds = new String[] { "fee", "fi", "fo", "fum", "burp", "fart" }; + if ((i < 0) || (i >= giantSounds.length)) + return ""; + + return giantSounds[i]; + } +} Property changes on: trunk/fb-contrib/samples/SACM_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/SCII_Sample.java =================================================================== --- trunk/fb-contrib/samples/SCII_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/SCII_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,71 +1,71 @@ -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; - -public class SCII_Sample extends OverEndulgentParent implements MouseListener -{ - public void mouseClicked(MouseEvent arg0) { - // TODO Auto-generated method stub - - } -} - -class OverEndulgentParent -{ - public void mousePressed(MouseEvent arg0) { - // TODO Auto-generated method stub - - } - - public void mouseReleased(MouseEvent arg0) { - // TODO Auto-generated method stub - - } - - public void mouseEntered(MouseEvent arg0) { - // TODO Auto-generated method stub - - } - - public void mouseExited(MouseEvent arg0) { - // TODO Auto-generated method stub - - } - - interface A - { - public void a(); - - public void b(); - - public void c(); - } - - interface B extends A - { - public void b(); - } - - interface C extends B - { - public void c(); - } - - class AA implements A - { - public void a() {} - - public void b() {} - - public void c() {} - } - - class BB extends AA implements B - { - - } - - class CC extends BB implements C - { - - } -} +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +public class SCII_Sample extends OverEndulgentParent implements MouseListener +{ + public void mouseClicked(MouseEvent arg0) { + // TODO Auto-generated method stub + + } +} + +class OverEndulgentParent +{ + public void mousePressed(MouseEvent arg0) { + // TODO Auto-generated method stub + + } + + public void mouseReleased(MouseEvent arg0) { + // TODO Auto-generated method stub + + } + + public void mouseEntered(MouseEvent arg0) { + // TODO Auto-generated method stub + + } + + public void mouseExited(MouseEvent arg0) { + // TODO Auto-generated method stub + + } + + interface A + { + public void a(); + + public void b(); + + public void c(); + } + + interface B extends A + { + public void b(); + } + + interface C extends B + { + public void c(); + } + + class AA implements A + { + public void a() {} + + public void b() {} + + public void c() {} + } + + class BB extends AA implements B + { + + } + + class CC extends BB implements C + { + + } +} Property changes on: trunk/fb-contrib/samples/SCII_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/SC_Sample.java =================================================================== --- trunk/fb-contrib/samples/SC_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/SC_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,28 +1,28 @@ -import java.util.Comparator; - -public class SC_Sample -{ - public static final int T1 = 0; - public static final int T2 = 1; - - int t = 0; - class SampleComparator implements Comparator<SC_Sample> - { - public int compare(SC_Sample arg0, SC_Sample arg1) { - if (arg0.t == arg1.t) - return 0; - - return -1; - } - } - - class SampleComparable implements Comparable<SC_Sample> - { - public int compareTo(SC_Sample arg0) { - if (t == arg0.t) - return 0; - - return 1; - } - } -} +import java.util.Comparator; + +public class SC_Sample +{ + public static final int T1 = 0; + public static final int T2 = 1; + + int t = 0; + class SampleComparator implements Comparator<SC_Sample> + { + public int compare(SC_Sample arg0, SC_Sample arg1) { + if (arg0.t == arg1.t) + return 0; + + return -1; + } + } + + class SampleComparable implements Comparable<SC_Sample> + { + public int compareTo(SC_Sample arg0) { + if (t == arg0.t) + return 0; + + return 1; + } + } +} Property changes on: trunk/fb-contrib/samples/SC_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/SIL_Sample.java =================================================================== --- trunk/fb-contrib/samples/SIL_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/SIL_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,20 +1,20 @@ -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -public class SIL_Sample -{ - public void test(ResultSet rs) throws SQLException - { - Connection c = rs.getStatement().getConnection(); - PreparedStatement ps = c.prepareStatement("select foo from boo where moo = ?"); - - while (rs.next()) - { - int key = rs.getInt(1); - ps.setInt(1, key); - ResultSet mrs = ps.executeQuery(); - } - } -} +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class SIL_Sample +{ + public void test(ResultSet rs) throws SQLException + { + Connection c = rs.getStatement().getConnection(); + PreparedStatement ps = c.prepareStatement("select foo from boo where moo = ?"); + + while (rs.next()) + { + int key = rs.getInt(1); + ps.setInt(1, key); + ResultSet mrs = ps.executeQuery(); + } + } +} Property changes on: trunk/fb-contrib/samples/SIL_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/SJVU_Sample.java =================================================================== --- trunk/fb-contrib/samples/SJVU_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/SJVU_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,12 +1,12 @@ - -public class SJVU_Sample -{ - public void test14using15(int i) - { - Integer ii = Integer.valueOf(i); - StringBuilder sb = new StringBuilder(); - sb.append(ii.intValue()); - } - - -} + +public class SJVU_Sample +{ + public void test14using15(int i) + { + Integer ii = Integer.valueOf(i); + StringBuilder sb = new StringBuilder(); + sb.append(ii.intValue()); + } + + +} Property changes on: trunk/fb-contrib/samples/SJVU_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/SPP_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,81 +1,81 @@ -import java.math.BigDecimal; -import java.util.BitSet; - -public class SPP_Sample -{ - private static final double pi = 3.14; - private static final double e = 2.72; - public static final String FALSE_POSITIVE = "INTERN_OK_HERE".intern(); - - static enum Flap { Smack, Jack }; - - public void testSPPBitSet(BitSet b) - { - b.set(-1); - } - - public String testSPPIntern() - { - return "FOO".intern(); //and yes i've seen this! - } - - public String testSBWithChars() - { - StringBuffer sb = new StringBuffer('v'); - sb.append("ictory"); - return sb.toString(); - } - - public double area(double radius) - { - return pi * radius * radius; - } - - public void testStutter(String s) - { - String a = a = s; - } - - public void testNAN(double d) - { - if (d == Double.NaN) - System.out.println("It's a nan"); - } - - public void testNAN(float f) - { - if (f == Float.NaN) - System.out.println("It's a nan"); - } - - public void testBigDecimal() - { - BigDecimal d = new BigDecimal(2.1); - } - - public void testEmptySB() - { - StringBuffer sb = new StringBuffer(""); - } - - public void equalsOnEnum(Flap f) - { - if (f.equals(Flap.Jack)) - System.out.println("Flap Jacks"); - } - - public void testCPPBoolean(Boolean a, Boolean b, Boolean c, Boolean d, Boolean e) - { - if (b && b.booleanValue()) - System.out.println("Booya"); - if (e && e.booleanValue()) - System.out.println("Booya"); - } - - public char usechatAt(String s) - { - if (s.length() > 0) - return s.toCharArray()[0]; - return ' '; - } -} +import java.math.BigDecimal; +import java.util.BitSet; + +public class SPP_Sample +{ + private static final double pi = 3.14; + private static final double e = 2.72; + public static final String FALSE_POSITIVE = "INTERN_OK_HERE".intern(); + + static enum Flap { Smack, Jack }; + + public void testSPPBitSet(BitSet b) + { + b.set(-1); + } + + public String testSPPIntern() + { + return "FOO".intern(); //and yes i've seen this! + } + + public String testSBWithChars() + { + StringBuffer sb = new StringBuffer('v'); + sb.append("ictory"); + return sb.toString(); + } + + public double area(double radius) + { + return pi * radius * radius; + } + + public void testStutter(String s) + { + String a = a = s; + } + + public void testNAN(double d) + { + if (d == Double.NaN) + System.out.println("It's a nan"); + } + + public void testNAN(float f) + { + if (f == Float.NaN) + System.out.println("It's a nan"); + } + + public void testBigDecimal() + { + BigDecimal d = new BigDecimal(2.1); + } + + public void testEmptySB() + { + StringBuffer sb = new StringBuffer(""); + } + + public void equalsOnEnum(Flap f) + { + if (f.equals(Flap.Jack)) + System.out.println("Flap Jacks"); + } + + public void testCPPBoolean(Boolean a, Boolean b, Boolean c, Boolean d, Boolean e) + { + if (b && b.booleanValue()) + System.out.println("Booya"); + if (e && e.booleanValue()) + System.out.println("Booya"); + } + + public char usechatAt(String s) + { + if (s.length() > 0) + return s.toCharArray()[0]; + return ' '; + } +} Property changes on: trunk/fb-contrib/samples/SPP_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/TR_Sample.java =================================================================== --- trunk/fb-contrib/samples/TR_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/TR_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,11 +1,11 @@ - -public class TR_Sample -{ - public int factorial(int n) - { - if (n == 1) - return 1; - - return n * factorial(n-1); - } -} + +public class TR_Sample +{ + public int factorial(int n) + { + if (n == 1) + return 1; + + return n * factorial(n-1); + } +} Property changes on: trunk/fb-contrib/samples/TR_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/UAA_Sample.java =================================================================== --- trunk/fb-contrib/samples/UAA_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/UAA_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,54 +1,54 @@ -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - - -public class UAA_Sample { - - private Set<String> in = new HashSet<String>(); - private Set<String> out = new HashSet<String>(); - - public Set<String> testLocalSet(Set<String> in) { - Set<String> out = new HashSet<String>(); - out.add("Foo"); - out.add("Bar"); - for (String s : in) { - out.add(s); - } - return out; - } - - public Set<String> testFPCondition(Set<String> in) { - Set<String> out = new HashSet<String>(); - for (String s : in) { - if (s.startsWith("a")) - out.add(s); - } - return out; - } - - public Set<String> testKeyOrValueAdd(Map<String, String> in) - { - Set<String> out = new HashSet<String>(); - for (String s : in.keySet()) - out.add(s); - - for (String s : in.values()) - out.add(s); - - return out; - } - - public void testMemberSet() { - for (String s : in) - out.add(s); - } - - public Set<String> testFromArray(String[] in) { - Set<String> out = new HashSet<String>(); - for (String s : in) - out.add(s); - - return out; - } -} +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + + +public class UAA_Sample { + + private Set<String> in = new HashSet<String>(); + private Set<String> out = new HashSet<String>(); + + public Set<String> testLocalSet(Set<String> in) { + Set<String> out = new HashSet<String>(); + out.add("Foo"); + out.add("Bar"); + for (String s : in) { + out.add(s); + } + return out; + } + + public Set<String> testFPCondition(Set<String> in) { + Set<String> out = new HashSet<String>(); + for (String s : in) { + if (s.startsWith("a")) + out.add(s); + } + return out; + } + + public Set<String> testKeyOrValueAdd(Map<String, String> in) + { + Set<String> out = new HashSet<String>(); + for (String s : in.keySet()) + out.add(s); + + for (String s : in.values()) + out.add(s); + + return out; + } + + public void testMemberSet() { + for (String s : in) + out.add(s); + } + + public Set<String> testFromArray(String[] in) { + Set<String> out = new HashSet<String>(); + for (String s : in) + out.add(s); + + return out; + } +} Property changes on: trunk/fb-contrib/samples/UAA_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/UCPM_Sample.java =================================================================== --- trunk/fb-contrib/samples/UCPM_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/UCPM_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,13 +1,13 @@ - -public class UCPM_Sample -{ - public int testUcpm1(String s) - { - return s.indexOf("*") * 10; - } - - public String testUcpm2(String s) - { - return s.startsWith("*") ? s.substring(1) : s; - } -} + +public class UCPM_Sample +{ + public int testUcpm1(String s) + { + return s.indexOf("*") * 10; + } + + public String testUcpm2(String s) + { + return s.startsWith("*") ? s.substring(1) : s; + } +} Property changes on: trunk/fb-contrib/samples/UCPM_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/UEC_Sample.java =================================================================== --- trunk/fb-contrib/samples/UEC_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/UEC_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,63 +1,63 @@ -import java.util.EnumMap; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - - -public class UEC_Sample -{ - public enum Suite { Spades, Hearts, Clubs, Diamonds }; - public enum FalsePositive { A, B, C }; - - private Set<Suite> wildSuites = new HashSet<Suite>(); - private EnumSet<Suite> eWildSuites = EnumSet.noneOf(Suite.class); - - public UEC_Sample() - { - wildSuites.add(Suite.Spades); - } - - public UEC_Sample(Suite s) - { - wildSuites.add(s); - } - - public Map<Suite, Integer> deal() - { - Map<Suite, Integer> hand = new HashMap<Suite, Integer>(); - hand.put(Suite.Spades, new Integer(10)); - hand.put(Suite.Hearts, new Integer(9)); - - return hand; - } - - public EnumMap<Suite, Integer> eDeal() - { - EnumMap<Suite, Integer> hand = new EnumMap(Suite.class); - hand.put(Suite.Spades, new Integer(10)); - hand.put(Suite.Hearts, new Integer(9)); - - return hand; - } - - public void uecFP() - { - Set<FalsePositive> testSet = EnumSet.of(FalsePositive.A); - - testSet.add(FalsePositive.B); - } - - public Set<Suite> getSuites() - { - return EnumSet.<Suite>allOf(Suite.class); - } - - public void uecFP2() - { - Set<Suite> suites = getSuites(); - - suites.add(Suite.Clubs); - } -} +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + + +public class UEC_Sample +{ + public enum Suite { Spades, Hearts, Clubs, Diamonds }; + public enum FalsePositive { A, B, C }; + + private Set<Suite> wildSuites = new HashSet<Suite>(); + private EnumSet<Suite> eWildSuites = EnumSet.noneOf(Suite.class); + + public UEC_Sample() + { + wildSuites.add(Suite.Spades); + } + + public UEC_Sample(Suite s) + { + wildSuites.add(s); + } + + public Map<Suite, Integer> deal() + { + Map<Suite, Integer> hand = new HashMap<Suite, Integer>(); + hand.put(Suite.Spades, new Integer(10)); + hand.put(Suite.Hearts, new Integer(9)); + + return hand; + } + + public EnumMap<Suite, Integer> eDeal() + { + EnumMap<Suite, Integer> hand = new EnumMap(Suite.class); + hand.put(Suite.Spades, new Integer(10)); + hand.put(Suite.Hearts, new Integer(9)); + + return hand; + } + + public void uecFP() + { + Set<FalsePositive> testSet = EnumSet.of(FalsePositive.A); + + testSet.add(FalsePositive.B); + } + + public Set<Suite> getSuites() + { + return EnumSet.<Suite>allOf(Suite.class); + } + + public void uecFP2() + { + Set<Suite> suites = getSuites(); + + suites.add(Suite.Clubs); + } +} Property changes on: trunk/fb-contrib/samples/UEC_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/URV_Sample.java =================================================================== --- trunk/fb-contrib/samples/URV_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/URV_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,38 +1,38 @@ -import java.util.HashSet; -import java.util.TreeSet; - -public class URV_Sample extends URV_Super -{ - public Object getASet(boolean b) - { - if (b) - return new HashSet(); - else - return new TreeSet(); - } - - public Object getInfo(boolean b) - { - if (b) - return new String[4]; - else - return ""; - } - - @Override - public Object getInheritedInfo(boolean b) - { - if (b) - return new Integer(1); - else - return new Float(1.0); - } -} - -class URV_Super -{ - public Object getInheritedInfo(boolean b) - { - return null; - } -} +import java.util.HashSet; +import java.util.TreeSet; + +public class URV_Sample extends URV_Super +{ + public Object getASet(boolean b) + { + if (b) + return new HashSet(); + else + return new TreeSet(); + } + + public Object getInfo(boolean b) + { + if (b) + return new String[4]; + else + return ""; + } + + @Override + public Object getInheritedInfo(boolean b) + { + if (b) + return new Integer(1); + else + return new Float(1.0); + } +} + +class URV_Super +{ + public Object getInheritedInfo(boolean b) + { + return null; + } +} Property changes on: trunk/fb-contrib/samples/URV_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/USS_Sample.java =================================================================== --- trunk/fb-contrib/samples/USS_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/USS_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,100 +1,100 @@ -import java.util.StringTokenizer; - -public class USS_Sample -{ - public String[] testUss1(String s) - { - StringTokenizer st = new StringTokenizer(s, ";"); - int count = st.countTokens(); - String[] sarray = new String[count]; - - int i = 0; - while (st.hasMoreTokens()) - { - sarray[i] = st.nextToken(); - i++; - } - - return sarray; - } - - public String[] testUss2(String s) - { - StringTokenizer st = new StringTokenizer(s, ";"); - int count = st.countTokens(); - String[] sarray = new String[count]; - - int i = 0; - while (st.hasMoreTokens()) - { - sarray[i++] = st.nextToken(); - } - - return sarray; - } - - public String[] testUss3(String s) - { - StringTokenizer st = new StringTokenizer(s, ";"); - int count = st.countTokens(); - String[] sarray = new String[count]; - - for (int i = 0; i < count; i++) - { - sarray[i++] = st.nextToken(); - } - - return sarray; - } - - public String[] testUss4(String s) - { - StringTokenizer st = new StringTokenizer(s, ";"); - int count = st.countTokens(); - String[] sarray = new String[count]; - - int i = 0; - while (st.hasMoreElements()) - { - sarray[i++] = (String)st.nextElement(); - } - - return sarray; - } - - public String[] testUssFP5(String s) - { - StringTokenizer st = new StringTokenizer(s, ";"); - int count = st.countTokens(); - String[] sarray = new String[count]; - - int i = 0; - while (st.hasMoreElements()) - { - sarray[i++] = "***" + (String)st.nextElement(); - } - - return sarray; - } - - public String[] testUssFP6(String s) - { - StringTokenizer st = new StringTokenizer(s, ";"); - int count = st.countTokens(); - String[] sarray = new String[count]; - - int i = 0; - while (st.hasMoreTokens()) - { - String x = st.nextToken(); - if (x.equals("*")) - x = "Star"; - - sarray[i++] = x; - } - - return sarray; - } - - -} +import java.util.StringTokenizer; + +public class USS_Sample +{ + public String[] testUss1(String s) + { + StringTokenizer st = new StringTokenizer(s, ";"); + int count = st.countTokens(); + String[] sarray = new String[count]; + + int i = 0; + while (st.hasMoreTokens()) + { + sarray[i] = st.nextToken(); + i++; + } + + return sarray; + } + + public String[] testUss2(String s) + { + StringTokenizer st = new StringTokenizer(s, ";"); + int count = st.countTokens(); + String[] sarray = new String[count]; + + int i = 0; + while (st.hasMoreTokens()) + { + sarray[i++] = st.nextToken(); + } + + return sarray; + } + + public String[] testUss3(String s) + { + StringTokenizer st = new StringTokenizer(s, ";"); + int count = st.countTokens(); + String[] sarray = new String[count]; + + for (int i = 0; i < count; i++) + { + sarray[i++] = st.nextToken(); + } + + return sarray; + } + + public String[] testUss4(String s) + { + StringTokenizer st = new StringTokenizer(s, ";"); + int count = st.countTokens(); + String[] sarray = new String[count]; + + int i = 0; + while (st.hasMoreElements()) + { + sarray[i++] = (String)st.nextElement(); + } + + return sarray; + } + + public String[] testUssFP5(String s) + { + StringTokenizer st = new StringTokenizer(s, ";"); + int count = st.countTokens(); + String[] sarray = new String[count]; + + int i = 0; + while (st.hasMoreElements()) + { + sarray[i++] = "***" + (String)st.nextElement(); + } + + return sarray; + } + + public String[] testUssFP6(String s) + { + StringTokenizer st = new StringTokenizer(s, ";"); + int count = st.countTokens(); + String[] sarray = new String[count]; + + int i = 0; + while (st.hasMoreTokens()) + { + String x = st.nextToken(); + if (x.equals("*")) + x = "Star"; + + sarray[i++] = x; + } + + return sarray; + } + + +} Property changes on: trunk/fb-contrib/samples/USS_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/samples/UTA_Sample.java =================================================================== --- trunk/fb-contrib/samples/UTA_Sample.java 2007-09-15 04:44:35 UTC (rev 904) +++ trunk/fb-contrib/samples/UTA_Sample.java 2007-09-15 18:59:26 UTC (rev 905) @@ -1,34 +1,34 @@ -import java.util.Iterator; -import java.util.List; - -public class UTA_Sample -{ - public String[] testList1(List<String> l) - { - String[] data = new String[l.size()]; - for (int i = 0; i < l.size(); i++) - data[i] = l.get(i); - - return data; - } - - public Integer[] testList2(List<Integer> l) - { - int size = l.size(); - Integer[] data = new Integer[size]; - for (int i = 0; i < size; i++) - data[i] = l.get(i); - - return data; - } - - public Long[] testList3(List<Long> l) - { - Iterator<Long> it = l.iterator(); - Long[] data = new Long[l.size()]; - for (int i = 0; i < l.size(); i++) - data[i] = it.next(); - - return data; - } -} +import java.util.Iterator; +import java.util.List; + +public class UTA_Sample +{ + public String[] testList1(List<String> l) + { + String[] data = new String[l.size()]; + for (int i = 0; i < l.size(); i++) + data[i] = l.get(i); + + return data; + } + + public Integer[] testList2(List<Integer> l) + { + int size = l.size(); + Integer[] data = new Integer[size]; + for (int i = 0; i < size; i++) + data[i] = l.get(i); + + return data; + } + + public Long[] testList3(List<Long> l) + { + Iterator<Long> it = l.iterator(); + Long[] data = new Long[l.size()]; + for (int i = 0; i < l.size(); i++) + data[i] = it.next(); + + return data; + } +} Property changes on: trunk/fb-contrib/samples/UTA_Sample.java ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/fb-contrib/samples/samples-bugs.xml ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java 2007-09-15 18:59:26 UTC (rev 905) @@ -0,0 +1,139 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2007 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.detect; + +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.JavaClass; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * looks for classes that implement Serializable and implements readObject and w... [truncated message content] |
From: <dbr...@us...> - 2007-09-15 04:44:32
|
Revision: 904 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=904&view=rev Author: dbrosius Date: 2007-09-14 21:44:35 -0700 (Fri, 14 Sep 2007) Log Message: ----------- add mime-types Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Integer14.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/MapEntry.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java Property Changed: ---------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Integer14.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/MapEntry.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2007-09-15 04:42:59 UTC (rev 903) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2007-09-15 04:44:35 UTC (rev 904) @@ -1,59 +1,59 @@ -/* - * fb-contrib - Auxilliary detectors for Java programs - * Copyright (C) 2005-2007 Dave Brosius - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package com.mebigfatguy.fbcontrib.collect; - -import org.apache.bcel.classfile.Code; - -import edu.umd.cs.findbugs.BugReporter; -import edu.umd.cs.findbugs.BytecodeScanningDetector; -import edu.umd.cs.findbugs.NonReportingDetector; - -public class CollectStatistics extends BytecodeScanningDetector implements NonReportingDetector -{ - private int numMethodCalls; - - @SuppressWarnings("unused") - public CollectStatistics(BugReporter bugReporter) { - Statistics.getStatistics().clear(); - } - - @Override - public void visitCode(Code obj) { - - numMethodCalls = 0; - - byte[] code = obj.getCode(); - if (code != null) { - super.visitCode(obj); - Statistics.getStatistics().addMethodStatistics(getClassName(), getMethodName(), getMethodSig(), new Statistics.MethodInfo(code.length, numMethodCalls)); - } - } - - @Override - public void sawOpcode(int seen) { - switch (seen) { - case INVOKEVIRTUAL: - case INVOKEINTERFACE: - case INVOKESPECIAL: - case INVOKESTATIC: - numMethodCalls++; - break; - } - } -} +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2007 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.collect; + +import org.apache.bcel.classfile.Code; + +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.NonReportingDetector; + +public class CollectStatistics extends BytecodeScanningDetector implements NonReportingDetector +{ + private int numMethodCalls; + + @SuppressWarnings("unused") + public CollectStatistics(BugReporter bugReporter) { + Statistics.getStatistics().clear(); + } + + @Override + public void visitCode(Code obj) { + + numMethodCalls = 0; + + byte[] code = obj.getCode(); + if (code != null) { + super.visitCode(obj); + Statistics.getStatistics().addMethodStatistics(getClassName(), getMethodName(), getMethodSig(), new Statistics.MethodInfo(code.length, numMethodCalls)); + } + } + + @Override + public void sawOpcode(int seen) { + switch (seen) { + case INVOKEVIRTUAL: + case INVOKEINTERFACE: + case INVOKESPECIAL: + case INVOKESTATIC: + numMethodCalls++; + break; + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2007-09-15 04:42:59 UTC (rev 903) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2007-09-15 04:44:35 UTC (rev 904) @@ -1,97 +1,97 @@ -/* - * fb-contrib - Auxilliary detectors for Java programs - * Copyright (C) 2005-2007 Dave Brosius - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package com.mebigfatguy.fbcontrib.collect; - -import java.util.HashMap; -import java.util.Map; - -public class Statistics { - - private static Statistics statistics = new Statistics(); - - private Map<Long, Long> methodStatistics = new HashMap<Long, Long>(); - - private Statistics() { - - } - - public static Statistics getStatistics() { - return statistics; - } - - public void clear() { - methodStatistics.clear(); - } - - public void addMethodStatistics(String className, String methodName, String signature, MethodInfo methodInfo) { - Long key = getKey(className, methodName, signature); - if (methodStatistics.containsKey(key)) - methodStatistics.put(key, getValue(new MethodInfo())); - else - methodStatistics.put(getKey(className, methodName, signature), getValue(methodInfo)); - } - - public MethodInfo getMethodStatistics(String className, String methodName, String signature) { - Long v = methodStatistics.get(getKey(className, methodName, signature)); - if (v == null) - return new MethodInfo(); - else - return buildMethodInfo(v); - } - - private Long getKey(String className, String methodName, String signature) { - long hashCode = className.hashCode(); - hashCode <<= 16; - hashCode |= methodName.hashCode(); - hashCode <<= 16; - hashCode |= signature.hashCode(); - return new Long(hashCode); - } - - private Long getValue(MethodInfo methodInfo) { - long value = methodInfo.numBytes; - value <<= 32; - value |= methodInfo.numMethodCalls; - return new Long(value); - } - - private MethodInfo buildMethodInfo(Long value) { - MethodInfo mi = new MethodInfo(); - long v = value.longValue(); - mi.numBytes = (int)(v >>> 32); - mi.numMethodCalls = (int)(v & 0x7FFFFFFF); - return mi; - } - - public static class MethodInfo - { - public int numBytes; - public int numMethodCalls; - - public MethodInfo() { - numBytes = 0; - numMethodCalls = 0; - } - - public MethodInfo(int bytes, int calls) { - numBytes = bytes; - numMethodCalls = calls; - } - } -} +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2007 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.collect; + +import java.util.HashMap; +import java.util.Map; + +public class Statistics { + + private static Statistics statistics = new Statistics(); + + private Map<Long, Long> methodStatistics = new HashMap<Long, Long>(); + + private Statistics() { + + } + + public static Statistics getStatistics() { + return statistics; + } + + public void clear() { + methodStatistics.clear(); + } + + public void addMethodStatistics(String className, String methodName, String signature, MethodInfo methodInfo) { + Long key = getKey(className, methodName, signature); + if (methodStatistics.containsKey(key)) + methodStatistics.put(key, getValue(new MethodInfo())); + else + methodStatistics.put(getKey(className, methodName, signature), getValue(methodInfo)); + } + + public MethodInfo getMethodStatistics(String className, String methodName, String signature) { + Long v = methodStatistics.get(getKey(className, methodName, signature)); + if (v == null) + return new MethodInfo(); + else + return buildMethodInfo(v); + } + + private Long getKey(String className, String methodName, String signature) { + long hashCode = className.hashCode(); + hashCode <<= 16; + hashCode |= methodName.hashCode(); + hashCode <<= 16; + hashCode |= signature.hashCode(); + return new Long(hashCode); + } + + private Long getValue(MethodInfo methodInfo) { + long value = methodInfo.numBytes; + value <<= 32; + value |= methodInfo.numMethodCalls; + return new Long(value); + } + + private MethodInfo buildMethodInfo(Long value) { + MethodInfo mi = new MethodInfo(); + long v = value.longValue(); + mi.numBytes = (int)(v >>> 32); + mi.numMethodCalls = (int)(v & 0x7FFFFFFF); + return mi; + } + + public static class MethodInfo + { + public int numBytes; + public int numMethodCalls; + + public MethodInfo() { + numBytes = 0; + numMethodCalls = 0; + } + + public MethodInfo(int bytes, int calls) { + numBytes = bytes; + numMethodCalls = calls; + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2007-09-15 04:42:59 UTC (rev 903) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2007-09-15 04:44:35 UTC (rev 904) @@ -30,7 +30,7 @@ /** * looks for private methods that can only return one constant value. - * either the class should return a value, or perhaps a branch was missed. + * either the class should not return a value, or perhaps a branch was missed. */ public class MethodReturnsConstant extends BytecodeScanningDetector { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Integer14.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Integer14.java 2007-09-15 04:42:59 UTC (rev 903) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Integer14.java 2007-09-15 04:44:35 UTC (rev 904) @@ -1,41 +1,41 @@ -/* - * fb-contrib - Auxilliary detectors for Java programs - * Copyright (C) 2005-2007 Dave Brosius - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package com.mebigfatguy.fbcontrib.utils; - -public class Integer14 -{ - public static final int MIN_CACHE = -10; - public static final int MAX_CACHE = 256; - - private static final Integer[] cachedInts = new Integer[MAX_CACHE-MIN_CACHE+1]; - static { - for (int i = MIN_CACHE; i <= MAX_CACHE; i++) - cachedInts[i-MIN_CACHE] = new Integer(i); - } - - private Integer14() - {} - - public static Integer valueOf(int i) - { - if ((i < MIN_CACHE) || (i > MAX_CACHE)) - return new Integer(i); - return cachedInts[i-MIN_CACHE]; - } -} +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2007 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.utils; + +public class Integer14 +{ + public static final int MIN_CACHE = -10; + public static final int MAX_CACHE = 256; + + private static final Integer[] cachedInts = new Integer[MAX_CACHE-MIN_CACHE+1]; + static { + for (int i = MIN_CACHE; i <= MAX_CACHE; i++) + cachedInts[i-MIN_CACHE] = new Integer(i); + } + + private Integer14() + {} + + public static Integer valueOf(int i) + { + if ((i < MIN_CACHE) || (i > MAX_CACHE)) + return new Integer(i); + return cachedInts[i-MIN_CACHE]; + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Integer14.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/MapEntry.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/MapEntry.java 2007-09-15 04:42:59 UTC (rev 903) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/MapEntry.java 2007-09-15 04:44:35 UTC (rev 904) @@ -1,55 +1,55 @@ -/* - * fb-contrib - Auxilliary detectors for Java programs - * Copyright (C) 2005-2007 Dave Brosius - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package com.mebigfatguy.fbcontrib.utils; - -import java.util.Map.Entry; - -/** - * a simple implementation of the Map.Entry interface - */ -public class MapEntry<K,V> implements Entry<K,V> { - - private K key; - private V value; - - public MapEntry() { - key = null; - value = null; - } - - public MapEntry(K k, V v) { - key = k; - value = v; - } - - public K getKey() { - return key; - } - - public V getValue() { - return value; - } - - public V setValue(V v) { - V temp = value; - value = v; - return temp; - } - -} +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2007 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.utils; + +import java.util.Map.Entry; + +/** + * a simple implementation of the Map.Entry interface + */ +public class MapEntry<K,V> implements Entry<K,V> { + + private K key; + private V value; + + public MapEntry() { + key = null; + value = null; + } + + public MapEntry(K k, V v) { + key = k; + value = v; + } + + public K getKey() { + return key; + } + + public V getValue() { + return value; + } + + public V setValue(V v) { + V temp = value; + value = v; + return temp; + } + +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/MapEntry.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2007-09-15 04:42:59 UTC (rev 903) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2007-09-15 04:44:35 UTC (rev 904) @@ -1,57 +1,57 @@ -/* - * fb-contrib - Auxilliary detectors for Java programs - * Copyright (C) 2005-2007 Dave Brosius - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package com.mebigfatguy.fbcontrib.utils; - -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.Method; - -public class SignatureUtils { - - public static boolean isInheritedMethod(JavaClass cls, String methodName, String signature) throws ClassNotFoundException { - JavaClass[] infs = cls.getAllInterfaces(); - if (findInheritedMethod(infs, methodName, signature) != null) { - return true; - } - - JavaClass[] supers = cls.getSuperClasses(); - for (int i = 0; i < supers.length; i++) { - if ("java.lang.Object".equals(supers[i].getClassName())) { - supers[i] = null; - } - } - return findInheritedMethod(supers, methodName, signature) != null; - } - - private static JavaClass findInheritedMethod(JavaClass[] classes, String methodName, String signature) { - for (JavaClass cls : classes) { - if (cls != null) { - Method[] methods = cls.getMethods(); - for (Method m : methods) { - if (!m.isPrivate()) { - if (m.getName().equals(methodName)) { - if (m.getSignature().equals(signature)) - return cls; - } - } - } - } - } - return null; - } -} +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2007 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.utils; + +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; + +public class SignatureUtils { + + public static boolean isInheritedMethod(JavaClass cls, String methodName, String signature) throws ClassNotFoundException { + JavaClass[] infs = cls.getAllInterfaces(); + if (findInheritedMethod(infs, methodName, signature) != null) { + return true; + } + + JavaClass[] supers = cls.getSuperClasses(); + for (int i = 0; i < supers.length; i++) { + if ("java.lang.Object".equals(supers[i].getClassName())) { + supers[i] = null; + } + } + return findInheritedMethod(supers, methodName, signature) != null; + } + + private static JavaClass findInheritedMethod(JavaClass[] classes, String methodName, String signature) { + for (JavaClass cls : classes) { + if (cls != null) { + Method[] methods = cls.getMethods(); + for (Method m : methods) { + if (!m.isPrivate()) { + if (m.getName().equals(methodName)) { + if (m.getSignature().equals(signature)) + return cls; + } + } + } + } + } + return null; + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java 2007-09-15 04:42:59 UTC (rev 903) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java 2007-09-15 04:44:35 UTC (rev 904) @@ -1,28 +1,28 @@ -/* - * fb-contrib - Auxilliary detectors for Java programs - * Copyright (C) 2005-2007 Dave Brosius - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package com.mebigfatguy.fbcontrib.utils; - - -/** - * supports different versions/changes to the FindBugs.jar file, by using reflection, etc - * to use different signatures. - */ -public class VersionTransition { - -} +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2007 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.utils; + + +/** + * supports different versions/changes to the FindBugs.jar file, by using reflection, etc + * to use different signatures. + */ +public class VersionTransition { + +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-15 04:42:55
|
Revision: 903 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=903&view=rev Author: dbrosius Date: 2007-09-14 21:42:59 -0700 (Fri, 14 Sep 2007) Log Message: ----------- add 'not' Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2007-09-15 04:36:12 UTC (rev 902) +++ trunk/fb-contrib/htdocs/index.html 2007-09-15 04:42:59 UTC (rev 903) @@ -63,7 +63,7 @@ source is an array, you can use Arrays.asList(array), and use that as the source to addAll.</li> <li><b>[MRC] Method returns Constant</b><br/> Looks for private methods that can only return one constant value. - Either the class should return a value, or perhaps a branch was missed. + Either the class should not return a value, or perhaps a branch was missed. </ul> </div> <hr/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-15 04:36:08
|
Revision: 902 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=902&view=rev Author: dbrosius Date: 2007-09-14 21:36:12 -0700 (Fri, 14 Sep 2007) Log Message: ----------- expand svn now Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2007-09-15 04:34:33 UTC (rev 901) +++ trunk/fb-contrib/htdocs/index.html 2007-09-15 04:36:12 UTC (rev 902) @@ -48,28 +48,28 @@ <a href="bugdescriptions.html">Bug Descriptions</a> <hr/> - <img id="svn_image" src="flip1.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> + <img id="svn_image" src="flip2.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> Detectors add in svn<br/> - <div id="svn" style="display:none;"> + <div id="svn" style="display:block;"> <ul> - <li><b>[MRC] Method returns Constant</b><br/> - Looks for private methods that can only return one constant value. - Either the class should return a value, or perhaps a branch was missed. + <li><b>[SJVU] Suspicious JDK Version Use</b><br/> + Looks for calls to classes and methods that do not exist in the JDK for which this class is + compiled. This can happen if you specify the -source and -target options of the javac compiler, and + specify a target that is less than the jdk version of the javac compiler.</li> <li><b>[UAA] Use Add All</b><br/> Looks for loops that transfers the contents of one collection to another. These collection sources might be local variables or member fields, including sets, maps key/values, lists, or arrays. It is simpler to just use the addAll method of the collection class. In the case where the source is an array, you can use Arrays.asList(array), and use that as the source to addAll.</li> - <li><b>[SJVU] Suspicious JDK Version Use</b><br/> - Looks for calls to classes and methods that do not exist in the JDK for which this class is - compiled. This can happen if you specify the -source and -target options of the javac compiler, and - specify a target that is less than the jdk version of the javac compiler.</li> + <li><b>[MRC] Method returns Constant</b><br/> + Looks for private methods that can only return one constant value. + Either the class should return a value, or perhaps a branch was missed. </ul> </div> <hr/> - <img id="v3_2_0_image" src="flip2.gif" onClick="toggleBlock('v3_2_0', 'v3_2_0_image');" align="top"/> + <img id="v3_2_0_image" src="flip1.gif" onClick="toggleBlock('v3_2_0', 'v3_2_0_image');" align="top"/> Detectors added in v3.2.0<br/> - <div id="v3_2_0" style="display:block;"> + <div id="v3_2_0" style="display:none;"> <ul> <li><b>[SCRV] Suspicious Comparator Return Values</b><br/> Looks for classes that implement Comparator or Comparable, and whose compare or compareTo This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-15 04:34:29
|
Revision: 901 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=901&view=rev Author: dbrosius Date: 2007-09-14 21:34:33 -0700 (Fri, 14 Sep 2007) Log Message: ----------- doc UAA and MRC Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2007-09-15 04:31:29 UTC (rev 900) +++ trunk/fb-contrib/htdocs/index.html 2007-09-15 04:34:33 UTC (rev 901) @@ -52,6 +52,14 @@ Detectors add in svn<br/> <div id="svn" style="display:none;"> <ul> + <li><b>[MRC] Method returns Constant</b><br/> + Looks for private methods that can only return one constant value. + Either the class should return a value, or perhaps a branch was missed. + <li><b>[UAA] Use Add All</b><br/> + Looks for loops that transfers the contents of one collection to another. These collection sources + might be local variables or member fields, including sets, maps key/values, lists, or arrays. + It is simpler to just use the addAll method of the collection class. In the case where the + source is an array, you can use Arrays.asList(array), and use that as the source to addAll.</li> <li><b>[SJVU] Suspicious JDK Version Use</b><br/> Looks for calls to classes and methods that do not exist in the JDK for which this class is compiled. This can happen if you specify the -source and -target options of the javac compiler, and This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-15 04:31:26
|
Revision: 900 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=900&view=rev Author: dbrosius Date: 2007-09-14 21:31:29 -0700 (Fri, 14 Sep 2007) Log Message: ----------- initial checkin - MRC detector Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2007-09-15 04:30:57 UTC (rev 899) +++ trunk/fb-contrib/etc/findbugs.xml 2007-09-15 04:31:29 UTC (rev 900) @@ -283,6 +283,10 @@ speed="fast" reports="UAA_USE_ADD_ALL" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.MethodReturnsConstant" + speed="fast" + reports="MRC_METHOD_RETURNS_CONSTANT" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -372,4 +376,5 @@ <BugPattern abbrev="USS" type="USS_USE_STRING_SPLIT" category="STYLE" /> <BugPattern abbrev="SJVU" type="SJVU_SUSPICIOUS_JDK_VERSION_USE" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="UAA" type="UAA_USE_ADD_ALL" category="STYLE" experimental="true" /> + <BugPattern abbrev="MRC" type="MRC_METHOD_RETURNS_CONSTANT" category="STYLE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2007-09-15 04:30:57 UTC (rev 899) +++ trunk/fb-contrib/etc/messages.xml 2007-09-15 04:31:29 UTC (rev 900) @@ -767,6 +767,17 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.MethodReturnsConstant"> + <Details> + <![CDATA[ + <p>looks for private methods that only return one constant value. Since there is no + chance for derived classes overriding this behavior, the return of a constant value + seems dubious.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -1922,6 +1933,19 @@ </Details> </BugPattern> + <BugPattern type="MRC_METHOD_RETURNS_CONSTANT"> + <ShortDescription>private method only returns one constant value</ShortDescription> + <LongDescription>private method {1} only returns one constant value</LongDescription> + <Details> + <![CDATA[ + <p>This private method only returns one constant value. As this method is private, + it's behavior can't be overridden, and thus the return of a constant value seems dubious. + Either the method should be changed to return no value, or perhaps another return value + was expected to be returned in another code path in this method.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -1987,4 +2011,5 @@ <BugCode abbrev="USS">Use String Split</BugCode> <BugCode abbrev="SJVU">Suspicious JDK Version Use</BugCode> <BugCode abbrev="UAA">Use Add All</BugCode> + <BugCode abbrev="MRC">Method Returns Constant</BugCode> </MessageCollection> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-15 04:30:53
|
Revision: 899 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=899&view=rev Author: dbrosius Date: 2007-09-14 21:30:57 -0700 (Fri, 14 Sep 2007) Log Message: ----------- initial checkin - MRC detector test Added Paths: ----------- trunk/fb-contrib/samples/MRC_Sample.java Added: trunk/fb-contrib/samples/MRC_Sample.java =================================================================== --- trunk/fb-contrib/samples/MRC_Sample.java (rev 0) +++ trunk/fb-contrib/samples/MRC_Sample.java 2007-09-15 04:30:57 UTC (rev 899) @@ -0,0 +1,39 @@ + +public class MRC_Sample +{ + private int getValue() { + return 1; + } + + private String getStringValue() { + return "Hello"; + } + + public float getFP() + { + return 0.0f; + } + + private double getTwoValuesFP(boolean b) + { + if (b) + return 1.0; + else + return 0.0; + } + + private String getTwoDupsBySwitch(int i) + { + switch (i) + { + case 1: + return "Hello"; + + case 2: + return "Hello"; + + default: + return "Hello"; + } + } +} Property changes on: trunk/fb-contrib/samples/MRC_Sample.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-15 04:29:09
|
Revision: 898 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=898&view=rev Author: dbrosius Date: 2007-09-14 21:29:10 -0700 (Fri, 14 Sep 2007) Log Message: ----------- initial checkin MRC detector Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SQLInLoop.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticArrayCreatedInMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/TailRecursion.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java Property Changed: ---------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessInstanceRetrieval.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonCollectionMethodUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ParallelLists.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PartiallyConstructedObjectAccess.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SQLInLoop.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SluggishGui.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpuriousThreadStates.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticArrayCreatedInMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousWaitOnConcurrentObject.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/TailRecursion.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/package.html Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java ___________________________________________________________________ Name: svn:mime-type + text/plain Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java ___________________________________________________________________ Name: svn:mime-type + text/plain Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java ___________________________________________________________________ Name: svn:mime-type + text/plain Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java ___________________________________________________________________ Name: svn:mime-type + text/plain Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2007-09-15 03:02:05 UTC (rev 897) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2007-09-15 04:29:10 UTC (rev 898) @@ -1,578 +1,578 @@ -/* - * fb-contrib - Auxilliary detectors for Java programs - * Copyright (C) 2005-2007 Dave Brosius - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package com.mebigfatguy.fbcontrib.detect; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.bcel.classfile.Code; -import org.apache.bcel.classfile.CodeException; -import org.apache.bcel.classfile.Method; - -import com.mebigfatguy.fbcontrib.utils.Integer14; -import com.mebigfatguy.fbcontrib.utils.RegisterUtils; - -import edu.umd.cs.findbugs.BugInstance; -import edu.umd.cs.findbugs.BugReporter; -import edu.umd.cs.findbugs.BytecodeScanningDetector; -import edu.umd.cs.findbugs.ba.ClassContext; - -/** - * looks for variable assignments at a scope larger than its use. In this case, - * the assignment can be pushed down into the smaller scope to reduce the performance - * impact of that assignment. - */ -public class BloatedAssignmentScope extends BytecodeScanningDetector -{ - BugReporter bugReporter; - private Set<Integer> ignoreRegs; - private ScopeBlock rootScopeBlock; - private Set<Integer> catchHandlers; - private Set<Integer> switchTargets; - private boolean dontReport; - private boolean sawDup; - private boolean sawNull; - - /** - * constructs a BAS detector given the reporter to report bugs on - - * @param bugReporter the sync of bug reports - */ - public BloatedAssignmentScope(BugReporter bugReporter) { - this.bugReporter = bugReporter; - } - - /** - * implements the visitor to create and the clear the register to location map - * - * @param classContext the context object of the currently parsed class - */ - @Override - public void visitClassContext(ClassContext classContext) { - try { - ignoreRegs = new HashSet<Integer>(); - catchHandlers = new HashSet<Integer>(); - switchTargets = new HashSet<Integer>(); - super.visitClassContext(classContext); - } finally { - ignoreRegs = null; - catchHandlers = null; - switchTargets = null; - } - } - - /** - * implements the visitor to reset the register to location map - * - * @param obj the context object of the currently parsed code block - */ - @Override - public void visitCode(Code obj) { - try { - - ignoreRegs.clear(); - Method method = getMethod(); - if (!method.isStatic()) - ignoreRegs.add(Integer14.valueOf(0)); - - int[] parmRegs = RegisterUtils.getParameterRegisters(method); - for (int parm : parmRegs) { - ignoreRegs.add(Integer14.valueOf(parm)); - } - - rootScopeBlock = new ScopeBlock(0, obj.getLength()); - catchHandlers.clear(); - CodeException[] exceptions = obj.getExceptionTable(); - if (exceptions != null) { - for (CodeException ex : exceptions) { - catchHandlers.add(Integer14.valueOf(ex.getHandlerPC())); - } - } - - switchTargets.clear(); - dontReport = false; - sawDup = false; - sawNull = false; - super.visitCode(obj); - - if (!dontReport) - rootScopeBlock.findBugs(new HashSet<Integer>()); - - } finally { - rootScopeBlock = null; - } - } - - /** - * implements the visitor to look for variables assigned below the scope - * in which they are used. - * - * @param seen the opcode of the currently parsed instruction - */ - @Override - public void sawOpcode(int seen) { - if ((seen == ASTORE) - || (seen == ISTORE) - || (seen == LSTORE) - || (seen == FSTORE) - || (seen == DSTORE) - || ((seen >= ASTORE_0) && (seen <= ASTORE_3)) - || ((seen >= ISTORE_0) && (seen <= ISTORE_3)) - || ((seen >= LSTORE_0) && (seen <= LSTORE_1)) - || ((seen >= FSTORE_0) && (seen <= FSTORE_1)) - || ((seen >= DSTORE_0) && (seen <= DSTORE_1))) { - int reg = RegisterUtils.getStoreReg(this, seen); - Integer iReg = Integer14.valueOf(reg); - int pc = getPC(); - if (catchHandlers.contains(Integer14.valueOf(pc))) - ignoreRegs.add(iReg); - else if (sawNull) - ignoreRegs.add(iReg); - - if (!ignoreRegs.contains(iReg)) { - ScopeBlock sb = findScopeBlock(rootScopeBlock, pc); - if (sb != null) { - sb.addStore(reg, pc); - if (sawDup) - sb.addLoad(reg, pc); - } - else - ignoreRegs.add(iReg); - } - } else if ((seen == ALOAD) - || (seen == ILOAD) - || (seen == LLOAD) - || (seen == FLOAD) - || (seen == DLOAD) - || ((seen >= ALOAD_0) && (seen <= ALOAD_3)) - || ((seen >= ILOAD_0) && (seen <= ILOAD_3)) - || ((seen >= LLOAD_0) && (seen <= LLOAD_1)) - || ((seen >= FLOAD_0) && (seen <= FLOAD_1)) - || ((seen >= DLOAD_0) && (seen <= DLOAD_1))) { - int reg = RegisterUtils.getLoadReg(this, seen); - if (!ignoreRegs.contains(Integer14.valueOf(reg))) { - ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); - if (sb != null) - sb.addLoad(reg, getPC()); - else - ignoreRegs.add(Integer14.valueOf(reg)); - } - } else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == GOTO_W)) { - int target = getBranchTarget(); - if (target > getPC()) { - if ((seen == GOTO) || (seen == GOTO_W)) { - Integer nextPC = Integer14.valueOf(getNextPC()); - if (!switchTargets.contains(nextPC)) { - ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), getNextPC()); - if (sb == null) { - sb = new ScopeBlock(getPC(), target); - sb.setLoop(); - sb.setGoto(); - rootScopeBlock.addChild(sb); - } else { - sb = new ScopeBlock(getPC(), target); - sb.setGoto(); - rootScopeBlock.addChild(sb); - } - } - } else { - ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target); - if ((sb != null) && (!sb.isLoop) && !sb.hasChildren()) { - if (sb.isGoto()) { - ScopeBlock parent = sb.getParent(); - sb.pushUpLoadStores(); - if (parent != null) - parent.removeChild(sb); - sb = new ScopeBlock(getPC(), target); - rootScopeBlock.addChild(sb); - } else { - sb.pushUpLoadStores(); - sb.setStart(getPC()); - sb.setFinish(target); - } - } else { - sb = new ScopeBlock(getPC(), target); - rootScopeBlock.addChild(sb); - } - } - } else { - ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); - if (sb != null) - sb.setLoop(); - } - } else if ((seen == TABLESWITCH) || (seen == LOOKUPSWITCH)) { - int pc = getPC(); - int[] offsets = getSwitchOffsets(); - List<Integer> targets = new ArrayList<Integer>(); - for (int i = 0; i < offsets.length; i++) - targets.add(Integer14.valueOf(offsets[i] + pc)); - Integer defOffset = Integer14.valueOf(getDefaultSwitchOffset() + pc); - if (!targets.contains(defOffset)) - targets.add(defOffset); - Collections.sort(targets); - - Integer lastTarget = targets.get(0); - for (int i = 1; i < targets.size(); i++) { - Integer nextTarget = targets.get(i); - ScopeBlock sb = new ScopeBlock(lastTarget.intValue(), nextTarget.intValue()); - rootScopeBlock.addChild(sb); - lastTarget = nextTarget; - } - switchTargets.addAll(targets); - } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEVIRTUAL)) { - if ("wasNull".equals(getNameConstantOperand()) - && "()Z".equals(getSigConstantOperand())) - dontReport = true; - } - - sawDup = (seen == DUP); - sawNull = (seen == ACONST_NULL); - } - - /** - * returns the scope block in which this register was assigned, by traversing the scope block tree - * - * @param sb the scope block to start searching in - * @param pc the current program counter - * @return the scope block or null if not found - */ - private ScopeBlock findScopeBlock(ScopeBlock sb, int pc) { - - if ((pc > sb.getStart()) && (pc < sb.getFinish())) { - if (sb.children != null) { - for (ScopeBlock child : sb.children) { - ScopeBlock foundSb = findScopeBlock(child, pc); - if (foundSb != null) - return foundSb; - } - } - return sb; - } - return null; - } - - /** - * returns an existing scope block that has the same target as the one looked for - * - * @param sb the scope block to start with - * @param target the target to look for - * - * @return the scope block found or null - */ - private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int start, int target) { - ScopeBlock parentBlock = null; - if ((sb.startLocation < start) && (sb.finishLocation >= start)) { - if ((sb.finishLocation <= target) || (sb.isGoto() && !sb.isLoop())) - parentBlock = sb; - } - - if (sb.children != null) - { - for (ScopeBlock child : sb.children) { - ScopeBlock targetBlock = findScopeBlockWithTarget(child, start, target); - if (targetBlock != null) - return targetBlock; - } - } - - return parentBlock; - } - - /** holds the description of a scope { } block, be it a for, if, while block - */ - private class ScopeBlock - { - private ScopeBlock parent; - private int startLocation; - private int finishLocation; - private boolean isLoop; - private boolean isGoto; - private Map<Integer, Integer> loads; - private Map<Integer, Integer> stores; - private List<ScopeBlock> children; - - /** construts a new scope block - * - * @param start the beginning of the block - * @param finish the end of the block - */ - public ScopeBlock(int start, int finish) { - parent = null; - startLocation = start; - finishLocation = finish; - isLoop = false; - isGoto = false; - loads = null; - stores = null; - children = null; - } - - /** - * returns a string representation of the scope block - * - * @returns a string representation - */ - @Override - public String toString() { - return "Start=" + startLocation + " Finish=" + finishLocation + " Loop=" + isLoop + " Loads=" + loads + " Stores=" + stores; - } - - /** - * returns the scope blocks parent - * - * @return the parent of this scope block - */ - public ScopeBlock getParent() { - return parent; - } - - /** returns the start of the block - * - * @return the start of the block - */ - public int getStart() { - return startLocation; - } - - /** returns the end of the block - * - * @return the end of the block - */ - public int getFinish() { - return finishLocation; - } - - /** - * sets the start pc of the block - * @param start the start pc - */ - public void setStart(int start) { - startLocation = start; - } - - /** - * sets the finish pc of the block - * @param finish the finish pc - */ - public void setFinish(int finish) { - finishLocation = finish; - } - - public boolean hasChildren() { - return children != null; - } - /** - * sets that this block is a loop - */ - public void setLoop() { - isLoop = true; - } - - /** - * returns whether this scope block is a loop - * - * @returns whether this block is a loop - */ - public boolean isLoop() { - return isLoop; - } - - /** - * sets that this block was caused from a goto, (an if block exit) - */ - public void setGoto() { - isGoto = true; - } - - /** - * returns whether this block was caused from a goto - * - * @returns whether this block was caused by a goto - */ - public boolean isGoto() { - return isGoto; - } - - /** - * adds the register as a store in this scope block - * - * @param reg the register that was stored - * @param pc the instruction that did the store - */ - public void addStore(int reg, int pc) { - if (stores == null) - stores = new HashMap<Integer, Integer>(); - - stores.put(Integer14.valueOf(reg), Integer14.valueOf(pc)); - } - - /** - * adds the register as a load in this scope block - * - * @param reg the register that was loaded - * @param pc the instruction that did the load - */ - public void addLoad(int reg, int pc) { - if (loads == null) - loads = new HashMap<Integer, Integer>(); - - loads.put(Integer14.valueOf(reg), Integer14.valueOf(pc)); - } - - /** - * adds a scope block to this subtree by finding the correct place in the hierarchy to store it - * - * @param child the scope block to add to the tree - */ - public void addChild(ScopeBlock newChild) { - newChild.parent = this; - - if (children != null) { - for (ScopeBlock child : children) { - if ((newChild.startLocation > child.startLocation) && (newChild.finishLocation < child.finishLocation)) { - child.addChild(newChild); - return; - } - } - int pos = 0; - for (ScopeBlock child : children) { - if (newChild.startLocation < child.startLocation) { - children.add(pos, newChild); - return; - } - pos++; - } - children.add(newChild); - return; - } - children = new ArrayList<ScopeBlock>(); - children.add(newChild); - } - - /** - * removes a child from this node - * @param child the child to remove - */ - public void removeChild(ScopeBlock child) { - if (children != null) - children.remove(child); - } - - /** - * report stores that occur at scopes higher than associated loads that are not involved with loops - */ - public void findBugs(Set<Integer> parentUsedRegs) { - if (isLoop) - return; - - Set<Integer> usedRegs = new HashSet<Integer>(parentUsedRegs); - if (stores != null) - usedRegs.addAll(stores.keySet()); - if (loads != null) - usedRegs.addAll(loads.keySet()); - - if (stores != null) { - if (loads != null) - stores.keySet().removeAll(loads.keySet()); - stores.keySet().removeAll(parentUsedRegs); - - if (stores.size() > 0) { - if (children != null) { - for (Map.Entry<Integer, Integer> entry : stores.entrySet()) { - int childUseCount = 0; - boolean inLoop = false; - Integer reg = entry.getKey(); - for (ScopeBlock child : children) { - if (child.usesReg(reg)) { - if (child.isLoop) { - inLoop = true; - break; - } - childUseCount++; - } - } - if ((!inLoop) && (childUseCount == 1)) { - bugReporter.reportBug(new BugInstance(BloatedAssignmentScope.this, "BAS_BLOATED_ASSIGNMENT_SCOPE", NORMAL_PRIORITY) - .addClass(BloatedAssignmentScope.this) - .addMethod(BloatedAssignmentScope.this) - .addSourceLine(BloatedAssignmentScope.this, entry.getValue().intValue())); - } - } - } - } - } - - if (children != null) { - for (ScopeBlock child : children) { - child.findBugs(usedRegs); - } - } - } - - /** - * returns whether this block either loads or stores into the register in question - * - * @param reg the register to look for loads or stores - * - * @return whether the block uses the register - */ - public boolean usesReg(Integer reg) { - if ((loads != null) && (loads.containsKey(reg))) - return true; - if ((stores != null) && (stores.containsKey(reg))) - return true; - - if (children != null) { - for (ScopeBlock child : children) { - if (child.usesReg(reg)) - return true; - } - } - - return false; - } - - /** - * push all loads and stores to this block up to the parent - */ - public void pushUpLoadStores() { - if (parent != null) { - if (loads != null) { - if (parent.loads != null) - parent.loads.putAll(loads); - else - parent.loads = loads; - } - if (stores != null) { - if (parent.stores != null) - parent.stores.putAll(stores); - else - parent.stores = stores; - } - loads = null; - stores = null; - } - } - } -} +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2007 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.detect; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.CodeException; +import org.apache.bcel.classfile.Method; + +import com.mebigfatguy.fbcontrib.utils.Integer14; +import com.mebigfatguy.fbcontrib.utils.RegisterUtils; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * looks for variable assignments at a scope larger than its use. In this case, + * the assignment can be pushed down into the smaller scope to reduce the performance + * impact of that assignment. + */ +public class BloatedAssignmentScope extends BytecodeScanningDetector +{ + BugReporter bugReporter; + private Set<Integer> ignoreRegs; + private ScopeBlock rootScopeBlock; + private Set<Integer> catchHandlers; + private Set<Integer> switchTargets; + private boolean dontReport; + private boolean sawDup; + private boolean sawNull; + + /** + * constructs a BAS detector given the reporter to report bugs on + + * @param bugReporter the sync of bug reports + */ + public BloatedAssignmentScope(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * implements the visitor to create and the clear the register to location map + * + * @param classContext the context object of the currently parsed class + */ + @Override + public void visitClassContext(ClassContext classContext) { + try { + ignoreRegs = new HashSet<Integer>(); + catchHandlers = new HashSet<Integer>(); + switchTargets = new HashSet<Integer>(); + super.visitClassContext(classContext); + } finally { + ignoreRegs = null; + catchHandlers = null; + switchTargets = null; + } + } + + /** + * implements the visitor to reset the register to location map + * + * @param obj the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + try { + + ignoreRegs.clear(); + Method method = getMethod(); + if (!method.isStatic()) + ignoreRegs.add(Integer14.valueOf(0)); + + int[] parmRegs = RegisterUtils.getParameterRegisters(method); + for (int parm : parmRegs) { + ignoreRegs.add(Integer14.valueOf(parm)); + } + + rootScopeBlock = new ScopeBlock(0, obj.getLength()); + catchHandlers.clear(); + CodeException[] exceptions = obj.getExceptionTable(); + if (exceptions != null) { + for (CodeException ex : exceptions) { + catchHandlers.add(Integer14.valueOf(ex.getHandlerPC())); + } + } + + switchTargets.clear(); + dontReport = false; + sawDup = false; + sawNull = false; + super.visitCode(obj); + + if (!dontReport) + rootScopeBlock.findBugs(new HashSet<Integer>()); + + } finally { + rootScopeBlock = null; + } + } + + /** + * implements the visitor to look for variables assigned below the scope + * in which they are used. + * + * @param seen the opcode of the currently parsed instruction + */ + @Override + public void sawOpcode(int seen) { + if ((seen == ASTORE) + || (seen == ISTORE) + || (seen == LSTORE) + || (seen == FSTORE) + || (seen == DSTORE) + || ((seen >= ASTORE_0) && (seen <= ASTORE_3)) + || ((seen >= ISTORE_0) && (seen <= ISTORE_3)) + || ((seen >= LSTORE_0) && (seen <= LSTORE_1)) + || ((seen >= FSTORE_0) && (seen <= FSTORE_1)) + || ((seen >= DSTORE_0) && (seen <= DSTORE_1))) { + int reg = RegisterUtils.getStoreReg(this, seen); + Integer iReg = Integer14.valueOf(reg); + int pc = getPC(); + if (catchHandlers.contains(Integer14.valueOf(pc))) + ignoreRegs.add(iReg); + else if (sawNull) + ignoreRegs.add(iReg); + + if (!ignoreRegs.contains(iReg)) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, pc); + if (sb != null) { + sb.addStore(reg, pc); + if (sawDup) + sb.addLoad(reg, pc); + } + else + ignoreRegs.add(iReg); + } + } else if ((seen == ALOAD) + || (seen == ILOAD) + || (seen == LLOAD) + || (seen == FLOAD) + || (seen == DLOAD) + || ((seen >= ALOAD_0) && (seen <= ALOAD_3)) + || ((seen >= ILOAD_0) && (seen <= ILOAD_3)) + || ((seen >= LLOAD_0) && (seen <= LLOAD_1)) + || ((seen >= FLOAD_0) && (seen <= FLOAD_1)) + || ((seen >= DLOAD_0) && (seen <= DLOAD_1))) { + int reg = RegisterUtils.getLoadReg(this, seen); + if (!ignoreRegs.contains(Integer14.valueOf(reg))) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); + if (sb != null) + sb.addLoad(reg, getPC()); + else + ignoreRegs.add(Integer14.valueOf(reg)); + } + } else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == GOTO_W)) { + int target = getBranchTarget(); + if (target > getPC()) { + if ((seen == GOTO) || (seen == GOTO_W)) { + Integer nextPC = Integer14.valueOf(getNextPC()); + if (!switchTargets.contains(nextPC)) { + ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), getNextPC()); + if (sb == null) { + sb = new ScopeBlock(getPC(), target); + sb.setLoop(); + sb.setGoto(); + rootScopeBlock.addChild(sb); + } else { + sb = new ScopeBlock(getPC(), target); + sb.setGoto(); + rootScopeBlock.addChild(sb); + } + } + } else { + ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target); + if ((sb != null) && (!sb.isLoop) && !sb.hasChildren()) { + if (sb.isGoto()) { + ScopeBlock parent = sb.getParent(); + sb.pushUpLoadStores(); + if (parent != null) + parent.removeChild(sb); + sb = new ScopeBlock(getPC(), target); + rootScopeBlock.addChild(sb); + } else { + sb.pushUpLoadStores(); + sb.setStart(getPC()); + sb.setFinish(target); + } + } else { + sb = new ScopeBlock(getPC(), target); + rootScopeBlock.addChild(sb); + } + } + } else { + ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); + if (sb != null) + sb.setLoop(); + } + } else if ((seen == TABLESWITCH) || (seen == LOOKUPSWITCH)) { + int pc = getPC(); + int[] offsets = getSwitchOffsets(); + List<Integer> targets = new ArrayList<Integer>(); + for (int i = 0; i < offsets.length; i++) + targets.add(Integer14.valueOf(offsets[i] + pc)); + Integer defOffset = Integer14.valueOf(getDefaultSwitchOffset() + pc); + if (!targets.contains(defOffset)) + targets.add(defOffset); + Collections.sort(targets); + + Integer lastTarget = targets.get(0); + for (int i = 1; i < targets.size(); i++) { + Integer nextTarget = targets.get(i); + ScopeBlock sb = new ScopeBlock(lastTarget.intValue(), nextTarget.intValue()); + rootScopeBlock.addChild(sb); + lastTarget = nextTarget; + } + switchTargets.addAll(targets); + } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEVIRTUAL)) { + if ("wasNull".equals(getNameConstantOperand()) + && "()Z".equals(getSigConstantOperand())) + dontReport = true; + } + + sawDup = (seen == DUP); + sawNull = (seen == ACONST_NULL); + } + + /** + * returns the scope block in which this register was assigned, by traversing the scope block tree + * + * @param sb the scope block to start searching in + * @param pc the current program counter + * @return the scope block or null if not found + */ + private ScopeBlock findScopeBlock(ScopeBlock sb, int pc) { + + if ((pc > sb.getStart()) && (pc < sb.getFinish())) { + if (sb.children != null) { + for (ScopeBlock child : sb.children) { + ScopeBlock foundSb = findScopeBlock(child, pc); + if (foundSb != null) + return foundSb; + } + } + return sb; + } + return null; + } + + /** + * returns an existing scope block that has the same target as the one looked for + * + * @param sb the scope block to start with + * @param target the target to look for + * + * @return the scope block found or null + */ + private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int start, int target) { + ScopeBlock parentBlock = null; + if ((sb.startLocation < start) && (sb.finishLocation >= start)) { + if ((sb.finishLocation <= target) || (sb.isGoto() && !sb.isLoop())) + parentBlock = sb; + } + + if (sb.children != null) + { + for (ScopeBlock child : sb.children) { + ScopeBlock targetBlock = findScopeBlockWithTarget(child, start, target); + if (targetBlock != null) + return targetBlock; + } + } + + return parentBlock; + } + + /** holds the description of a scope { } block, be it a for, if, while block + */ + private class ScopeBlock + { + private ScopeBlock parent; + private int startLocation; + private int finishLocation; + private boolean isLoop; + private boolean isGoto; + private Map<Integer, Integer> loads; + private Map<Integer, Integer> stores; + private List<ScopeBlock> children; + + /** construts a new scope block + * + * @param start the beginning of the block + * @param finish the end of the block + */ + public ScopeBlock(int start, int finish) { + parent = null; + startLocation = start; + finishLocation = finish; + isLoop = false; + isGoto = false; + loads = null; + stores = null; + children = null; + } + + /** + * returns a string representation of the scope block + * + * @returns a string representation + */ + @Override + public String toString() { + return "Start=" + startLocation + " Finish=" + finishLocation + " Loop=" + isLoop + " Loads=" + loads + " Stores=" + stores; + } + + /** + * returns the scope blocks parent + * + * @return the parent of this scope block + */ + public ScopeBlock getParent() { + return parent; + } + + /** returns the start of the block + * + * @return the start of the block + */ + public int getStart() { + return startLocation; + } + + /** returns the end of the block + * + * @return the end of the block + */ + public int getFinish() { + return finishLocation; + } + + /** + * sets the start pc of the block + * @param start the start pc + */ + public void setStart(int start) { + startLocation = start; + } + + /** + * sets the finish pc of the block + * @param finish the finish pc + */ + public void setFinish(int finish) { + finishLocation = finish; + } + + public boolean hasChildren() { + return children != null; + } + /** + * sets that this block is a loop + */ + public void setLoop() { + isLoop = true; + } + + /** + * returns whether this scope block is a loop + * + * @returns whether this block is a loop + */ + public boolean isLoop() { + return isLoop; + } + + /** + * sets that this block was caused from a goto, (an if block exit) + */ + public void setGoto() { + isGoto = true; + } + + /** + * returns whether this block was caused from a goto + * + * @returns whether this block was caused by a goto + */ + public boolean isGoto() { + return isGoto; + } + + /** + * adds the register as a store in this scope block + * + * @param reg the register that was stored + * @param pc the instruction that did the store + */ + public void addStore(int reg, int pc) { + if (stores == null) + stores = new HashMap<Integer, Integer>(); + + stores.put(Integer14.valueOf(reg), Integer14.valueOf(pc)); + } + + /** + * adds the register as a load in this scope block + * + * @param reg the register that was loaded + * @param pc the instruction that did the load + */ + public void addLoad(int reg, int pc) { + if (loads == null) + loads = new HashMap<Integer, Integer>(); + + loads.put(Integer14.valueOf(reg), Integer14.valueOf(pc)); + } + + /** + * adds a scope block to this subtree by finding the correct place in the hierarchy to store it + * + * @param child the scope block to add to the tree + */ + public void addChild(ScopeBlock newChild) { + newChild.parent = this; + + if (children != null) { + for (ScopeBlock child : children) { + if ((newChild.startLocation > child.startLocation) && (newChild.finishLocation < child.finishLocation)) { + child.addChild(newChild); + return; + } + } + int pos = 0; + for (ScopeBlock child : children) { + if (newChild.startLocation < child.startLocation) { + children.add(pos, newChild); + return; + } + pos++; + } + children.add(newChild); + return; + } + children = new ArrayList<ScopeBlock>(); + children.add(newChild); + } + + /** + * removes a child from this node + * @param child the child to remove + */ + public void removeChild(ScopeBlock child) { + if (children != null) + children.remove(child); + } + + /** + * report stores that occur at scopes higher than associated loads that are not involved with loops + */ + public void findBugs(Set<Integer> parentUsedRegs) { + if (isLoop) + return; + + Set<Integer> usedRegs = new HashSet<Integer>(parentUsedRegs); + if (stores != null) + usedRegs.addAll(stores.keySet()); + if (loads != null) + usedRegs.addAll(loads.keySet()); + + if (stores != null) { + if (loads != null) + stores.keySet().removeAll(loads.keySet()); + stores.keySet().removeAll(parentUsedRegs); + + if (stores.size() > 0) { + if (children != null) { + for (Map.Entry<Integer, Integer> entry : stores.entrySet()) { + int childUseCount = 0; + boolean inLoop = false; + Integer reg = entry.getKey(); + for (ScopeBlock child : children) { + if (child.usesReg(reg)) { + if (child.isLoop) { + inLoop = true; + break; + } + childUseCount++; + } + } + if ((!inLoop) && (childUseCount == 1)) { + bugReporter.reportBug(new BugInstance(BloatedAssignmentScope.this, "BAS_BLOATED_ASSIGNMENT_SCOPE", NORMAL_PRIORITY) + .addClass(BloatedAssignmentScope.this) + .addMethod(BloatedAssignmentScope.this) + .addSourceLine(BloatedAssignmentScope.this, entry.getValue().intValue())); + } + } + } + } + } + + if (children != null) { + for (ScopeBlock child : children) { + child.findBugs(usedRegs); + } + } + } + + /** + * returns whether this block either loads or stores into the register in question + * + * @param reg the register to look for loads or stores + * + * @return whether the block uses the register + */ + public boolean usesReg(Integer reg) { + if ((loads != null) && (loads.containsKey(reg))) + return true; + if ((stores != null) && (stores.containsKey(reg))) + return true; + + if (children != null) { + for (ScopeBlock child : children) { + if (child.usesReg(reg)) + return true; + } + } + + return false; + } + + /** + * push all loads and stores to this block up to the parent + */ + public void pushUpLoadStores() { + if (parent != null) { + if (loads != null) { + if (parent.loads != null) + parent.loads.putAll(loads); + else + parent.loads = loads; + } + if (stores != null) { + if (parent.stores != null) + parent.stores.putAll(stores); + else + parent.stores = stores; + } + loads = null; + stores = null; + } + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java ___________________________________________________________________ Name: svn:mime-type + text/plain Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java ___________________________________________________________________ Name: svn:mime-type + text/plain Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java ___________________________________________________________________ Name: svn:mime-type + text/plain Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java ___________________________________________________________________ Name: svn:mime-type + text/plain Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java ___________________________________________________________________ Name: svn:mime-type + text/plain Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java ___________________________________________________________________ Name: svn:mime-type + text/plain Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java ___________________________________________________________________ Name: svn:mime-type + text/plain Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java ___________________________________________________________________ Name: svn:mime-type + text/plain Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-09-15 03:02:05 UTC (rev 897) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-09-15 04:29:10 UTC (rev 898) @@ -1,378 +1,378 @@ -/* - * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2007 Dave Brosius - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package com.mebigfatguy.fbcontrib.detect; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.bcel.Repository; -import org.apache.bcel.classfile.Code; -import org.apache.bcel.classfile.JavaClass; - -import com.mebigfatguy.fbcontrib.utils.Integer14; -import com.mebigfatguy.fbcontrib.utils.RegisterUtils; - -import edu.umd.cs.findbugs.BugInstance; -import edu.umd.cs.findbugs.BugReporter; -import edu.umd.cs.findbugs.BytecodeScanningDetector; -import edu.umd.cs.findbugs.FieldAnnotation; -import edu.umd.cs.findbugs.OpcodeStack; -import edu.umd.cs.findbugs.ba.ClassContext; -import edu.umd.cs.findbugs.ba.XField; -import edu.umd.cs.findbugs.classfile.FieldDescriptor; - -/** - * looks for deletion of items from a collection using the remove method - * of the collection at the same time that the collection is being iterated on. If - * this occurs the iterator will become invalid and throw a ConcurrentModificationException. - * Instead, the remove should be called on the iterator itself. - */ -public class DeletingWhileIterating extends BytecodeScanningDetector -{ - private static JavaClass collectionClass; - private static JavaClass iteratorClass; - private static final Set<String> collectionMethods; - static { - try { - collectionClass = Repository.lookupClass("java.util.Collection"); - iteratorClass = Repository.lookupClass("java.util.Iterator"); - } catch (ClassNotFoundException cnfe) { - collectionClass = null; - iteratorClass = null; - } - - collectionMethods = new HashSet<String>(); - collectionMethods.add("entrySet()Ljava/lang/Set;"); - collectionMethods.add("keySet()Ljava/lang/Set;"); - collectionMethods.add("values()Ljava/lang/Collection;"); - } - private static final Map<String, Integer> modifyingMethods = new HashMap<String, Integer>(); - static { - modifyingMethods.put("add(Ljava/lang/Object;)Z", Integer14.valueOf(1)); - modifyingMethods.put("addAll(Ljava/util/Collection;)Z", Integer14.valueOf(1)); - modifyingMethods.put("addAll(ILjava/util/Collection;)Z", Integer14.valueOf(2)); - modifyingMethods.put("clear()V", Integer14.valueOf(0)); - modifyingMethods.put("remove(I)Ljava/lang/Object;", Integer14.valueOf(1)); - modifyingMethods.put("removeAll(Ljava/util/Collection;)Z", Integer14.valueOf(1)); - modifyingMethods.put("retainAll(Ljava/util/Collection;)Z", Integer14.valueOf(1)); - modifyingMethods.put("set(ILjava/lang/Object;)Ljava/lang/Object;", Integer14.valueOf(2)); - - } - - private BugReporter bugReporter; - private OpcodeStack stack; - private List<Set<Comparable>> collectionGroups; - private Map<Integer, Integer> groupToIterator; - private Map<Integer, Loop> loops; - - /** - * constructs a DWI detector given the reporter to report bugs on - * @param bugReporter the sync of bug reports - */ - public DeletingWhileIterating(BugReporter bugReporter) { - this.bugReporter = bugReporter; - } - - /** - * implements the visitor to setup the opcode stack, collectionGroups, groupToIterator and loops - * - * @param classContext the context object of the currently parsed class - */ - @Override - public void visitClassContext(ClassContext classContext) { - if ((collectionClass == null) || (iteratorClass == null)) - return; - - try { - stack = new OpcodeStack(); - collectionGroups = new ArrayList<Set<Comparable>>(); - groupToIterator = new HashMap<Integer, Integer>(); - loops = new HashMap<Integer, Loop>(); - super.visitClassContext(classContext); - } finally { - stack = null; - collectionGroups = null; - groupToIterator = null; - loops = null; - } - } - - /** - * implements the visitor to reset the stack, collectionGroups, groupToIterator and loops - * - * @param obj the context object of the currently parsed code block - */ - @Override - public void visitCode(Code obj) { - stack.resetForMethodEntry(this); - collectionGroups.clear(); - groupToIterator.clear(); - loops.clear(); - super.visitCode(obj); - } - - /** - * implements the visitor to look for deletes on collections that are being iterated - * - * @param seen the opcode of the currently parsed instruction - */ - @Override - public void sawOpcode(int seen) { - int groupId = -1; - - try { - if (seen == INVOKEINTERFACE) - { - String className = getClassConstantOperand(); - String methodName = getNameConstantOperand(); - String signature = getSigConstantOperand(); - String methodInfo = methodName + signature; - - if (isCollection(className)) { - if (collectionMethods.contains(methodInfo)) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item itm = stack.getStackItem(0); - groupId = findCollectionGroup(itm, true); - - } - } else if ("iterator()Ljava/util/Iterator;".equals(methodInfo)) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item itm = stack.getStackItem(0); - groupId = findCollectionGroup(itm, true); - } - } else if ("remove(Ljava/lang/Object;)Z".equals(methodInfo)) { - if (stack.getStackDepth() > 1) { - OpcodeStack.Item itm = stack.getStackItem(1); - int id = findCollectionGroup(itm, true); - if (id >= 0) { - Integer it = groupToIterator.get(Integer14.valueOf(id)); - Loop loop = loops.get(it); - if (loop != null) { - int pc = getPC(); - if (loop.hasPC(pc)) { - bugReporter.reportBug(new BugInstance(this, "DWI_DELETING_WHILE_ITERATING", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } - } - } else { - Integer numArgs = modifyingMethods.get(methodInfo); - if (numArgs != null) { - if (stack.getStackDepth() > numArgs.intValue()) { - OpcodeStack.Item itm = stack.getStackItem(numArgs.intValue()); - int id = findCollectionGroup(itm, true); - if (id >= 0) { - Integer it = groupToIterator.get(Integer14.valueOf(id)); - if (it != null) { - Loop loop = loops.get(it); - if (loop != null) { - int pc = getPC(); - if (loop.hasPC(pc)) { - bugReporter.reportBug(new BugInstance(this, "DWI_MODIFYING_WHILE_ITERATING", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } - } - } - } - } - } else if ("java/util/Iterator".equals(className) && "hasNext()Z".equals(methodInfo)) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item itm = stack.getStackItem(0); - Integer id = (Integer)itm.getUserValue(); - if (id != null) - groupId = id.intValue(); - } - } - } else if (seen == PUTFIELD) { - if (stack.getStackDepth() > 1) { - OpcodeStack.Item itm = stack.getStackItem(0); - - Integer id = (Integer)itm.getUserValue(); - if (id == null) { - FieldAnnotation fa = FieldAnnotation.fromFieldDescriptor(new FieldDescriptor(getClassConstantOperand(), getNameConstantOperand(), getSigConstantOperand(), false)); - itm = new OpcodeStack.Item(itm.getSignature(), fa, stack.getStackItem(1).getRegisterNumber()); - removeFromCollectionGroup(itm); - } - } - } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item itm = stack.getStackItem(0); - Integer id = (Integer)itm.getUserValue(); - if (id != null) { - int reg = RegisterUtils.getAStoreReg(this, seen); - - try { - JavaClass cls = itm.getJavaClass(); - if ((cls != null) && cls.implementationOf(iteratorClass)) { - Integer regIt = Integer14.valueOf(reg); - Iterator<Integer> curIt = groupToIterator.values().iterator(); - while (curIt.hasNext()) { - if (curIt.next().equals(regIt)) - curIt.remove(); - } - groupToIterator.put(id, regIt); - } - - Set<Comparable> group = collectionGroups.get(id.intValue()); - if (group != null) { - group.add(Integer14.valueOf(reg)); - } - } catch (ClassNotFoundException cnfe) { - bugReporter.reportMissingClass(cnfe); - } - } - } - } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { - int reg = RegisterUtils.getALoadReg(this, seen); - OpcodeStack.Item itm = new OpcodeStack.Item(new OpcodeStack.Item(), reg); - groupId = findCollectionGroup(itm, false); - } else if (seen == IFEQ) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item itm = stack.getStackItem(0); - Integer id = (Integer)itm.getUserValue(); - if (id != null) { - int target = getBranchTarget(); - int gotoAddr = target - 3; - int ins = getCode().getCode()[gotoAddr]; - if (ins < 0) - ins = 256 + ins; - if (ins == GOTO) { - Integer reg = groupToIterator.get(id); - if (reg != null) - loops.put(reg, new Loop(getPC(), gotoAddr)); - } - } - } - } - } finally { - stack.sawOpcode(this, seen); - if ((groupId >= 0) && (stack.getStackDepth() > 0)) { - OpcodeStack.Item itm = stack.getStackItem(0); - itm.setUserValue(Integer14.valueOf(groupId)); - } - } - } - - private boolean isCollection(String className) { - try { - JavaClass cls = Repository.lookupClass(className); - return cls.implementationOf(collectionClass); - } catch (ClassNotFoundException cnfe) { - bugReporter.reportMissingClass(cnfe); - return false; - } - } - - private Comparable getGroupElement(OpcodeStack.Item itm) { - Comparable groupElement = null; - - int reg = itm.getRegisterNumber(); - if (reg >= 0) - groupElement = Integer14.valueOf(reg); - else { - XField field = itm.getXField(); - if (field != null) { - int regLoad = itm.getFieldLoadedFromRegister(); - if (regLoad >= 0) - groupElement = field.getName() + ":{" + regLoad + "}"; - } - } - - return groupElement; - } - - private int findCollectionGroup(OpcodeStack.Item itm, boolean addIfNotFound) { - - Integer id = (Integer)itm.getUserValue(); - if (id != null) - return id.intValue(); - - Comparable groupElement = getGroupElement(itm); - if (groupElement != null) { - int numGroups = collectionGroups.size(); - for (int i = 0; i < numGroups; i++) { - Set<? extends Comparable> group = collectionGroups.get(i); - if (group.contains(groupElement)) { - return i; - } - } - - if (addIfNotFound) { - Set<Comparable> group = new HashSet<Comparable>(); - group.add(groupElement); - collectionGroups.add(group); - return collectionGroups.size() - 1; - } - } - - return -1; - } - - private void removeFromCollectionGroup(OpcodeStack.Item itm) { - Comparable groupElement = getGroupElement(itm); - if (groupElement != null) { - for (Set<? extends Comparable> group : collectionGroups) { - if (group.contains(groupElement)) { - group.remove(groupElement); - break; - } - } - } - } - - static class Loop - { - public int loopStart; - public int loopFinish; - - public Loop(int start, int finish) { - loopStart = start; - loopFinish = finish; - } - - public int getLoopFinish() { - return loopFinish; - } - - public int getLoopStart() { - return loopStart; - } - - public boolean hasPC(int pc) { - return (loopStart <= pc) && (pc <= loopFinish); - } - - @Override - public String toString() { - return "Start=" + loopStart + " Finish=" + loopFinish; - } - } -} +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2007 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distribu... [truncated message content] |
From: <dbr...@us...> - 2007-09-15 03:02:04
|
Revision: 897 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=897&view=rev Author: dbrosius Date: 2007-09-14 20:02:05 -0700 (Fri, 14 Sep 2007) Log Message: ----------- add copyright Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2007-06-29 16:54:46 UTC (rev 896) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2007-09-15 03:02:05 UTC (rev 897) @@ -1,3 +1,21 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2007 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.mebigfatguy.fbcontrib.detect; import java.util.HashMap; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-06-29 16:54:47
|
Revision: 896 http://svn.sourceforge.net/fb-contrib/?rev=896&view=rev Author: dbrosius Date: 2007-06-29 09:54:46 -0700 (Fri, 29 Jun 2007) Log Message: ----------- better filtering out of conditionals from loops Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2007-06-29 05:55:41 UTC (rev 895) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2007-06-29 16:54:46 UTC (rev 896) @@ -131,7 +131,7 @@ uValue = (Integer)valueItem.getUserValue(); if (uValue != null) { LoopInfo loop = loops.get(uValue); - if ((loop != null) && loop.isInLoop(getPC())) { + if ((loop != null) && loop.isInLoop(getPC(), false)) { bugReporter.reportBug(new BugInstance(this, "UAA_USE_ADD_ALL", NORMAL_PRIORITY) .addClass(this) .addMethod(this) @@ -151,6 +151,7 @@ || ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3)))) { sawLoad = true; } else if (seen == IFEQ) { + boolean loopFound = false; if (stack.getStackDepth() > 0) { if (getBranchOffset() > 0) { int gotoPos = getBranchTarget() - 3; @@ -166,9 +167,13 @@ if (uValue != null) { loops.put(uValue, new LoopInfo(getPC(), getBranchTarget())); } + loopFound = true; } - } else { - LoopInfo loop = findLoop(getPC()); + } + + if (!loopFound) + { + LoopInfo loop = findLoop(getPC(), true); if (loop != null) { loop.addConditionalRange(getPC(), getBranchTarget()); } @@ -177,7 +182,7 @@ } } else if (((seen > IFEQ) && (seen <= GOTO)) || (seen == IFNULL) || (seen == IFNONNULL)) { if (getBranchOffset() > 0) { - LoopInfo loop = findLoop(getPC()); + LoopInfo loop = findLoop(getPC(), true); if (loop != null) { loop.addConditionalRange(getPC(), getBranchTarget()); } @@ -238,9 +243,9 @@ return -1; } - private LoopInfo findLoop(int pc) { + private LoopInfo findLoop(int pc, boolean ignoreConditionals) { for (LoopInfo loop : loops.values()) { - if (loop.isInLoop(pc)) + if (loop.isInLoop(pc, ignoreConditionals)) return loop; } @@ -264,11 +269,14 @@ conditionalRanges.put(Integer14.valueOf(condStart), Integer14.valueOf(condEnd)); } - public boolean isInLoop(int pc) + public boolean isInLoop(int pc, boolean ignoreConditionals) { if ((pc < start) || (pc > end)) return false; + if (ignoreConditionals) + return true; + for (Map.Entry<Integer, Integer> entry : conditionalRanges.entrySet()) { if ((pc >= entry.getKey().intValue()) && pc <= entry.getValue().intValue()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-06-29 05:55:40
|
Revision: 895 http://svn.sourceforge.net/fb-contrib/?rev=895&view=rev Author: dbrosius Date: 2007-06-28 22:55:41 -0700 (Thu, 28 Jun 2007) Log Message: ----------- fix ifeq checking of loops Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2007-06-29 05:41:13 UTC (rev 894) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2007-06-29 05:55:41 UTC (rev 895) @@ -160,7 +160,7 @@ brOffset <<= 8; brOffset |= (0x0FF & code[gotoPos+2]); gotoPos += brOffset; - if (brOffset < getPC()) { + if (gotoPos < getPC()) { OpcodeStack.Item itm = stack.getStackItem(0); uValue = (Integer)itm.getUserValue(); if (uValue != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-06-29 05:41:11
|
Revision: 894 http://svn.sourceforge.net/fb-contrib/?rev=894&view=rev Author: dbrosius Date: 2007-06-28 22:41:13 -0700 (Thu, 28 Jun 2007) Log Message: ----------- filter out adds inside conditionals guarded by ifnull and ifnonnull as well. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2007-06-27 06:03:27 UTC (rev 893) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2007-06-29 05:41:13 UTC (rev 894) @@ -175,7 +175,7 @@ } } } - } else if ((seen > IFEQ) && (seen <= GOTO)) { + } else if (((seen > IFEQ) && (seen <= GOTO)) || (seen == IFNULL) || (seen == IFNONNULL)) { if (getBranchOffset() > 0) { LoopInfo loop = findLoop(getPC()); if (loop != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-06-27 06:03:27
|
Revision: 893 http://svn.sourceforge.net/fb-contrib/?rev=893&view=rev Author: dbrosius Date: 2007-06-26 23:03:27 -0700 (Tue, 26 Jun 2007) Log Message: ----------- ignore conditional else blocks as well. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2007-06-26 23:05:51 UTC (rev 892) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2007-06-27 06:03:27 UTC (rev 893) @@ -175,7 +175,7 @@ } } } - } else if ((seen > IFEQ) && (seen <= IF_ACMPNE)) { + } else if ((seen > IFEQ) && (seen <= GOTO)) { if (getBranchOffset() > 0) { LoopInfo loop = findLoop(getPC()); if (loop != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-06-26 23:05:50
|
Revision: 892 http://svn.sourceforge.net/fb-contrib/?rev=892&view=rev Author: dbrosius Date: 2007-06-26 16:05:51 -0700 (Tue, 26 Jun 2007) Log Message: ----------- javadoc cleanups Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticArrayCreatedInMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousWaitOnConcurrentObject.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or @@ -32,7 +32,7 @@ /** * looks for classes that implement interfaces by relying on methods being - * implemented in superclasses, even tho the superclass knows nothing about + * implemented in super classes, even though the superclass knows nothing about * the interface being implemented by the child. */ public class SpoiledChildInterfaceImplementor implements Detector { @@ -122,7 +122,7 @@ } /** - * removes methods found in an interface when a superinterface having the same methods + * removes methods found in an interface when a super interface having the same methods * is implemented in a parent. While this is somewhat hinky, we'll allow it. * * @param inf the interface to look for super interfaces for Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticArrayCreatedInMethod.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticArrayCreatedInMethod.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticArrayCreatedInMethod.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousWaitOnConcurrentObject.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousWaitOnConcurrentObject.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousWaitOnConcurrentObject.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or @@ -148,7 +148,7 @@ } /** - * checks if the curent opcode is a store, if so saves the register + * checks if the current opcode is a store, if so saves the register * * @param seen the opcode of the currently parsed instruction * @return if a store was seen Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java 2007-06-26 21:55:38 UTC (rev 891) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java 2007-06-26 23:05:51 UTC (rev 892) @@ -1,5 +1,5 @@ /* - * fb-contrib - Auxilliary detectors for Java programs + * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2007 Dave Brosius * * This library is free software; you can redistribute it and/or This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |