[Fb-contrib-commit] SF.net SVN: fb-contrib:[1606] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2010-09-05 00:38:04
|
Revision: 1606
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1606&view=rev
Author: dbrosius
Date: 2010-09-05 00:37:58 +0000 (Sun, 05 Sep 2010)
Log Message:
-----------
handle field based beans correctly
Modified Paths:
--------------
trunk/fb-contrib/samples/SGSU_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousGetterSetterUse.java
Modified: trunk/fb-contrib/samples/SGSU_Sample.java
===================================================================
--- trunk/fb-contrib/samples/SGSU_Sample.java 2010-09-04 20:41:14 UTC (rev 1605)
+++ trunk/fb-contrib/samples/SGSU_Sample.java 2010-09-05 00:37:58 UTC (rev 1606)
@@ -2,12 +2,23 @@
public class SGSU_Sample
{
private SGSU_Sample foo;
+ private SGSU_Sample foo2;
- public void testSGSU(SGSU_Sample s1, SGSU_Sample s2)
+ public void testSGSULocals(SGSU_Sample s1, SGSU_Sample s2)
{
s1.setSGSU(s1.getSGSU());
}
+ public void testSGSUFields()
+ {
+ foo.setSGSU(foo.getSGSU());
+ }
+
+ public void fpSGSUFields()
+ {
+ foo.setSGSU(foo2.getSGSU());
+ }
+
public void setSGSU(SGSU_Sample f)
{
foo = f;
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousGetterSetterUse.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousGetterSetterUse.java 2010-09-04 20:41:14 UTC (rev 1605)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousGetterSetterUse.java 2010-09-05 00:37:58 UTC (rev 1606)
@@ -33,9 +33,11 @@
private static enum State {SEEN_NOTHING, SEEN_ALOAD, SEEN_GETFIELD, SEEN_DUAL_LOADS, SEEN_INVOKEVIRTUAL};
private final BugReporter bugReporter;
private State state;
- private String beanReference;
+ private String beanReference1;
+ private String beanReference2;
private String propName;
private String propType;
+ private boolean sawField;
/**
* constructs a SGSU detector given the reporter to report bugs on
@@ -54,9 +56,11 @@
@Override
public void visitCode(Code obj) {
state = State.SEEN_NOTHING;
- beanReference = null;
+ beanReference1 = null;
+ beanReference2 = null;
propName = null;
propType = null;
+ sawField = false;
super.visitCode(obj);
}
@@ -77,16 +81,10 @@
case ALOAD_1:
case ALOAD_2:
case ALOAD_3:
- beanReference = String.valueOf(getRegisterOperand());
+ beanReference1 = String.valueOf(getRegisterOperand());
state = State.SEEN_ALOAD;
reset = false;
break;
-
- case GETFIELD:
- beanReference = getNameConstantOperand();
- state = State.SEEN_GETFIELD;
- reset = false;
- break;
}
break;
@@ -97,19 +95,42 @@
case ALOAD_1:
case ALOAD_2:
case ALOAD_3:
- if (beanReference.equals(String.valueOf(getRegisterOperand()))) {
+ if (!sawField && beanReference1.equals(String.valueOf(getRegisterOperand()))) {
state = State.SEEN_DUAL_LOADS;
reset = false;
}
break;
+
+ case GETFIELD: {
+ if (sawField) {
+ beanReference2 += ":" + getNameConstantOperand();
+ if (beanReference1.equals(beanReference2)) {
+ state = State.SEEN_DUAL_LOADS;
+ reset = false;
+ }
+ } else {
+ state = State.SEEN_GETFIELD;
+ beanReference1 += ":" + getNameConstantOperand();
+ sawField = true;
+ reset = false;
+ }
+ }
}
break;
- case SEEN_GETFIELD:
- if (beanReference.equals(getNameConstantOperand())) {
- state = State.SEEN_DUAL_LOADS;
- reset = false;
+ case SEEN_GETFIELD: {
+ switch (seen) {
+ case ALOAD:
+ case ALOAD_0:
+ case ALOAD_1:
+ case ALOAD_2:
+ case ALOAD_3:
+ beanReference2 = String.valueOf(getRegisterOperand());
+ state = State.SEEN_ALOAD;
+ reset = false;
+ break;
}
+ }
break;
case SEEN_DUAL_LOADS:
@@ -148,9 +169,11 @@
}
if (reset) {
- beanReference = null;
+ beanReference1 = null;
+ beanReference2 = null;
propType = null;
propName = null;
+ sawField = false;
state = State.SEEN_NOTHING;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|