[Fb-contrib-commit] fb-contrib/src/com/mebigfatguy/fbcontrib/detect BloatedSynchronizedBlock.java,1.
Brought to you by:
dbrosius
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17673/src/com/mebigfatguy/fbcontrib/detect Modified Files: BloatedSynchronizedBlock.java FinalParameters.java JDBCVendorReliance.java UnrelatedCollectionContents.java Log Message: refactor to use RegisterUtils Index: UnrelatedCollectionContents.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- UnrelatedCollectionContents.java 12 Mar 2006 06:27:17 -0000 1.15 +++ UnrelatedCollectionContents.java 13 Mar 2006 06:13:42 -0000 1.16 @@ -26,8 +26,8 @@ import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.LocalVariable; -import org.apache.bcel.classfile.LocalVariableTable; + +import com.mebigfatguy.fbcontrib.utils.RegisterUtils; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -163,7 +163,7 @@ commonSupers = new HashSet<String>(); localCollections.put(new Integer(reg), commonSupers); addNewItem(commonSupers, addItm); - Integer scopeEnd = getRegisterScopeEnd(reg); + Integer scopeEnd = RegisterUtils.getLocalVariableEndRange(getMethod().getLocalVariableTable(), reg, getNextPC()); if (scopeEnd != null) { Set<Integer> regs = localScopeEnds.get(scopeEnd); if (regs == null) { @@ -261,15 +261,4 @@ it.remove(); } } - - private Integer getRegisterScopeEnd(final int reg) { - LocalVariableTable lvt = getMethod().getLocalVariableTable(); - if (lvt == null) - return null; - LocalVariable lv = lvt.getLocalVariable(reg, getPC()); - if (lv == null) - return null; - - return new Integer(lv.getStartPC() + lv.getLength()); - } } Index: JDBCVendorReliance.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- JDBCVendorReliance.java 13 Mar 2006 06:02:11 -0000 1.7 +++ JDBCVendorReliance.java 13 Mar 2006 06:13:42 -0000 1.8 @@ -4,8 +4,6 @@ import java.util.Iterator; import java.util.Map; -import org.apache.bcel.classfile.LocalVariable; -import org.apache.bcel.classfile.LocalVariableTable; import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.Type; Index: BloatedSynchronizedBlock.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- BloatedSynchronizedBlock.java 12 Mar 2006 06:27:17 -0000 1.18 +++ BloatedSynchronizedBlock.java 13 Mar 2006 06:13:42 -0000 1.19 @@ -26,6 +26,8 @@ import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.Type; +import com.mebigfatguy.fbcontrib.utils.RegisterUtils; + import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -100,7 +102,7 @@ stack.mergeJumps(this); if (unsafeCallOccurred && ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3)))) { - int storeReg = astoreReg(seen); + int storeReg = RegisterUtils.getAStoreReg(this, seen); if (storeReg >= 0) unsafeAliases.add(new Integer(storeReg)); } @@ -150,7 +152,7 @@ boolean unsafe = unsafeCallOccurred; unsafe |= ((seen == PUTFIELD) || (seen == GETFIELD) || (seen == GETSTATIC) || (seen == PUTSTATIC)); unsafe |= (!isStatic) && ((seen == ALOAD_0) || (seen == ASTORE_0)); - int aloadReg = aloadReg(seen); + int aloadReg = RegisterUtils.getALoadReg(this, seen); unsafe |= (aloadReg >= 0) && unsafeAliases.contains(new Integer(aloadReg)); if (unsafe) { //If a branch exists in the safe code, make sure the entire branch @@ -180,34 +182,4 @@ stack.sawOpcode(this, seen); } } - - /** - * return the register number used in this ALOAD method, if it is an aload instruction - * - * @param seen the currently visited opcode - * - * @return the register used if it's an aload instruction, or -1 otherwise - */ - public int aloadReg(int seen) { - if (seen == ALOAD) - return getRegisterOperand(); - if ((seen >= ALOAD_0) && (seen <= ALOAD_3)) - return seen - ALOAD_0; - return -1; - } - - /** - * return the register number used in this ASTORE method, if it is an astore instruction - * - * @param seen the currently visited opcode - * - * @return the register used if it's an astore instruction, or -1 otherwise - */ - public int astoreReg(int seen) { - if (seen == ASTORE) - return getRegisterOperand(); - if ((seen >= ASTORE_0) && (seen <= ASTORE_3)) - return seen - ASTORE_0; - return -1; - } } Index: FinalParameters.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- FinalParameters.java 6 Feb 2006 01:36:23 -0000 1.12 +++ FinalParameters.java 13 Mar 2006 06:13:42 -0000 1.13 @@ -33,6 +33,8 @@ import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.Type; +import com.mebigfatguy.fbcontrib.utils.RegisterUtils; + import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -256,11 +258,7 @@ * @return the register number being stored */ private int getAStoreParameter(final int seen) { - int reg; - if (seen == ASTORE) - reg = getRegisterOperand(); - else - reg = seen - ASTORE_0; + int reg = RegisterUtils.getAStoreReg(this, seen); if (!isStatic) reg--; |