Thread: [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. |
From: <dbr...@us...> - 2006-04-19 01:07:43
|
Revision: 495 Author: dbrosius Date: 2006-04-18 18:07:38 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=495&view=rev Log Message: ----------- Manually cleanup memory now that StatelessDetector is removed. 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-19 01:06:26 UTC (rev 494) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java 2006-04-19 01:07:38 UTC (rev 495) @@ -34,6 +34,7 @@ import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.ba.ClassContext; /** * looks for methods that make static method calls using an instance reference. @@ -42,8 +43,8 @@ */ public class StaticMethodInstanceInvocation extends BytecodeScanningDetector { private BugReporter bugReporter; - private OpcodeStack stack = new OpcodeStack(); - private List<PopInfo> popStack = new ArrayList<PopInfo>(); + private OpcodeStack stack; + private List<PopInfo> popStack; /** * constructs a SMII detector given the reporter to report bugs on @@ -52,17 +53,18 @@ public StaticMethodInstanceInvocation(BugReporter bugReporter) { this.bugReporter = bugReporter; } - - /** - * clone this detector so that it can be a StatelessDetector - * - * @return a clone of this object - */ + @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + popStack = new ArrayList<PopInfo>(); + super.visitClassContext(classContext); + } finally { + stack = null; + popStack = null; + } } - /** * looks for methods that contain a INVOKESTATIC opcodes * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |