fb-contrib-commit Mailing List for fb-contrib (Page 57)
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...> - 2006-04-11 14:34:40
|
Revision: 440 Author: dbrosius Date: 2006-04-11 07:34:15 -0700 (Tue, 11 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=440&view=rev Log Message: ----------- ClassContext.getBytecodeSet seems to have settled down. Go back to directly calling it. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2006-04-11 14:28:33 UTC (rev 439) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2006-04-11 14:34:15 UTC (rev 440) @@ -28,7 +28,6 @@ import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; -import com.mebigfatguy.fbcontrib.utils.VersionTransition; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -83,7 +82,7 @@ * @return if the class uses synchronization */ public boolean prescreen(Method method) { - BitSet bytecodeSet = VersionTransition.getBytecodeSet(getClassContext(), method); + BitSet bytecodeSet = getClassContext().getBytecodeSet(method); return (bytecodeSet != null) && (bytecodeSet.get(Constants.NEWARRAY) || bytecodeSet.get(Constants.ANEWARRAY)); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2006-04-11 14:28:33 UTC (rev 439) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2006-04-11 14:34:15 UTC (rev 440) @@ -30,7 +30,6 @@ import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; -import com.mebigfatguy.fbcontrib.utils.VersionTransition; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -83,7 +82,7 @@ * @return if the class uses synchronization */ public boolean prescreen(Method method) { - BitSet bytecodeSet = VersionTransition.getBytecodeSet(getClassContext(), method); + BitSet bytecodeSet = getClassContext().getBytecodeSet(method); return (bytecodeSet != null) && (bytecodeSet.get(Constants.MONITORENTER)); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-11 14:28:33 UTC (rev 439) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-11 14:34:15 UTC (rev 440) @@ -38,8 +38,6 @@ import org.apache.bcel.generic.Instruction; import org.apache.bcel.generic.InstructionHandle; -import com.mebigfatguy.fbcontrib.utils.VersionTransition; - import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -152,7 +150,7 @@ * @return if the class uses synchronization */ public boolean prescreen(Method method) { - BitSet bytecodeSet = VersionTransition.getBytecodeSet(getClassContext(), method); + BitSet bytecodeSet = getClassContext().getBytecodeSet(method); return (bytecodeSet != null) && (bytecodeSet.get(Constants.PUTFIELD) || bytecodeSet.get(Constants.GETFIELD)); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-04-11 14:28:33 UTC (rev 439) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-04-11 14:34:15 UTC (rev 440) @@ -27,8 +27,6 @@ import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Method; -import com.mebigfatguy.fbcontrib.utils.VersionTransition; - import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -88,7 +86,7 @@ * @return if the class uses synchronization */ public boolean prescreen(Method method) { - BitSet bytecodeSet = VersionTransition.getBytecodeSet(getClassContext(), method); + BitSet bytecodeSet = getClassContext().getBytecodeSet(method); return (bytecodeSet != null) && (bytecodeSet.get(Constants.GOTO) || bytecodeSet.get(Constants.GOTO_W)); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-11 14:28:33 UTC (rev 439) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-11 14:34:15 UTC (rev 440) @@ -10,7 +10,6 @@ import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; -import com.mebigfatguy.fbcontrib.utils.VersionTransition; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -57,7 +56,7 @@ * @return if the class uses synchronization */ public boolean prescreen(Method method) { - BitSet bytecodeSet = VersionTransition.getBytecodeSet(getClassContext(), method); + BitSet bytecodeSet = getClassContext().getBytecodeSet(method); return bytecodeSet != null && (bytecodeSet.get(Constants.MONITORENTER)); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java 2006-04-11 14:28:33 UTC (rev 439) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java 2006-04-11 14:34:15 UTC (rev 440) @@ -30,8 +30,6 @@ import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.Type; -import com.mebigfatguy.fbcontrib.utils.VersionTransition; - import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -72,7 +70,7 @@ * @return if the class uses synchronization */ public boolean prescreen(Method method) { - BitSet bytecodeSet = VersionTransition.getBytecodeSet(getClassContext(), method); + BitSet bytecodeSet = getClassContext().getBytecodeSet(method); return (bytecodeSet != null) && (bytecodeSet.get(Constants.INVOKESTATIC)); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2006-04-11 14:28:33 UTC (rev 439) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2006-04-11 14:34:15 UTC (rev 440) @@ -109,7 +109,6 @@ */ @Override public void sawOpcode(int seen) { - int loadReg; switch (state) { case SEEN_NOTHING: if (lookForStore(seen)) Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java 2006-04-11 14:28:33 UTC (rev 439) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java 2006-04-11 14:34:15 UTC (rev 440) @@ -12,25 +12,4 @@ */ public class VersionTransition { - private static java.lang.reflect.Method gbs; - - /** - * manages the change to ClassContext getBytecodeSet from member to static method - * - * @param classContext the context object for the current class - * @param m the method to get the bytecode set for - * @return the byte code set - */ - - public static BitSet getBytecodeSet(ClassContext classContext, Method m) { - try { - if (gbs == null) - gbs = ClassContext.class.getMethod("getBytecodeSet", new Class[] { Method.class }); - return (BitSet)gbs.invoke(classContext, new Object[] { m }); - } catch (Exception e) { - BitSet byteCodeSet = new BitSet(256); - byteCodeSet.set(0, 255, true); - return byteCodeSet; - } - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-11 14:28:48
|
Revision: 439 Author: dbrosius Date: 2006-04-11 07:28:33 -0700 (Tue, 11 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=439&view=rev Log Message: ----------- reduce cyclomatic complexity Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2006-04-11 14:15:45 UTC (rev 438) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2006-04-11 14:28:33 UTC (rev 439) @@ -112,25 +112,8 @@ int loadReg; switch (state) { case SEEN_NOTHING: - if ((seen >= ISTORE) && (seen <= ASTORE)) { - storeReg = getRegisterOperand(); + if (lookForStore(seen)) state = SEEN_STORE; - } else if ((seen >= ISTORE_0) && (seen <= ISTORE_3)) { - storeReg = seen - ISTORE_0; - state = SEEN_STORE; - } else if ((seen >= LSTORE_0) && (seen <= LSTORE_3)) { - storeReg = seen - LSTORE_0; - state = SEEN_STORE; - } else if ((seen >= FSTORE_0) && (seen <= FSTORE_3)) { - storeReg = seen - FSTORE_0; - state = SEEN_STORE; - } else if ((seen >= DSTORE_0) && (seen <= DSTORE_3)) { - storeReg = seen - DSTORE_0; - state = SEEN_STORE; - } else if ((seen >= ASTORE_0) && (seen <= ASTORE_3)) { - storeReg = seen - ASTORE_0; - state = SEEN_STORE; - } break; case SEEN_STORE: @@ -139,26 +122,7 @@ return; } - if ((seen >= ILOAD) && (seen <= ALOAD)) { - loadReg = getRegisterOperand(); - state = (storeReg == loadReg) ? SEEN_LOAD : SEEN_NOTHING; - } else if ((seen >= ILOAD_0) && (seen <= ILOAD_3)) { - loadReg = seen - ILOAD_0; - state = (storeReg == loadReg) ? SEEN_LOAD : SEEN_NOTHING; - } else if ((seen >= LLOAD_0) && (seen <= LLOAD_3)) { - loadReg = seen - LLOAD_0; - state = (storeReg == loadReg) ? SEEN_LOAD : SEEN_NOTHING; - } else if ((seen >= FLOAD_0) && (seen <= FLOAD_3)) { - loadReg = seen - FLOAD_0; - state = (storeReg == loadReg) ? SEEN_LOAD : SEEN_NOTHING; - } else if ((seen >= DLOAD_0) && (seen <= DLOAD_3)) { - loadReg = seen - DLOAD_0; - state = (storeReg == loadReg) ? SEEN_LOAD : SEEN_NOTHING; - } else if ((seen >= ALOAD_0) && (seen <= ALOAD_3)) { - loadReg = seen - ALOAD_0; - state = (storeReg == loadReg) ? SEEN_LOAD : SEEN_NOTHING; - } else - state = SEEN_NOTHING; + state = lookForLoad(seen) ? SEEN_LOAD : SEEN_NOTHING; break; case SEEN_LOAD: @@ -177,5 +141,54 @@ } } - + + /** + * checks if the curent opcode is a store, if so saves the register + * + * @param seen the opcode of the currently parsed instruction + * @return if a store was seen + */ + private boolean lookForStore(int seen) { + if ((seen >= ISTORE) && (seen <= ASTORE)) + storeReg = getRegisterOperand(); + else if ((seen >= ISTORE_0) && (seen <= ISTORE_3)) + storeReg = seen - ISTORE_0; + else if ((seen >= LSTORE_0) && (seen <= LSTORE_3)) + storeReg = seen - LSTORE_0; + else if ((seen >= FSTORE_0) && (seen <= FSTORE_3)) + storeReg = seen - FSTORE_0; + else if ((seen >= DSTORE_0) && (seen <= DSTORE_3)) + storeReg = seen - DSTORE_0; + else if ((seen >= ASTORE_0) && (seen <= ASTORE_3)) + storeReg = seen - ASTORE_0; + else + return false; + return true; + } + + /** + * looks for a load of the register that was just stored + * + * @param seen the opcode of the currently parsed instruction + * @return if the load was seen + */ + private boolean lookForLoad(int seen) { + int loadReg; + if ((seen >= ILOAD) && (seen <= ALOAD)) + loadReg = getRegisterOperand(); + else if ((seen >= ILOAD_0) && (seen <= ILOAD_3)) + loadReg = seen - ILOAD_0; + else if ((seen >= LLOAD_0) && (seen <= LLOAD_3)) + loadReg = seen - LLOAD_0; + else if ((seen >= FLOAD_0) && (seen <= FLOAD_3)) + loadReg = seen - FLOAD_0; + else if ((seen >= DLOAD_0) && (seen <= DLOAD_3)) + loadReg = seen - DLOAD_0; + else if ((seen >= ALOAD_0) && (seen <= ALOAD_3)) + loadReg = seen - ALOAD_0; + else + return false; + + return (storeReg == loadReg); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-11 14:15:59
|
Revision: 438 Author: dbrosius Date: 2006-04-11 07:15:45 -0700 (Tue, 11 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=438&view=rev Log Message: ----------- remove unused Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-10 03:08:45 UTC (rev 437) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-11 14:15:45 UTC (rev 438) @@ -146,7 +146,6 @@ public void visitCode(Code obj) { Method m = getMethod(); if (!"<init>".equals(m.getName())) { - String attName = m.getName() + ":" + m.getSignature(); super.visitCode(obj); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-10 03:08:52
|
Revision: 437 Author: dbrosius Date: 2006-04-09 20:08:45 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=437&view=rev Log Message: ----------- adjust documented detector timings based on experimentation 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 2006-04-10 02:53:59 UTC (rev 436) +++ trunk/fb-contrib/etc/findbugs.xml 2006-04-10 03:08:45 UTC (rev 437) @@ -18,7 +18,7 @@ reports="ISB_INEFFICIENT_STRING_BUFFERING" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SyncCollectionIterators" - speed="fast" + speed="slow" reports="SCI_SYNCHRONIZED_COLLECTION_ITERATORS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CyclomaticComplexity" @@ -26,7 +26,7 @@ reports="CC_CYCLOMATIC_COMPLEXITY" /> <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyConcreteParameter" - speed="fast" + speed="moderate" reports="OCP_OVERLY_CONCRETE_PARAMETER" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ListIndexedIterating" @@ -34,7 +34,7 @@ reports="LII_LIST_INDEXED_ITERATING" /> <Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedCollectionContents" - speed="moderate" + speed="fast" reports="UCC_UNRELATED_COLLECTION_CONTENTS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeclaredRuntimeException" @@ -42,12 +42,12 @@ reports="DRE_DECLARED_RUNTIME_EXCEPTION" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" - speed="moderate" + speed="fast" reports="CE_CLASS_ENVY" disabled="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison" - speed="moderate" + speed="fast" reports="LSC_LITERAL_STRING_COMPARISON" /> <Detector class="com.mebigfatguy.fbcontrib.detect.PartiallyConstructedObjectAccess" @@ -63,7 +63,7 @@ reports="PL_PARALLEL_LISTS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.FinalParameters" - speed="fast" + speed="slow" reports="FP_FINAL_PARAMETERS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.AbstractClassEmptyMethods" @@ -107,7 +107,7 @@ reports="USBR_UNNECESSARY_STORE_BEFORE_RETURN" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CopiedOverriddenMethod" - speed="moderate" + speed="fast" reports="COM_COPIED_OVERRIDDEN_METHOD" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayBasedCollections" @@ -123,7 +123,7 @@ reports="AOM_ABSTRACT_OVERRIDDEN_METHOD" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CustomBuiltXML" - speed="moderate" + speed="fast" reports="CBX_CUSTOM_BUILT_XML" /> <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" @@ -160,7 +160,7 @@ reports="SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT" /> <Detector class="com.mebigfatguy.fbcontrib.detect.JDBCVendorReliance" - speed="moderate" + speed="fast" reports="JVR_JDBC_VENDOR_RELIANCE" /> <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleMemoryBloat" @@ -168,11 +168,11 @@ reports="PMB_POSSIBLE_MEMORY_BLOAT" /> <Detector class="com.mebigfatguy.fbcontrib.detect.LocalSynchronizedCollection" - speed="fast" + speed="moderate" reports="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" /> <Detector class="com.mebigfatguy.fbcontrib.detect.FieldCouldBeLocal" - speed="fast" + speed="slow" reports="FCBL_FIELD_COULD_BE_LOCAL" /> <Detector class="com.mebigfatguy.fbcontrib.detect.NonOwnedSynchronization" @@ -180,7 +180,7 @@ reports="NOS_NON_OWNED_SYNCHRONIZATION" /> <Detector class="com.mebigfatguy.fbcontrib.detect.NonRecycleableTaglibs" - speed="moderate" + speed="fast" reports="NRTL_NON_RECYCLEABLE_TAG_LIBS" /> <!-- BugPattern --> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-04-10 02:53:59 UTC (rev 436) +++ trunk/fb-contrib/etc/messages.xml 2006-04-10 03:08:45 UTC (rev 437) @@ -37,7 +37,7 @@ <p> As the collection in question was built thru Collections.synchronizedXXX, an assumption is made that this collection must be multithreaded safe. However, iterator access is used, which is explicitly unsafe. When iterators are to be used, synchronization should be done manually.</p> - <p>It is a fast detector</p> + <p>It is a slow detector</p> ]]> </Details> </Detector> @@ -58,7 +58,7 @@ <p> Looks for parameters that are defined by classes, but only use methods defined by an implemented interface or super class. Relying on concrete classes in public signatures causes cohesion, and makes low impact changes more difficult.</p> - <p>It is a fast detector</p> + <p>It is a moderately fast detector</p> ]]> </Details> </Detector> @@ -83,7 +83,7 @@ determine type. A better design usually can be had by creating a seperate class, which defines the different types required, and add an instance of that class to the collection, or array.</p> - <p>It is a moderately fast detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -108,7 +108,7 @@ methods. When this is the case, it is often better to implement this method in that other class, by refactoring the class to accept parameters it needs from the source class. The reporting percentage can be set with system property 'fb-contrib.ce.percent'.</p> - <p>It is a moderately fast detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -119,7 +119,7 @@ <p> Looks for methods that compare strings against literal strings, where the literal string is passed as the parameter. If the .equals or .compareTo is called on the literal itself, passing the variable as the parameter, you avoid the possibility of a NullPointerException.</p> - <p>It is a moderately fast detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -320,7 +320,7 @@ <![CDATA[ <p>Looks for methods that are direct copies of the implementation in the super class</p> </p> - <p>It is a moderately fast detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -366,7 +366,7 @@ and custom values together. Doing so makes brittle code, that is difficult to modify, validate and understand. It is cleaner to create external xml files that are transformed at runtime, using parameters set through Transformer.setParameter. - <p>It is a moderately fast detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -377,7 +377,7 @@ <p>Looks for methods that are implemented using synchronized blocks, but are overly synchronized because the beginning of the block only accesses local variables, and not member variables, or this.</p> - <p>It is a fast detector</p> + <p>It is a slow detector</p> ]]> </Details> </Detector> @@ -466,7 +466,7 @@ <![CDATA[ <p>Looks for uses of jdbc vendor specific classes and methods making the database access code non portable.</p> - <p>It is a moderately fast detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -489,7 +489,7 @@ variables, and never stored in fields or returned from methods. As local variables are by definition thread safe, using synchronized collections in this context makes no sense.</p> - <p>It is a fast detector</p> + <p>It is a moderately fast detector</p> ]]> </Details> </Detector> @@ -500,7 +500,7 @@ <p>looks for classes that define fields that are used in a locals only fashion, specifically private fields that are accessed first in each method with a store vs. a load.</p> - <p>It is a fast detector</p> + <p>It is a slow detector</p> ]]> </Details> </Detector> @@ -523,7 +523,7 @@ <![CDATA[ <p>looks for tag libraries that are not recycleable because backing members of taglib attributes are set in areas besides the setter method for the attribute.</p> - <p>It is a moderately fast detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-10 02:54:06
|
Revision: 436 Author: dbrosius Date: 2006-04-09 19:53:59 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=436&view=rev Log Message: ----------- new timings Modified Paths: -------------- trunk/fb-contrib/DetectorTimings.xlr Modified: trunk/fb-contrib/DetectorTimings.xlr =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 23:17:57
|
Revision: 435 Author: dbrosius Date: 2006-04-09 16:17:52 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=435&view=rev Log Message: ----------- prescreen for PUTFIELD and GETFIELD Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-09 23:13:10 UTC (rev 434) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-09 23:17:52 UTC (rev 435) @@ -27,6 +27,7 @@ import java.util.Map; import java.util.Set; +import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Field; import org.apache.bcel.classfile.JavaClass; @@ -37,6 +38,8 @@ import org.apache.bcel.generic.Instruction; import org.apache.bcel.generic.InstructionHandle; +import com.mebigfatguy.fbcontrib.utils.VersionTransition; + import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -143,6 +146,17 @@ } /** + * looks for methods that contain a GETFIELD or PUTFIELD opcodes + * + * @param method the context object of the current method + * @return if the class uses synchronization + */ + public boolean prescreen(Method method) { + BitSet bytecodeSet = VersionTransition.getBytecodeSet(getClassContext(), method); + return (bytecodeSet != null) && (bytecodeSet.get(Constants.PUTFIELD) || bytecodeSet.get(Constants.GETFIELD)); + } + + /** * implements the visitor to pass through constructors and static initializers to the * byte code scanning code. These methods are not reported, but are used to build * SourceLineAnnotations for fields, if accessed. @@ -151,12 +165,14 @@ */ @Override public void visitCode(Code obj) { - String methodName = getMethodName(); - if ("<clinit".equals(methodName) || "<init>".equals(methodName)) - super.visitCode(obj); + Method m = getMethod(); + if (prescreen(m)) { + String methodName = m.getName(); + if ("<clinit".equals(methodName) || "<init>".equals(methodName)) + super.visitCode(obj); + } } - /** * implements the visitor to add SourceLineAnnotations for fields in constructors and static * initializers. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 23:13:14
|
Revision: 434 Author: dbrosius Date: 2006-04-09 16:13:10 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=434&view=rev Log Message: ----------- allow writes to attributes backing fields in the constructor Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 22:58:33 UTC (rev 433) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 23:13:10 UTC (rev 434) @@ -145,8 +145,10 @@ @Override public void visitCode(Code obj) { Method m = getMethod(); - String attName = m.getName() + ":" + m.getSignature(); - super.visitCode(obj); + if (!"<init>".equals(m.getName())) { + String attName = m.getName() + ":" + m.getSignature(); + super.visitCode(obj); + } } @Override @@ -160,6 +162,7 @@ } String fieldName = getNameConstantOperand(); String fieldSig = getSigConstantOperand(); + FieldAnnotation fa = new FieldAnnotation(getClassName(), fieldName, fieldSig, false); fa.setSourceLines(SourceLineAnnotation.fromVisitedInstruction(this)); fieldAnnotations.put(fieldName, fa); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 22:58:38
|
Revision: 433 Author: dbrosius Date: 2006-04-09 15:58:33 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=433&view=rev Log Message: ----------- fix the npe guard, right Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 22:54:58 UTC (rev 432) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 22:58:33 UTC (rev 433) @@ -176,7 +176,7 @@ String attType = entry.getValue(); Set<String> fields = methodWrites.get(methodInfo); - if ((fields != null) && fields.size() != 1) + if ((fields == null) || (fields.size() != 1)) continue; String fieldInfo = fields.iterator().next(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 22:55:07
|
Revision: 432 Author: dbrosius Date: 2006-04-09 15:54:58 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=432&view=rev Log Message: ----------- guard against npe's Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 21:44:03 UTC (rev 431) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 22:54:58 UTC (rev 432) @@ -176,7 +176,7 @@ String attType = entry.getValue(); Set<String> fields = methodWrites.get(methodInfo); - if (fields.size() != 1) + if ((fields != null) && fields.size() != 1) continue; String fieldInfo = fields.iterator().next(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 21:44:16
|
Revision: 431 Author: dbrosius Date: 2006-04-09 14:44:03 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=431&view=rev Log Message: ----------- NRTL is starting to hobble along Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-04-09 21:02:41 UTC (rev 430) +++ trunk/fb-contrib/etc/findbugs.xml 2006-04-09 21:44:03 UTC (rev 431) @@ -181,8 +181,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NonRecycleableTaglibs" speed="moderate" - reports="NRTL_NON_RECYCLEABLE_TAG_LIBS" - hidden="true" /> + reports="NRTL_NON_RECYCLEABLE_TAG_LIBS" /> <!-- BugPattern --> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 21:02:41 UTC (rev 430) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 21:44:03 UTC (rev 431) @@ -10,8 +10,11 @@ import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.Type; +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.SourceLineAnnotation; import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; @@ -43,9 +46,15 @@ } private BugReporter bugReporter; + /** + * methodname:methodsig -> type of setter methods + */ private Map<String, String> attributes; - private boolean isAttribute; - private boolean sawSet; + /** + * methodname:methodsig -> (fieldname:fieldtype)s + */ + private Map<String, Set<String>> methodWrites; + private Map<String, FieldAnnotation> fieldAnnotations; /** * constructs a NRTL detector given the reporter to report bugs on. @@ -80,7 +89,10 @@ for (JavaClass superCls : superClasses) { if (tagClasses.contains(superCls.getClassName())) { attributes = getAttributes(cls); + if (attributes.size() > 0) { + methodWrites = new HashMap<String, Set<String>>(); + fieldAnnotations = new HashMap<String, FieldAnnotation>(); super.visitClassContext(classContext); reportBugs(); } @@ -93,6 +105,8 @@ } finally { attributes = null; + methodWrites = null; + fieldAnnotations = null; } } @@ -114,12 +128,8 @@ String parmSig = args[0].getSignature(); if (validAttrTypes.contains(parmSig)) { Code code = m.getCode(); - if ((code != null) && code.getCode().length < MAX_ATTRIBUTE_CODE_LENGTH) { - attributes.put(name.substring("set".length()), parmSig); - isAttribute = true; - sawSet = false; - super.visitMethod(m); - } + if ((code != null) && code.getCode().length < MAX_ATTRIBUTE_CODE_LENGTH) + attributes.put(name + ":" + sig, parmSig); } } } @@ -134,28 +144,59 @@ */ @Override public void visitCode(Code obj) { + Method m = getMethod(); + String attName = m.getName() + ":" + m.getSignature(); super.visitCode(obj); } @Override public void sawOpcode(int seen) { - if (isAttribute) { - sawAttributeOpcode(seen); - } - } - - private void sawAttributeOpcode(int seen) { if (seen == PUTFIELD) { - String sig = getSigConstantOperand(); - - + String methodInfo = getMethodName() + ":" + getMethodSig(); + Set<String> fields = methodWrites.get(methodInfo); + if (fields == null) { + fields = new HashSet<String>(); + methodWrites.put(methodInfo, fields); + } + String fieldName = getNameConstantOperand(); + String fieldSig = getSigConstantOperand(); + FieldAnnotation fa = new FieldAnnotation(getClassName(), fieldName, fieldSig, false); + fa.setSourceLines(SourceLineAnnotation.fromVisitedInstruction(this)); + fieldAnnotations.put(fieldName, fa); + fields.add(fieldName + ":" + fieldSig); } } - + /** * generates all the bug reports for attributes that are not recycleable */ private void reportBugs() { - + for (Map.Entry<String, String> entry : attributes.entrySet()) { + String methodInfo = entry.getKey(); + String attType = entry.getValue(); + + Set<String> fields = methodWrites.get(methodInfo); + if (fields.size() != 1) + continue; + + String fieldInfo = fields.iterator().next(); + String fieldName = fieldInfo.substring(0, fieldInfo.indexOf(":")); + String fieldType = fieldInfo.substring(fieldInfo.indexOf(":")+1); + + if (!attType.equals(fieldType)) + continue; + + int cnt = 0; + for (Set<String> allFields : methodWrites.values()) { + if (allFields.contains(fieldInfo)) + cnt++; + } + + if (cnt > 1) { + bugReporter.reportBug(new BugInstance(this, "NRTL_NON_RECYCLEABLE_TAG_LIB", NORMAL_PRIORITY) + .addClass(this) + .addField(fieldAnnotations.get(fieldName))); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 21:02:45
|
Revision: 430 Author: dbrosius Date: 2006-04-09 14:02:41 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=430&view=rev Log Message: ----------- based on set not get Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 20:52:22 UTC (rev 429) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 21:02:41 UTC (rev 430) @@ -8,6 +8,7 @@ import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -26,10 +27,25 @@ tagClasses.add("javax.servlet.jsp.tagext.TagSupport"); tagClasses.add("javax.servlet.jsp.tagext.BodyTagSupport"); } + + private static final Set<String> validAttrTypes = new HashSet<String>(); + static { + validAttrTypes.add("B"); + validAttrTypes.add("C"); + validAttrTypes.add("D"); + validAttrTypes.add("F"); + validAttrTypes.add("I"); + validAttrTypes.add("J"); + validAttrTypes.add("S"); + validAttrTypes.add("Z"); + validAttrTypes.add("Ljava/lang/String;"); + validAttrTypes.add("Ljava/util/Date;"); + } + private BugReporter bugReporter; private Map<String, String> attributes; private boolean isAttribute; - private boolean sawPut; + private boolean sawSet; /** * constructs a NRTL detector given the reporter to report bugs on. @@ -90,16 +106,18 @@ Method[] methods = cls.getMethods(); for (Method m : methods) { String name = m.getName(); - if (name.startsWith("get") && m.isPublic() && !m.isStatic()) { + if (name.startsWith("set") && m.isPublic() && !m.isStatic()) { String sig = m.getSignature(); - if (sig.startsWith("()")) { - String retSig = sig.substring(sig.indexOf(")")+1); - if ((retSig.charAt(0) != 'L') && ("Ljava/lang/String;".equals(retSig))) { + Type ret = Type.getReturnType(sig); + Type[] args = Type.getArgumentTypes(sig); + if (ret.equals(Type.VOID) && (args.length == 1)) { + String parmSig = args[0].getSignature(); + if (validAttrTypes.contains(parmSig)) { Code code = m.getCode(); - if ((code != null) && code.getCode().length > MAX_ATTRIBUTE_CODE_LENGTH) { - attributes.put(name.substring("get".length()), retSig); + if ((code != null) && code.getCode().length < MAX_ATTRIBUTE_CODE_LENGTH) { + attributes.put(name.substring("set".length()), parmSig); isAttribute = true; - sawPut = false; + sawSet = false; super.visitMethod(m); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 20:52:30
|
Revision: 429 Author: dbrosius Date: 2006-04-09 13:52:22 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=429&view=rev Log Message: ----------- add jsp-api.jar Modified Paths: -------------- trunk/fb-contrib/samples/samples.fb Modified: trunk/fb-contrib/samples/samples.fb =================================================================== --- trunk/fb-contrib/samples/samples.fb 2006-04-09 20:18:34 UTC (rev 428) +++ trunk/fb-contrib/samples/samples.fb 2006-04-09 20:52:22 UTC (rev 429) @@ -3,5 +3,6 @@ [Source dirs] . [Aux classpath entries] +.\lib\jsp-api.jar [Options] relative_paths=true This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 20:18:45
|
Revision: 428 Author: dbrosius Date: 2006-04-09 13:18:34 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=428&view=rev Log Message: ----------- start samples Added Paths: ----------- trunk/fb-contrib/samples/NRTL_Sample.java Added: trunk/fb-contrib/samples/NRTL_Sample.java =================================================================== --- trunk/fb-contrib/samples/NRTL_Sample.java (rev 0) +++ trunk/fb-contrib/samples/NRTL_Sample.java 2006-04-09 20:18:34 UTC (rev 428) @@ -0,0 +1,26 @@ +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; + + public void setSample(String s) { + sample = s; + } + + public int doStartTag() throws JspException { + try { + sample += Math.random(); + pageContext.getOut().print(sample); + } catch (Exception ex) { + throw new JspTagException("NRTL_Sample: " + ex.getMessage()); + } + return SKIP_BODY; + } + + public int doEndTag() { + return EVAL_PAGE; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 20:15:17
|
Revision: 427 Author: dbrosius Date: 2006-04-09 13:15:07 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=427&view=rev Log Message: ----------- add additional samples classpath (lib dir) Modified Paths: -------------- trunk/fb-contrib/.classpath trunk/fb-contrib/build.xml Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2006-04-09 20:11:12 UTC (rev 426) +++ trunk/fb-contrib/.classpath 2006-04-09 20:15:07 UTC (rev 427) @@ -5,5 +5,6 @@ <classpathentry kind="src" path="samples"/> <classpathentry kind="lib" path="O:/fb-contrib/fb-contrib/lib/findbugs.jar"/> <classpathentry kind="lib" path="O:/fb-contrib/fb-contrib/lib/bcel.jar"/> + <classpathentry kind="lib" path="O:/fb-contrib/fb-contrib/samples/lib/jsp-api.jar"/> <classpathentry kind="output" path="classes"/> </classpath> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2006-04-09 20:11:12 UTC (rev 426) +++ trunk/fb-contrib/build.xml 2006-04-09 20:15:07 UTC (rev 427) @@ -12,6 +12,7 @@ <property name="lib.dir" value="${basedir}/lib"/> <property name="etc.dir" value="${basedir}/etc"/> <property name="samples.dir" value="${basedir}/samples"/> + <property name="sampleslib.dir" value="${samples.dir}/lib"/> <property name="javadoc.dir" value="${basedir}/javadoc"/> <property name="javac.source" value="1.5"/> <property name="javac.target" value="jsr14"/> @@ -39,6 +40,9 @@ <pathelement location="${lib.dir}/findbugs.jar"/> <pathelement location="${lib.dir}/bcel.jar"/> </path> + <path id="fb-contrib.samples.classpath"> + <pathelement location="${sampleslib.dir}/jsp-api.jar"/> + </path> <mkdir dir="${classes.dir}/com"/> <mkdir dir="${classes.dir}/com/mebigfatguy"/> <mkdir dir="${classes.dir}/com/mebigfatguy/fbcontrib"/> @@ -73,6 +77,7 @@ deprecation="${javac.deprecation}" debug="${javac.debug}"> <classpath refid="fb-contrib.classpath"/> + <classpath refid="fb-contrib.samples.classpath"/> </javac> </target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 20:11:21
|
Revision: 426 Author: dbrosius Date: 2006-04-09 13:11:12 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=426&view=rev Log Message: ----------- Initial checkin NonRecycleableTaglibs -- not even close to working. :) Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-04-09 20:09:29 UTC (rev 425) +++ trunk/fb-contrib/etc/findbugs.xml 2006-04-09 20:11:12 UTC (rev 426) @@ -179,6 +179,11 @@ speed="fast" reports="NOS_NON_OWNED_SYNCHRONIZATION" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.NonRecycleableTaglibs" + speed="moderate" + reports="NRTL_NON_RECYCLEABLE_TAG_LIBS" + hidden="true" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -215,11 +220,12 @@ <BugPattern abbrev="AWCBR" type="AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE" category="STYLE" /> <BugPattern abbrev="SG" type="SG_SLUGGISH_GUI" category="PERFORMANCE" /> <BugPattern abbrev="NIR" type="NIR_NEEDLESS_INSTANCE_RETRIEVAL" category="PERFORMANCE" /> - <BugPattern abbrev="DDC" type="DDC_DOUBLE_DATE_COMPARISON" category="PERFORMANCE" experimental="true" /> - <BugPattern abbrev="SWCO" type="SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="JVR" type="JVR_JDBC_VENDOR_RELIANCE" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="PMB" type="PMB_POSSIBLE_MEMORY_BLOAT" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="LSYC" type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="DDC" type="DDC_DOUBLE_DATE_COMPARISON" category="PERFORMANCE" /> + <BugPattern abbrev="SWCO" type="SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT" category="CORRECTNESS" /> + <BugPattern abbrev="JVR" type="JVR_JDBC_VENDOR_RELIANCE" category="CORRECTNESS" /> + <BugPattern abbrev="PMB" type="PMB_POSSIBLE_MEMORY_BLOAT" category="CORRECTNESS" /> + <BugPattern abbrev="LSYC" type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" category="CORRECTNESS" /> <BugPattern abbrev="FCBL" type="FCBL_FIELD_COULD_BE_LOCAL" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="NOS" type="NOS_NON_OWNED_SYNCHRONIZATION" category="STYLE" experimental="true" /> + <BugPattern abbrev="NRTL" type="NRTL_NON_RECYCLEABLE_TAG_LIB" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-04-09 20:09:29 UTC (rev 425) +++ trunk/fb-contrib/etc/messages.xml 2006-04-09 20:11:12 UTC (rev 426) @@ -517,6 +517,16 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.NonRecycleableTaglibs"> + <Details> + <![CDATA[ + <p>looks for tag libraries that are not recycleable because backing members + of taglib attributes are set in areas besides the setter method for the attribute.</p> + <p>It is a moderately fast detector</p> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -1057,6 +1067,21 @@ ]]> </Details> </BugPattern> + + <BugPattern type="NRTL_NON_RECYCLEABLE_TAG_LIB"> + <ShortDescription>Tag library is not recycleable</ShortDescription> + <LongDescription>Tag library {0} is not recycleable</LongDescription> + <Details> + <![CDATA[ + <p>This Tag library class implements an attribute who's associated backing store field + is modified at another point in the tag library. In order for a taglibrary to be + recycleable, only the container is allowed to change this attribute, through the use + of the setXXX method of the taglib. By modifying the value programmatically, the + container will not initialize the attribute correctly on reuse.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -1100,4 +1125,5 @@ <BugCode abbrev="LSYC">Local Synchronized Collection</BugCode> <BugCode abbrev="FCBL">Field Could Be Local</BugCode> <BugCode abbrev="NOS">Non Owned Synchronization</BugCode> + <BugCode abbrev="NRTL">Non Recycleable Taglib</BugCode> </MessageCollection> \ No newline at end of file Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 20:11:12 UTC (rev 426) @@ -0,0 +1,143 @@ +package com.mebigfatguy.fbcontrib.detect; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; + +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.StatelessDetector; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * looks for tag libraries that are not recycleable because backing members of taglib attributes are + * set in areas besides the setter method for the attribute. + */ +public class NonRecycleableTaglibs extends BytecodeScanningDetector implements StatelessDetector { + private static final int MAX_ATTRIBUTE_CODE_LENGTH = 60; + + private static final Set<String> tagClasses = new HashSet<String>(); + static { + tagClasses.add("javax.servlet.jsp.tagext.TagSupport"); + tagClasses.add("javax.servlet.jsp.tagext.BodyTagSupport"); + } + private BugReporter bugReporter; + private Map<String, String> attributes; + private boolean isAttribute; + private boolean sawPut; + + /** + * constructs a NRTL detector given the reporter to report bugs on. + + * @param bugReporter the sync of bug reports + */ + public NonRecycleableTaglibs(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * clone this detector so that it can be a StatelessDetector. + * + * @return a clone of this object + * @throws CloneNotSupportedException never + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * implements the visitor to look for classes that extend the TagSupport or BodyTagSupport class + * + * @param classContext the context object for the currently parsed class + */ + @Override + public void visitClassContext(ClassContext classContext) { + try { + JavaClass cls = classContext.getJavaClass(); + JavaClass[] superClasses = cls.getSuperClasses(); + for (JavaClass superCls : superClasses) { + if (tagClasses.contains(superCls.getClassName())) { + attributes = getAttributes(cls); + if (attributes.size() > 0) { + super.visitClassContext(classContext); + reportBugs(); + } + break; + } + } + + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + } + finally { + attributes = null; + } + } + + /** + * collect all possible attributes given the name of methods available. + * + * @return the map of possible attributes/types + */ + private Map<String, String> getAttributes(JavaClass cls) { + Map<String, String> attributes = new HashMap<String, String>(); + Method[] methods = cls.getMethods(); + for (Method m : methods) { + String name = m.getName(); + if (name.startsWith("get") && m.isPublic() && !m.isStatic()) { + String sig = m.getSignature(); + if (sig.startsWith("()")) { + String retSig = sig.substring(sig.indexOf(")")+1); + if ((retSig.charAt(0) != 'L') && ("Ljava/lang/String;".equals(retSig))) { + Code code = m.getCode(); + if ((code != null) && code.getCode().length > MAX_ATTRIBUTE_CODE_LENGTH) { + attributes.put(name.substring("get".length()), retSig); + isAttribute = true; + sawPut = false; + super.visitMethod(m); + } + } + } + } + } + return attributes; + } + + /** + * implements the visitor to + * + * @param obj the context object for the currently parsed code object + */ + @Override + public void visitCode(Code obj) { + super.visitCode(obj); + } + + @Override + public void sawOpcode(int seen) { + if (isAttribute) { + sawAttributeOpcode(seen); + } + } + + private void sawAttributeOpcode(int seen) { + if (seen == PUTFIELD) { + String sig = getSigConstantOperand(); + + + } + } + + /** + * generates all the bug reports for attributes that are not recycleable + */ + private void reportBugs() { + + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 20:09:36
|
Revision: 425 Author: dbrosius Date: 2006-04-09 13:09:29 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=425&view=rev Log Message: ----------- ad jsp-api.jar for samples to test NRTL Added Paths: ----------- trunk/fb-contrib/samples/lib/ trunk/fb-contrib/samples/lib/jsp-api.jar Added: trunk/fb-contrib/samples/lib/jsp-api.jar =================================================================== (Binary files differ) Property changes on: trunk/fb-contrib/samples/lib/jsp-api.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 17:22:11
|
Revision: 424 Author: dbrosius Date: 2006-04-09 10:22:03 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=424&view=rev Log Message: ----------- clean up my poo Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java 2006-04-09 17:21:37 UTC (rev 423) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java 2006-04-09 17:22:03 UTC (rev 424) @@ -18,9 +18,6 @@ */ package com.mebigfatguy.fbcontrib.utils; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import org.apache.bcel.Constants; import org.apache.bcel.classfile.LocalVariable; import org.apache.bcel.classfile.LocalVariableTable; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 17:21:44
|
Revision: 423 Author: dbrosius Date: 2006-04-09 10:21:37 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=423&view=rev Log Message: ----------- silly, that method isn't needed, as our stack doesn't care about width. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java 2006-04-09 17:17:07 UTC (rev 422) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java 2006-04-09 17:21:37 UTC (rev 423) @@ -34,8 +34,6 @@ */ public class RegisterUtils { - private static final String METHOD_PARM_SIG = "(\\[*(?:[^L]|L[^;]*;))"; - private static Pattern parameterPattern = Pattern.compile(METHOD_PARM_SIG); /** * private to reinforce the helper status of the class */ @@ -143,7 +141,7 @@ /** * gets the set of registers used for parameters * - * @param signature the method signature + * @param obj the context object for the method to find the parameter registers of */ public static int[] getParameterRegisters(Method obj) { Type[] argTypes = obj.getArgumentTypes(); @@ -159,24 +157,4 @@ } return regs; } - - /** - * returns the size on the stack that a method's arguments takes up - * - * @param signature the method signature - */ - public static int getParameterAreaSize(String signature) { - String[] sigParts = signature.split("\\(|\\)"); - Matcher m = parameterPattern.matcher(sigParts[1]); - int size = 0; - while (m.find()) { - String parm = m.group(); - if ("J".equals(parm) || "D".equals(parm)) - size+=2; - else - size+=1; - } - return size; - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 17:17:12
|
Revision: 422 Author: dbrosius Date: 2006-04-09 10:17:07 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=422&view=rev Log Message: ----------- add getParameterAreaSize because just knowing the number of parameters isn't enough Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java 2006-04-09 03:29:38 UTC (rev 421) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java 2006-04-09 17:17:07 UTC (rev 422) @@ -18,6 +18,9 @@ */ package com.mebigfatguy.fbcontrib.utils; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.apache.bcel.Constants; import org.apache.bcel.classfile.LocalVariable; import org.apache.bcel.classfile.LocalVariableTable; @@ -31,6 +34,8 @@ */ public class RegisterUtils { + private static final String METHOD_PARM_SIG = "(\\[*(?:[^L]|L[^;]*;))"; + private static Pattern parameterPattern = Pattern.compile(METHOD_PARM_SIG); /** * private to reinforce the helper status of the class */ @@ -138,10 +143,10 @@ /** * gets the set of registers used for parameters * - * @param obj the context object for the method to get the parameters of + * @param signature the method signature */ public static int[] getParameterRegisters(Method obj) { - Type[] argTypes = obj.getArgumentTypes(); + Type[] argTypes = obj.getArgumentTypes(); int[] regs = new int[argTypes.length]; int curReg = obj.isStatic() ? 0 : 1; @@ -154,4 +159,24 @@ } return regs; } + + /** + * returns the size on the stack that a method's arguments takes up + * + * @param signature the method signature + */ + public static int getParameterAreaSize(String signature) { + String[] sigParts = signature.split("\\(|\\)"); + Matcher m = parameterPattern.matcher(sigParts[1]); + int size = 0; + while (m.find()) { + String parm = m.group(); + if ("J".equals(parm) || "D".equals(parm)) + size+=2; + else + size+=1; + } + return size; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 03:36:50
|
Revision: 421 Author: dbrosius Date: 2006-04-08 20:29:38 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=421&view=rev Log Message: ----------- no autoboxing Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-09 03:22:17 UTC (rev 420) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-09 03:29:38 UTC (rev 421) @@ -26,7 +26,7 @@ * the current class and synchronization on 'this' should be avoided as well. */ public class NonOwnedSynchronization extends BytecodeScanningDetector implements StatelessDetector { - private static final Integer OWNED = Integer.MAX_VALUE; + private static final Integer OWNED = new Integer(Integer.MAX_VALUE); private static final Integer LOW = new Integer(LOW_PRIORITY); private static final Integer NORMAL = new Integer(NORMAL_PRIORITY); private BugReporter bugReporter; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 03:30:57
|
Revision: 420 Author: dbrosius Date: 2006-04-08 20:22:17 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=420&view=rev Log Message: ----------- simplify Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java 2006-04-08 23:18:36 UTC (rev 419) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java 2006-04-09 03:22:17 UTC (rev 420) @@ -147,8 +147,6 @@ && !clsName.startsWith("javax/sql/")) return false; - if (clsName.endsWith("Exception")) - return false; - return true; + return (!clsName.endsWith("Exception")); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-08 23:18:42
|
Revision: 419 Author: dbrosius Date: 2006-04-08 16:18:36 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=419&view=rev Log Message: ----------- timings for detectors running against FindBugs Added Paths: ----------- trunk/fb-contrib/DetectorTimings.xlr Added: trunk/fb-contrib/DetectorTimings.xlr =================================================================== (Binary files differ) Property changes on: trunk/fb-contrib/DetectorTimings.xlr ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-08 22:59:09
|
Revision: 418 Author: dbrosius Date: 2006-04-08 15:59:04 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=418&view=rev Log Message: ----------- the method length needs to twice the reportSize to even check it. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2006-04-08 22:37:22 UTC (rev 417) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2006-04-08 22:59:04 UTC (rev 418) @@ -99,7 +99,7 @@ //There really is no valid relationship between reportLimit and code //length, but it is good enough. If the method is small, don't bother - if (code.getCode().length < reportLimit) + if (code.getCode().length < (2*reportLimit)) return; Set<Integer> exceptionNodeTargets = new HashSet<Integer>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-08 22:37:29
|
Revision: 417 Author: dbrosius Date: 2006-04-08 15:37:22 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=417&view=rev Log Message: ----------- don't check small methods Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2006-04-08 14:24:57 UTC (rev 416) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2006-04-08 22:37:22 UTC (rev 417) @@ -22,6 +22,7 @@ import java.util.Iterator; import java.util.Set; +import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Method; import edu.umd.cs.findbugs.BugInstance; @@ -92,9 +93,15 @@ @Override public void visitMethod(final Method obj) { try { - if (obj.getCode() == null) + Code code = obj.getCode(); + if (code == null) return; + //There really is no valid relationship between reportLimit and code + //length, but it is good enough. If the method is small, don't bother + if (code.getCode().length < reportLimit) + return; + Set<Integer> exceptionNodeTargets = new HashSet<Integer>(); CFG cfg = classContext.getCFG(obj); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-08 14:25:09
|
Revision: 416 Author: dbrosius Date: 2006-04-08 07:24:57 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=416&view=rev Log Message: ----------- only check methods that actually return a value Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2006-04-08 14:19:15 UTC (rev 415) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2006-04-08 14:24:57 UTC (rev 416) @@ -21,7 +21,9 @@ import java.util.HashSet; import java.util.Set; +import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -82,12 +84,29 @@ return super.clone(); } + /** + * implements the visitor to make sure method returns a value, and then clears the targets + * + * @param obj the context object of the currently parsed code block + */ @Override - public void visitMethod(Method obj) { - state = SEEN_NOTHING; - branchTargets.clear(); + public void visitCode(Code obj) { + Method m = getMethod(); + String sig = m.getSignature(); + Type t = Type.getReturnType(sig); + if (!t.equals(Type.VOID)) { + state = SEEN_NOTHING; + branchTargets.clear(); + super.visitCode(obj); + } } + /** + * implements the visitor to look for store of registers immediately before returns + * of that register + * + * @param seen the opcode of the currently parsed instruction + */ @Override public void sawOpcode(int seen) { int loadReg; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |