[Fb-contrib-commit] SF.net SVN: fb-contrib: [414] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/det
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2006-04-08 14:18:52
|
Revision: 414 Author: dbrosius Date: 2006-04-08 07:18:47 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=414&view=rev Log Message: ----------- prescreen for GOTO or GOTO_W opcodes Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-04-08 14:10:32 UTC (rev 413) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-04-08 14:18:47 UTC (rev 414) @@ -18,12 +18,17 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.BitSet; import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import org.apache.bcel.Constants; 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; @@ -77,24 +82,38 @@ } /** + * looks for methods that contain a GOTO or GOTO_W 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.GOTO) || bytecodeSet.get(Constants.GOTO_W)); + } + + /** * overrides the visitor to reset the opcode stack * * @param obj the code object for the currently parsed Code */ @Override public void visitCode(final Code obj) { - sawListSize = false; - - stack.resetForMethodEntry(this); - state = SEEN_NOTHING; - stage = FIND_LOOP_STAGE; - super.visitCode(obj); - - if (sawListSize) { + Method m = getMethod(); + if (prescreen(m)) { + sawListSize = false; + stack.resetForMethodEntry(this); state = SEEN_NOTHING; - stage = FIND_BUG_STAGE; + stage = FIND_LOOP_STAGE; super.visitCode(obj); + + if (sawListSize) { + stack.resetForMethodEntry(this); + state = SEEN_NOTHING; + stage = FIND_BUG_STAGE; + super.visitCode(obj); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |