[Fb-contrib-commit] SF.net SVN: fb-contrib: [415] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/det
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-04-08 14:19:23
|
Revision: 415 Author: dbrosius Date: 2006-04-08 07:19:15 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=415&view=rev Log Message: ----------- prescreen for INVOKESTATIC opcodes Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java 2006-04-08 14:18:47 UTC (rev 414) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java 2006-04-08 14:19:15 UTC (rev 415) @@ -19,14 +19,19 @@ package com.mebigfatguy.fbcontrib.detect; import java.util.ArrayList; +import java.util.BitSet; import java.util.Iterator; import java.util.List; +import org.apache.bcel.Constants; import org.apache.bcel.Repository; +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 com.mebigfatguy.fbcontrib.utils.VersionTransition; + import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -61,15 +66,29 @@ } /** + * looks for methods that contain a INVOKESTATIC 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.INVOKESTATIC)); + } + + /** * implement the visitor to reset the stack * * @param obj the context object of the currently parsed method */ @Override - public void visitMethod(Method obj) { - stack.resetForMethodEntry(this); - popStack.clear(); - super.visitMethod(obj); + public void visitCode(Code obj) { + Method m = getMethod(); + if (prescreen(m)) { + stack.resetForMethodEntry(this); + popStack.clear(); + super.visitCode(obj); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |