[Fb-contrib-commit] SF.net SVN: fb-contrib: [413] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/det
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2006-04-08 14:10:37
|
Revision: 413 Author: dbrosius Date: 2006-04-08 07:10:32 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=413&view=rev Log Message: ----------- prescreen for MONITORENTER opcodes Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2006-04-08 14:10:00 UTC (rev 412) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2006-04-08 14:10:32 UTC (rev 413) @@ -18,15 +18,19 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.BitSet; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Method; 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; @@ -73,22 +77,36 @@ } /** + * looks for methods that contain a MONITORENTER 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.MONITORENTER)); + } + + /** * implement the visitor to reset the sync count, the stack, and gather some information * * @param obj the context object for the currently parsed method */ @Override - public void visitMethod(Method obj) { - if (obj.isSynchronized()) - syncPC = 0; - else - syncPC = -1; - isStatic = obj.isStatic(); - unsafeAliases.clear(); - unsafeAliases.add(new Integer(0)); - branchInfo.clear(); - unsafeCallOccurred = false; - stack.resetForMethodEntry(this); + public void visitCode(Code obj) { + Method m = getMethod(); + if (prescreen(m)) { + if (m.isSynchronized()) + syncPC = 0; + else + syncPC = -1; + isStatic = m.isStatic(); + unsafeAliases.clear(); + unsafeAliases.add(new Integer(0)); + branchInfo.clear(); + unsafeCallOccurred = false; + stack.resetForMethodEntry(this); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |