[Fb-contrib-commit] SF.net SVN: fb-contrib:[1661] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2011-03-25 23:43:59
|
Revision: 1661
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1661&view=rev
Author: dbrosius
Date: 2011-03-25 23:43:53 +0000 (Fri, 25 Mar 2011)
Log Message:
-----------
fix WOC FP when field is fetched from a non-this object of the same class
Modified Paths:
--------------
trunk/fb-contrib/samples/WOC_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java
Modified: trunk/fb-contrib/samples/WOC_Sample.java
===================================================================
--- trunk/fb-contrib/samples/WOC_Sample.java 2011-03-25 23:27:14 UTC (rev 1660)
+++ trunk/fb-contrib/samples/WOC_Sample.java 2011-03-25 23:43:53 UTC (rev 1661)
@@ -97,7 +97,7 @@
};
}
- public List<String> fpOtherClass(WOC_Sample ws)
+ public List<String> fpOtherInstance(WOC_Sample ws)
{
return ws.fpList;
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2011-03-25 23:27:14 UTC (rev 1660)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2011-03-25 23:43:53 UTC (rev 1661)
@@ -98,6 +98,7 @@
private final BugReporter bugReporter;
private OpcodeStack stack;
+ private String clsSignature;
/** register to first allocation PC */
private Map<Integer, Integer> localWOCollections;
/** fieldname to field sig */
@@ -119,11 +120,12 @@
@Override
public void visitClassContext(ClassContext classContext) {
try {
+ clsSignature = "L" + classContext.getJavaClass().getClassName().replaceAll("\\.", "/") + ";";
stack = new OpcodeStack();
localWOCollections = new HashMap<Integer, Integer>();
fieldWOCollections = new HashMap<String, String>();
super.visitClassContext(classContext);
-
+
if (fieldWOCollections.size() > 0) {
String clsName = classContext.getJavaClass().getClassName();
for (Map.Entry<String, String> entry : fieldWOCollections.entrySet()) {
@@ -140,7 +142,7 @@
fieldWOCollections = null;
}
}
-
+
@Override
public void visitField(Field obj) {
if (obj.isPrivate() && !obj.isSynthetic()) {
@@ -149,7 +151,7 @@
String type = sig.substring(1, sig.length() - 1).replace('/', '.');
if (collectionClasses.contains(type)) {
fieldWOCollections.put(obj.getName(), obj.getSignature());
- }
+ }
}
}
}
@@ -199,7 +201,7 @@
break;
case INVOKEINTERFACE:
- case INVOKEVIRTUAL:
+ case INVOKEVIRTUAL: {
String sig = getSigConstantOperand();
int numParms = Type.getArgumentTypes(sig).length;
if (stack.getStackDepth() > numParms) {
@@ -218,6 +220,7 @@
}
}
processMethodParms();
+ }
break;
case INVOKESTATIC:
@@ -281,7 +284,8 @@
case GETFIELD:
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
- if (item.getRegisterNumber() == 0) {
+ String sig = item.getSignature();
+ if ((item.getRegisterNumber() == 0) || ((sig != null) && sig.equals(clsSignature))) {
XField field = getXFieldOperand();
if (field != null) {
String fieldName = field.getName();
@@ -292,7 +296,7 @@
}
}
break;
-
+
case PUTSTATIC:
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
@@ -302,7 +306,7 @@
}
}
break;
-
+
case GETSTATIC:
XField field = getXFieldOperand();
if (field != null) {
@@ -312,7 +316,7 @@
}
}
break;
-
+
case GOTO:
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
@@ -338,7 +342,7 @@
int nextPC = getNextPC();
return getCode().getCode()[nextPC] == POP;
}
-
+
private void clearUserValue(OpcodeStack.Item item) {
Object uo = item.getUserValue();
if (uo instanceof Integer) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|