[Fb-contrib-commit] fb-contrib/src/com/mebigfatguy/fbcontrib/detect BloatedSynchronizedBlock.java,1.
Brought to you by:
dbrosius
|
From: Dave B. <dbr...@us...> - 2006-01-02 04:23:30
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv350/src/com/mebigfatguy/fbcontrib/detect Modified Files: BloatedSynchronizedBlock.java Log Message: remove some now unused guff Index: BloatedSynchronizedBlock.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- BloatedSynchronizedBlock.java 2 Jan 2006 03:41:07 -0000 1.2 +++ BloatedSynchronizedBlock.java 2 Jan 2006 04:23:21 -0000 1.3 @@ -18,20 +18,17 @@ */ package com.mebigfatguy.fbcontrib.detect; -import org.apache.bcel.Constants; import org.apache.bcel.classfile.Method; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; -import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.StatelessDetector; public class BloatedSynchronizedBlock extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; private static final String BSB_MIN_SAFE_CODE_SIZE = "fb-contrib.bsb.minsize"; - private OpcodeStack stack = new OpcodeStack(); private int syncPC; private int lastPC; private boolean isStatic; @@ -67,7 +64,6 @@ syncPC = 0; else syncPC = -1; - stack.resetForMethodEntry(this); lastPC = -1; isStatic = obj.isStatic(); } @@ -79,29 +75,25 @@ * @param seen the opcode of the currently parsed instruction */ public void sawOpcode(int seen) { - try { - if (seen == MONITORENTER) { - if (syncPC < 0) - syncPC = getPC(); - } - else if (seen == MONITOREXIT) - syncPC = -1; - else if (syncPC >= 0) { - boolean unsafe = ((seen == PUTFIELD) || (seen == GETFIELD)); - unsafe |= (!isStatic) && ((seen == ALOAD_0) || (seen == ASTORE_0)); - if (unsafe) { - if ((getPC() - syncPC) > minSafeCodeLength) { - bugReporter.reportBug(new BugInstance(this, "BSB_BLOATED_SYNCHRONIZED_BLOCK", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLineRange(this, syncPC + 1, lastPC)); - } - syncPC = -1; + if (seen == MONITORENTER) { + if (syncPC < 0) + syncPC = getPC(); + } + else if (seen == MONITOREXIT) + syncPC = -1; + else if (syncPC >= 0) { + boolean unsafe = ((seen == PUTFIELD) || (seen == GETFIELD)); + unsafe |= (!isStatic) && ((seen == ALOAD_0) || (seen == ASTORE_0)); + if (unsafe) { + if ((getPC() - syncPC) > minSafeCodeLength) { + bugReporter.reportBug(new BugInstance(this, "BSB_BLOATED_SYNCHRONIZED_BLOCK", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLineRange(this, syncPC + 1, lastPC)); } + syncPC = -1; } - lastPC = getPC(); - } finally { - stack.sawOpcode(this, seen); } + lastPC = getPC(); } } |