[Fb-contrib-commit] SF.net SVN: fb-contrib:[1707] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/d
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2011-12-14 06:07:13
|
Revision: 1707
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1707&view=rev
Author: dbrosius
Date: 2011-12-14 06:07:04 +0000 (Wed, 14 Dec 2011)
Log Message:
-----------
fix bug in Findbugs where user values are not maintained on the stack across ternary statements
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ReflectionOnObjectMethods.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SideEffectConstructor.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousCloneAlgorithm.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousClusteredSessionSupport.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -28,6 +28,7 @@
import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -276,7 +277,9 @@
break;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (userValue != null) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -32,6 +32,7 @@
import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -42,18 +43,18 @@
/**
* looks for variable assignments at a scope larger than its use. In this case,
- * the assignment can be pushed down into the smaller scope to reduce the performance
- * impact of that assignment.
+ * the assignment can be pushed down into the smaller scope to reduce the
+ * performance impact of that assignment.
*/
-public class BloatedAssignmentScope extends BytecodeScanningDetector
-{
+public class BloatedAssignmentScope extends BytecodeScanningDetector {
private static final Set<String> dangerousAssignmentClassSources = new HashSet<String>();
private static final Set<String> dangerousAssignmentMethodSources = new HashSet<String>();
static {
dangerousAssignmentClassSources.add("java/io/InputStream");
dangerousAssignmentClassSources.add("java/io/ObjectInput");
- dangerousAssignmentMethodSources.add("java/lang/System.currentTimeMillis()J");
+ dangerousAssignmentMethodSources
+ .add("java/lang/System.currentTimeMillis()J");
}
BugReporter bugReporter;
@@ -69,17 +70,20 @@
/**
* constructs a BAS detector given the reporter to report bugs on
-
- * @param bugReporter the sync of bug reports
+ *
+ * @param bugReporter
+ * the sync of bug reports
*/
public BloatedAssignmentScope(BugReporter bugReporter) {
this.bugReporter = bugReporter;
}
/**
- * implements the visitor to create and the clear the register to location map
- *
- * @param classContext the context object of the currently parsed class
+ * implements the visitor to create and the clear the register to location
+ * map
+ *
+ * @param classContext
+ * the context object of the currently parsed class
*/
@Override
public void visitClassContext(ClassContext classContext) {
@@ -101,8 +105,9 @@
/**
* implements the visitor to reset the register to location map
- *
- * @param obj the context object of the currently parsed code block
+ *
+ * @param obj
+ * the context object of the currently parsed code block
*/
@Override
public void visitCode(Code obj) {
@@ -110,8 +115,7 @@
ignoreRegs.clear();
Method method = getMethod();
- if (!method.isStatic())
- {
+ if (!method.isStatic()) {
ignoreRegs.add(Integer.valueOf(0));
}
@@ -136,8 +140,7 @@
sawNull = false;
super.visitCode(obj);
- if (!dontReport)
- {
+ if (!dontReport) {
rootScopeBlock.findBugs(new HashSet<Integer>());
}
@@ -147,20 +150,18 @@
}
/**
- * implements the visitor to look for variables assigned below the scope
- * in which they are used.
- *
- * @param seen the opcode of the currently parsed instruction
+ * implements the visitor to look for variables assigned below the scope in
+ * which they are used.
+ *
+ * @param seen
+ * the opcode of the currently parsed instruction
*/
@Override
public void sawOpcode(int seen) {
UserObject uo = null;
try {
- if ((seen == ASTORE)
- || (seen == ISTORE)
- || (seen == LSTORE)
- || (seen == FSTORE)
- || (seen == DSTORE)
+ if ((seen == ASTORE) || (seen == ISTORE) || (seen == LSTORE)
+ || (seen == FSTORE) || (seen == DSTORE)
|| ((seen >= ASTORE_0) && (seen <= ASTORE_3))
|| ((seen >= ISTORE_0) && (seen <= ISTORE_3))
|| ((seen >= LSTORE_0) && (seen <= LSTORE_3))
@@ -170,16 +171,11 @@
Integer iReg = Integer.valueOf(reg);
int pc = getPC();
- if (catchHandlers.contains(Integer.valueOf(pc)))
- {
+ if (catchHandlers.contains(Integer.valueOf(pc))) {
ignoreRegs.add(iReg);
- }
- else if (monitorSyncPCs.size() > 0)
- {
+ } else if (monitorSyncPCs.size() > 0) {
ignoreRegs.add(iReg);
- }
- else if (sawNull)
- {
+ } else if (sawNull) {
ignoreRegs.add(iReg);
}
@@ -188,21 +184,19 @@
if (sb != null) {
UserObject assoc = null;
if (stack.getStackDepth() > 0) {
- assoc = (UserObject)stack.getStackItem(0).getUserValue();
+ assoc = (UserObject) stack.getStackItem(0)
+ .getUserValue();
}
if ((assoc != null) && assoc.isRisky) {
ignoreRegs.add(iReg);
} else {
sb.addStore(reg, pc, assoc);
- if (sawDup)
- {
+ if (sawDup) {
sb.addLoad(reg, pc);
}
}
- }
- else
- {
+ } else {
ignoreRegs.add(iReg);
}
}
@@ -211,26 +205,18 @@
Integer iReg = Integer.valueOf(reg);
if (!ignoreRegs.contains(iReg)) {
ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC());
- if (sb != null)
- {
+ if (sb != null) {
sb.addLoad(reg, getPC());
- }
- else
- {
+ } else {
ignoreRegs.add(iReg);
}
}
int pc = getPC();
- if (catchHandlers.contains(Integer.valueOf(pc)))
- {
+ if (catchHandlers.contains(Integer.valueOf(pc))) {
ignoreRegs.add(iReg);
- }
- else if (monitorSyncPCs.size() > 0)
- {
+ } else if (monitorSyncPCs.size() > 0) {
ignoreRegs.add(iReg);
- }
- else if (sawNull)
- {
+ } else if (sawNull) {
ignoreRegs.add(iReg);
}
@@ -238,21 +224,15 @@
ScopeBlock sb = findScopeBlock(rootScopeBlock, pc);
if (sb != null) {
sb.addStore(reg, pc, null);
- if (sawDup)
- {
+ if (sawDup) {
sb.addLoad(reg, pc);
}
- }
- else
- {
+ } else {
ignoreRegs.add(iReg);
}
}
- } else if ((seen == ALOAD)
- || (seen == ILOAD)
- || (seen == LLOAD)
- || (seen == FLOAD)
- || (seen == DLOAD)
+ } else if ((seen == ALOAD) || (seen == ILOAD) || (seen == LLOAD)
+ || (seen == FLOAD) || (seen == DLOAD)
|| ((seen >= ALOAD_0) && (seen <= ALOAD_3))
|| ((seen >= ILOAD_0) && (seen <= ILOAD_3))
|| ((seen >= LLOAD_0) && (seen <= LLOAD_3))
@@ -261,22 +241,21 @@
int reg = RegisterUtils.getLoadReg(this, seen);
if (!ignoreRegs.contains(Integer.valueOf(reg))) {
ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC());
- if (sb != null)
- {
+ if (sb != null) {
sb.addLoad(reg, getPC());
- }
- else
- {
+ } else {
ignoreRegs.add(Integer.valueOf(reg));
}
}
- } else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == IFNULL) || (seen == IFNONNULL) || (seen == GOTO_W)) {
+ } else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == IFNULL)
+ || (seen == IFNONNULL) || (seen == GOTO_W)) {
int target = getBranchTarget();
if (target > getPC()) {
if ((seen == GOTO) || (seen == GOTO_W)) {
Integer nextPC = Integer.valueOf(getNextPC());
if (!switchTargets.contains(nextPC)) {
- ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), getNextPC());
+ ScopeBlock sb = findScopeBlockWithTarget(
+ rootScopeBlock, getPC(), getNextPC());
if (sb == null) {
sb = new ScopeBlock(getPC(), target);
sb.setLoop();
@@ -289,13 +268,13 @@
}
}
} else {
- ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target);
+ ScopeBlock sb = findScopeBlockWithTarget(
+ rootScopeBlock, getPC(), target);
if ((sb != null) && (!sb.isLoop) && !sb.hasChildren()) {
if (sb.isGoto()) {
ScopeBlock parent = sb.getParent();
sb.pushUpLoadStores();
- if (parent != null)
- {
+ if (parent != null) {
parent.removeChild(sb);
}
sb = new ScopeBlock(getPC(), target);
@@ -312,8 +291,7 @@
}
} else {
ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC());
- if (sb != null)
- {
+ if (sb != null) {
ScopeBlock parentSB = sb.getParent();
while (parentSB != null) {
if (parentSB.getStart() >= target) {
@@ -330,13 +308,12 @@
int pc = getPC();
int[] offsets = getSwitchOffsets();
List<Integer> targets = new ArrayList<Integer>();
- for (int offset : offsets)
- {
+ for (int offset : offsets) {
targets.add(Integer.valueOf(offset + pc));
}
- Integer defOffset = Integer.valueOf(getDefaultSwitchOffset() + pc);
- if (!targets.contains(defOffset))
- {
+ Integer defOffset = Integer.valueOf(getDefaultSwitchOffset()
+ + pc);
+ if (!targets.contains(defOffset)) {
targets.add(defOffset);
}
Collections.sort(targets);
@@ -344,15 +321,15 @@
Integer lastTarget = targets.get(0);
for (int i = 1; i < targets.size(); i++) {
Integer nextTarget = targets.get(i);
- ScopeBlock sb = new ScopeBlock(lastTarget.intValue(), nextTarget.intValue());
+ ScopeBlock sb = new ScopeBlock(lastTarget.intValue(),
+ nextTarget.intValue());
rootScopeBlock.addChild(sb);
lastTarget = nextTarget;
}
switchTargets.addAll(targets);
} else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE)) {
if ("wasNull".equals(getNameConstantOperand())
- && "()Z".equals(getSigConstantOperand()))
- {
+ && "()Z".equals(getSigConstantOperand())) {
dontReport = true;
}
@@ -372,8 +349,7 @@
} else if (seen == MONITORENTER) {
monitorSyncPCs.add(Integer.valueOf(getPC()));
} else if (seen == MONITOREXIT) {
- if (monitorSyncPCs.size() > 0)
- {
+ if (monitorSyncPCs.size() > 0) {
monitorSyncPCs.remove(monitorSyncPCs.size() - 1);
}
}
@@ -381,7 +357,9 @@
sawDup = (seen == DUP);
sawNull = (seen == ACONST_NULL);
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (uo != null) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
@@ -392,15 +370,15 @@
}
/**
- * returns either a register number of a field reference of the object that a method is being called on,
- * or null, if it can't be determined.
- *
- * @return either an Integer for a register, or a String for the field name, or null
+ * returns either a register number of a field reference of the object that
+ * a method is being called on, or null, if it can't be determined.
+ *
+ * @return either an Integer for a register, or a String for the field name,
+ * or null
*/
private Comparable<?> getCallingObject() {
String sig = getSigConstantOperand();
- if ("V".equals(Type.getReturnType(sig).getSignature()))
- {
+ if ("V".equals(Type.getReturnType(sig).getSignature())) {
return null;
}
@@ -411,24 +389,29 @@
OpcodeStack.Item caller = stack.getStackItem(types.length);
int reg = caller.getRegisterNumber();
- if (reg >= 0)
- {
+ if (reg >= 0) {
return Integer.valueOf(reg);
}
- /* We ignore the possibility of two fields with the same name in different classes */
+ /*
+ * We ignore the possibility of two fields with the same name in
+ * different classes
+ */
XField f = caller.getXField();
- if (f != null)
- {
+ if (f != null) {
return f.getName();
}
return null;
}
+
/**
- * returns the scope block in which this register was assigned, by traversing the scope block tree
- *
- * @param sb the scope block to start searching in
- * @param pc the current program counter
+ * returns the scope block in which this register was assigned, by
+ * traversing the scope block tree
+ *
+ * @param sb
+ * the scope block to start searching in
+ * @param pc
+ * the current program counter
* @return the scope block or null if not found
*/
private ScopeBlock findScopeBlock(ScopeBlock sb, int pc) {
@@ -437,8 +420,7 @@
if (sb.children != null) {
for (ScopeBlock child : sb.children) {
ScopeBlock foundSb = findScopeBlock(child, pc);
- if (foundSb != null)
- {
+ if (foundSb != null) {
return foundSb;
}
}
@@ -449,28 +431,30 @@
}
/**
- * returns an existing scope block that has the same target as the one looked for
- *
- * @param sb the scope block to start with
- * @param target the target to look for
- *
+ * returns an existing scope block that has the same target as the one
+ * looked for
+ *
+ * @param sb
+ * the scope block to start with
+ * @param target
+ * the target to look for
+ *
* @return the scope block found or null
*/
- private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int start, int target) {
+ private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int start,
+ int target) {
ScopeBlock parentBlock = null;
if ((sb.startLocation < start) && (sb.finishLocation >= start)) {
- if ((sb.finishLocation <= target) || (sb.isGoto() && !sb.isLoop()))
- {
+ if ((sb.finishLocation <= target) || (sb.isGoto() && !sb.isLoop())) {
parentBlock = sb;
}
}
- if (sb.children != null)
- {
+ if (sb.children != null) {
for (ScopeBlock child : sb.children) {
- ScopeBlock targetBlock = findScopeBlockWithTarget(child, start, target);
- if (targetBlock != null)
- {
+ ScopeBlock targetBlock = findScopeBlockWithTarget(child, start,
+ target);
+ if (targetBlock != null) {
return targetBlock;
}
}
@@ -479,10 +463,10 @@
return parentBlock;
}
- /** holds the description of a scope { } block, be it a for, if, while block
+ /**
+ * holds the description of a scope { } block, be it a for, if, while block
*/
- private class ScopeBlock
- {
+ private class ScopeBlock {
private ScopeBlock parent;
private int startLocation;
private int finishLocation;
@@ -493,10 +477,13 @@
private Map<UserObject, Integer> assocs;
private List<ScopeBlock> children;
- /** construts a new scope block
- *
- * @param start the beginning of the block
- * @param finish the end of the block
+ /**
+ * construts a new scope block
+ *
+ * @param start
+ * the beginning of the block
+ * @param finish
+ * the end of the block
*/
public ScopeBlock(int start, int finish) {
parent = null;
@@ -512,33 +499,37 @@
/**
* returns a string representation of the scope block
- *
+ *
* @returns a string representation
*/
@Override
public String toString() {
- return "Start=" + startLocation + " Finish=" + finishLocation + " Loop=" + isLoop + " Loads=" + loads + " Stores=" + stores;
+ return "Start=" + startLocation + " Finish=" + finishLocation
+ + " Loop=" + isLoop + " Loads=" + loads + " Stores="
+ + stores;
}
/**
* returns the scope blocks parent
- *
+ *
* @return the parent of this scope block
*/
public ScopeBlock getParent() {
return parent;
}
- /** returns the start of the block
- *
+ /**
+ * returns the start of the block
+ *
* @return the start of the block
*/
public int getStart() {
return startLocation;
}
- /** returns the end of the block
- *
+ /**
+ * returns the end of the block
+ *
* @return the end of the block
*/
public int getFinish() {
@@ -547,7 +538,9 @@
/**
* sets the start pc of the block
- * @param start the start pc
+ *
+ * @param start
+ * the start pc
*/
public void setStart(int start) {
startLocation = start;
@@ -555,7 +548,9 @@
/**
* sets the finish pc of the block
- * @param finish the finish pc
+ *
+ * @param finish
+ * the finish pc
*/
public void setFinish(int finish) {
finishLocation = finish;
@@ -564,6 +559,7 @@
public boolean hasChildren() {
return children != null;
}
+
/**
* sets that this block is a loop
*/
@@ -573,7 +569,7 @@
/**
* returns whether this scope block is a loop
- *
+ *
* @returns whether this block is a loop
*/
public boolean isLoop() {
@@ -589,7 +585,7 @@
/**
* returns whether this block was caused from a goto
- *
+ *
* @returns whether this block was caused by a goto
*/
public boolean isGoto() {
@@ -598,28 +594,30 @@
/**
* adds the register as a store in this scope block
- *
- * @param reg the register that was stored
- * @param pc the instruction that did the store
+ *
+ * @param reg
+ * the register that was stored
+ * @param pc
+ * the instruction that did the store
*/
public void addStore(int reg, int pc, UserObject assocObject) {
- if (stores == null)
- {
+ if (stores == null) {
stores = new HashMap<Integer, Integer>();
}
stores.put(Integer.valueOf(reg), Integer.valueOf(pc));
- if (assocs == null)
- {
+ if (assocs == null) {
assocs = new HashMap<UserObject, Integer>();
}
assocs.put(assocObject, Integer.valueOf(reg));
}
/**
- * removes stores to registers that where retrieved from method calls on assocObject
- *
- * @param assocObject the object that a method call was just performed on
+ * removes stores to registers that where retrieved from method calls on
+ * assocObject
+ *
+ * @param assocObject
+ * the object that a method call was just performed on
*/
public void removeByAssoc(Object assocObject) {
if (assocs != null) {
@@ -637,13 +635,14 @@
/**
* adds the register as a load in this scope block
- *
- * @param reg the register that was loaded
- * @param pc the instruction that did the load
+ *
+ * @param reg
+ * the register that was loaded
+ * @param pc
+ * the instruction that did the load
*/
public void addLoad(int reg, int pc) {
- if (loads == null)
- {
+ if (loads == null) {
loads = new HashMap<Integer, Integer>();
}
@@ -651,16 +650,19 @@
}
/**
- * adds a scope block to this subtree by finding the correct place in the hierarchy to store it
- *
- * @param newChild the scope block to add to the tree
+ * adds a scope block to this subtree by finding the correct place in
+ * the hierarchy to store it
+ *
+ * @param newChild
+ * the scope block to add to the tree
*/
public void addChild(ScopeBlock newChild) {
newChild.parent = this;
if (children != null) {
for (ScopeBlock child : children) {
- if ((newChild.startLocation > child.startLocation) && (newChild.finishLocation <= child.finishLocation)) {
+ if ((newChild.startLocation > child.startLocation)
+ && (newChild.finishLocation <= child.finishLocation)) {
child.addChild(newChild);
return;
}
@@ -682,37 +684,35 @@
/**
* removes a child from this node
- * @param child the child to remove
+ *
+ * @param child
+ * the child to remove
*/
public void removeChild(ScopeBlock child) {
- if (children != null)
- {
+ if (children != null) {
children.remove(child);
}
}
/**
- * report stores that occur at scopes higher than associated loads that are not involved with loops
+ * report stores that occur at scopes higher than associated loads that
+ * are not involved with loops
*/
public void findBugs(Set<Integer> parentUsedRegs) {
- if (isLoop)
- {
+ if (isLoop) {
return;
}
Set<Integer> usedRegs = new HashSet<Integer>(parentUsedRegs);
- if (stores != null)
- {
+ if (stores != null) {
usedRegs.addAll(stores.keySet());
}
- if (loads != null)
- {
+ if (loads != null) {
usedRegs.addAll(loads.keySet());
}
if (stores != null) {
- if (loads != null)
- {
+ if (loads != null) {
stores.keySet().removeAll(loads.keySet());
}
stores.keySet().removeAll(parentUsedRegs);
@@ -720,7 +720,8 @@
if (stores.size() > 0) {
if (children != null) {
- for (Map.Entry<Integer, Integer> entry : stores.entrySet()) {
+ for (Map.Entry<Integer, Integer> entry : stores
+ .entrySet()) {
int childUseCount = 0;
boolean inLoop = false;
Integer reg = entry.getKey();
@@ -734,10 +735,15 @@
}
}
if ((!inLoop) && (childUseCount == 1)) {
- bugReporter.reportBug(new BugInstance(BloatedAssignmentScope.this, "BAS_BLOATED_ASSIGNMENT_SCOPE", NORMAL_PRIORITY)
- .addClass(BloatedAssignmentScope.this)
- .addMethod(BloatedAssignmentScope.this)
- .addSourceLine(BloatedAssignmentScope.this, entry.getValue().intValue()));
+ bugReporter.reportBug(new BugInstance(
+ BloatedAssignmentScope.this,
+ "BAS_BLOATED_ASSIGNMENT_SCOPE",
+ NORMAL_PRIORITY)
+ .addClass(BloatedAssignmentScope.this)
+ .addMethod(BloatedAssignmentScope.this)
+ .addSourceLine(
+ BloatedAssignmentScope.this,
+ entry.getValue().intValue()));
}
}
}
@@ -752,26 +758,25 @@
}
/**
- * returns whether this block either loads or stores into the register in question
- *
- * @param reg the register to look for loads or stores
- *
+ * returns whether this block either loads or stores into the register
+ * in question
+ *
+ * @param reg
+ * the register to look for loads or stores
+ *
* @return whether the block uses the register
*/
public boolean usesReg(Integer reg) {
- if ((loads != null) && (loads.containsKey(reg)))
- {
+ if ((loads != null) && (loads.containsKey(reg))) {
return true;
}
- if ((stores != null) && (stores.containsKey(reg)))
- {
+ if ((stores != null) && (stores.containsKey(reg))) {
return true;
}
if (children != null) {
for (ScopeBlock child : children) {
- if (child.usesReg(reg))
- {
+ if (child.usesReg(reg)) {
return true;
}
}
@@ -786,22 +791,16 @@
public void pushUpLoadStores() {
if (parent != null) {
if (loads != null) {
- if (parent.loads != null)
- {
+ if (parent.loads != null) {
parent.loads.putAll(loads);
- }
- else
- {
+ } else {
parent.loads = loads;
}
}
if (stores != null) {
- if (parent.stores != null)
- {
+ if (parent.stores != null) {
parent.stores.putAll(stores);
- }
- else
- {
+ } else {
parent.stores = stores;
}
}
@@ -819,7 +818,8 @@
return true;
}
- String key = clsName + "." + getNameConstantOperand() + getSigConstantOperand();
+ String key = clsName + "." + getNameConstantOperand()
+ + getSigConstantOperand();
return dangerousAssignmentMethodSources.contains(key);
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -35,6 +35,7 @@
import com.mebigfatguy.fbcontrib.utils.CodeByteUtils;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -301,7 +302,9 @@
}
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if ((groupId >= 0) && (stack.getStackDepth() > 0)) {
OpcodeStack.Item itm = stack.getStackItem(0);
itm.setUserValue(Integer.valueOf(groupId));
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -29,6 +29,7 @@
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
import com.mebigfatguy.fbcontrib.utils.SignatureUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -184,7 +185,9 @@
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (methodPackage != null) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -22,6 +22,8 @@
import org.apache.bcel.classfile.Constant;
import org.apache.bcel.classfile.ConstantString;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
+
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
import edu.umd.cs.findbugs.BytecodeScanningDetector;
@@ -171,7 +173,9 @@
}
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (nestedSB != null) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -26,6 +26,7 @@
import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -143,7 +144,9 @@
tosIsJDBC = true;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (tosIsJDBC) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -29,6 +29,8 @@
import org.apache.bcel.classfile.Unknown;
import org.apache.bcel.generic.Type;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
+
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
import edu.umd.cs.findbugs.BytecodeScanningDetector;
@@ -196,7 +198,9 @@
}
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if ((userValue != null) && (stack.getStackDepth() > 0)) {
OpcodeStack.Item item = stack.getStackItem(0);
item.setUserValue(userValue);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -26,6 +26,7 @@
import org.apache.bcel.classfile.Code;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -141,7 +142,9 @@
break;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (sawNewGraphicsAt != null) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -30,6 +30,7 @@
import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -229,7 +230,9 @@
}
}
} finally {
- stack.sawOpcode(this, seen);
+ TernaryPatcher.pre(stack, seen);
+ stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (tosIsSyncColReg != null) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -31,6 +31,8 @@
import org.apache.bcel.classfile.Method;
import org.apache.bcel.generic.Type;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
+
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
import edu.umd.cs.findbugs.BytecodeScanningDetector;
@@ -260,7 +262,9 @@
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
} finally {
- stack.sawOpcode(this, seen);
+ TernaryPatcher.pre(stack, seen);
+ stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (ldcClassName != null) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -38,6 +38,7 @@
import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -291,7 +292,9 @@
lastWasExitPoint = seen >= IRETURN && seen <= RETURN || seen == GOTO || seen == GOTO_W || seen == ATHROW;
}
finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (markAsValid) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -22,6 +22,8 @@
import org.apache.bcel.classfile.Code;
import org.apache.bcel.classfile.Method;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
+
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
import edu.umd.cs.findbugs.BytecodeScanningDetector;
@@ -133,7 +135,9 @@
}
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (sawSBToString && (stack.getStackDepth() > 0)) {
OpcodeStack.Item item = stack.getStackItem(0);
item.setUserValue(Boolean.TRUE);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -29,6 +29,8 @@
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.generic.Type;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
+
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
import edu.umd.cs.findbugs.BytecodeScanningDetector;
@@ -324,7 +326,9 @@
break;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (isSyncCollection) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -28,6 +28,7 @@
import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -203,7 +204,9 @@
break;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (tosIsPriority != null) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -25,6 +25,7 @@
import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -215,7 +216,9 @@
break;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (sawAllocation) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ReflectionOnObjectMethods.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ReflectionOnObjectMethods.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ReflectionOnObjectMethods.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -28,6 +28,7 @@
import org.apache.bcel.classfile.Method;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -244,7 +245,9 @@
break;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (arraySize != null) {
if (stack.getStackDepth() >= 1) {
OpcodeStack.Item item = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -30,6 +30,7 @@
import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -291,7 +292,9 @@
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (sawTextLabel) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SideEffectConstructor.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SideEffectConstructor.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SideEffectConstructor.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -21,6 +21,8 @@
import org.apache.bcel.classfile.Code;
import org.apache.bcel.generic.Type;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
+
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
import edu.umd.cs.findbugs.BytecodeScanningDetector;
@@ -127,7 +129,9 @@
break;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (pc != 0) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -39,6 +39,7 @@
import com.mebigfatguy.fbcontrib.utils.CodeByteUtils;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -666,7 +667,9 @@
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if ((userValue != null) && (stack.getStackDepth() > 0)) {
OpcodeStack.Item item = stack.getStackItem(0);
item.setUserValue(userValue);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -25,6 +25,7 @@
import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.SignatureUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -161,7 +162,9 @@
break;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (fieldSource != null) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousCloneAlgorithm.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousCloneAlgorithm.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousCloneAlgorithm.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -27,6 +27,8 @@
import org.apache.bcel.classfile.Method;
import org.apache.bcel.generic.Type;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
+
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
import edu.umd.cs.findbugs.BytecodeScanningDetector;
@@ -167,7 +169,9 @@
break;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (srcField && stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
item.setUserValue(Boolean.TRUE);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousClusteredSessionSupport.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousClusteredSessionSupport.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousClusteredSessionSupport.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -27,6 +27,7 @@
import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -146,7 +147,9 @@
}
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (sawGetAttribute)
{
if (stack.getStackDepth() > 0) {
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -25,6 +25,7 @@
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
import com.mebigfatguy.fbcontrib.utils.SignatureUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -251,7 +252,9 @@
break;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
item.setUserValue(userValue);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -28,6 +28,7 @@
import com.mebigfatguy.fbcontrib.utils.AttributesUtils;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -180,7 +181,9 @@
break;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (sawAlloc) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -27,6 +27,8 @@
import org.apache.bcel.classfile.Method;
import org.apache.bcel.generic.Type;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
+
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
import edu.umd.cs.findbugs.BytecodeScanningDetector;
@@ -196,7 +198,9 @@
lhsReg = processBinOp(seen);
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if ((lhsReg > -1) && (stack.getStackDepth() >= 1)) {
OpcodeStack.Item item = stack.getStackItem(0);
item.setUserValue(Integer.valueOf(lhsReg));
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -27,6 +27,7 @@
import org.apache.bcel.classfile.JavaClass;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -274,7 +275,9 @@
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (sawAlias) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -28,6 +28,7 @@
import org.apache.bcel.classfile.Method;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -175,7 +176,9 @@
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (sawEnumCollectionCreation != null) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -25,6 +25,7 @@
import org.apache.bcel.classfile.JavaClass;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -215,7 +216,9 @@
break;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (state != State.SEEN_NOTHING) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -26,6 +26,7 @@
import org.apache.bcel.classfile.JavaClass;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -191,7 +192,9 @@
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (sawAlias) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -30,6 +30,8 @@
import org.apache.bcel.classfile.Method;
import org.apache.bcel.generic.Type;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
+
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
import edu.umd.cs.findbugs.BytecodeScanningDetector;
@@ -162,7 +164,9 @@
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if ((sawConstant || allConstantStrings) && (stack.getStackDepth() > 0)) {
OpcodeStack.Item item = stack.getStackItem(0);
item.setUserValue(Boolean.TRUE);
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2011-11-23 00:17:01 UTC (rev 1706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2011-12-14 06:07:04 UTC (rev 1707)
@@ -40,6 +40,7 @@
import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+import com.mebigfatguy.fbcontrib.utils.TernaryPatcher;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -328,7 +329,9 @@
break;
}
} finally {
+ TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
+ TernaryPatcher.post(stack, seen);
if (userObject != null) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|