[Fb-contrib-commit] SF.net SVN: fb-contrib:[1741] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2013-02-10 02:29:21
|
Revision: 1741
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1741&view=rev
Author: dbrosius
Date: 2013-02-10 02:29:13 +0000 (Sun, 10 Feb 2013)
Log Message:
-----------
sync from github
Modified Paths:
--------------
trunk/fb-contrib/samples/MRC_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java
Modified: trunk/fb-contrib/samples/MRC_Sample.java
===================================================================
--- trunk/fb-contrib/samples/MRC_Sample.java 2013-02-06 05:02:24 UTC (rev 1740)
+++ trunk/fb-contrib/samples/MRC_Sample.java 2013-02-10 02:29:13 UTC (rev 1741)
@@ -1,3 +1,4 @@
+import java.awt.Component;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -6,6 +7,8 @@
@SuppressWarnings("all")
public class MRC_Sample
{
+ private Component[] components;
+
private int getValue() {
return 1;
}
@@ -87,4 +90,25 @@
}
return totLength;
}
+
+ private int getFPLoopVar(List<String> c) {
+ for (int i = 0; i < c.size(); i++) {
+ if (c.get(i) == null) {
+ return i;
+ }
+ }
+
+ throw new RuntimeException();
+ }
+
+ private int fpFindComponent(Component component) {
+ int index = 0;
+ while (this.components[index] != component) {
+ index++;
+ if (index >= this.components.length) {
+ return 0;
+ }
+ }
+ return index;
+ }
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2013-02-06 05:02:24 UTC (rev 1740)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2013-02-10 02:29:13 UTC (rev 1741)
@@ -18,6 +18,9 @@
*/
package com.mebigfatguy.fbcontrib.detect;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.bcel.Constants;
import org.apache.bcel.classfile.Code;
import org.apache.bcel.classfile.Method;
@@ -38,6 +41,8 @@
{
private final BugReporter bugReporter;
private OpcodeStack stack;
+ private int returnRegister;
+ private Map<Integer, Object> registerConstants;
private Object returnConstant;
private boolean methodSuspect;
private int returnPC;
@@ -54,9 +59,11 @@
public void visitClassContext(ClassContext classContext) {
try {
stack = new OpcodeStack();
+ registerConstants = new HashMap<Integer, Object>();
super.visitClassContext(classContext);
} finally {
stack = null;
+ registerConstants = null;
}
}
@@ -73,7 +80,9 @@
&& ((aFlags & Constants.ACC_SYNTHETIC) == 0)
&& (!m.getSignature().endsWith(")Z"))) {
stack.resetForMethodEntry(this);
+ returnRegister = -1;
returnConstant = null;
+ registerConstants.clear();
methodSuspect = true;
returnPC = -1;
super.visitCode(obj);
@@ -108,12 +117,18 @@
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
+ int register = item.getRegisterNumber();
+ if (registerConstants.containsKey(register) && (registerConstants.get(register) == null)) {
+ methodSuspect = false;
+ return;
+ }
+
Object constant = item.getConstant();
if (constant == null) {
methodSuspect = false;
return;
}
- if ((item.getUserValue() != null) && ("".equals(constant))) {
+ if (Boolean.TRUE.equals(item.getUserValue()) && ("".equals(constant))) {
methodSuspect = false;
return;
}
@@ -122,6 +137,7 @@
return;
}
+ returnRegister = item.getRegisterNumber();
returnConstant = constant;
}
} else if ((seen == GOTO) || (seen == GOTO_W)) {
@@ -133,7 +149,35 @@
if (clsName.startsWith("java/lang/StringB")) {
sawSBToString = "toString".equals(getNameConstantOperand());
}
+ } else if ((seen >= ISTORE) && (seen <= ASTORE_3) || (seen == IINC)) {
+ int register = getRegisterOperand();
+ if ((returnRegister != -1) && (register == returnRegister)) {
+ methodSuspect = false;
+ }
+
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ Object constant = item.getConstant();
+ if (registerConstants.containsKey(register)) {
+ if ((constant == null) || !constant.equals(registerConstants.get(register))) {
+ registerConstants.put(register, null);
+ }
+ } else {
+ registerConstants.put(register, constant);
+ }
+ } else {
+ registerConstants.put(register, null);
+ }
+
+ if (returnRegister == register) {
+ Object constant = registerConstants.get(returnRegister);
+ if (constant != null) {
+ methodSuspect = false;
+ }
+ }
}
+
+
} finally {
TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|