Thread: [Fb-contrib-commit] SF.net SVN: fb-contrib: [481] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/det
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-04-19 00:42:16
|
Revision: 481 Author: dbrosius Date: 2006-04-18 17:42:04 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=481&view=rev Log Message: ----------- Manually cleanup memory now that StatelessDetector is removed. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java 2006-04-19 00:39:41 UTC (rev 480) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java 2006-04-19 00:42:04 UTC (rev 481) @@ -30,12 +30,12 @@ import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.OpcodeStack; -import edu.umd.cs.findbugs.StatelessDetector; +import edu.umd.cs.findbugs.ba.ClassContext; /** * Looks for methods that create DOM Nodes but do not add them to any DOM Document. */ -public class OrphanedDOMNode extends BytecodeScanningDetector implements StatelessDetector +public class OrphanedDOMNode extends BytecodeScanningDetector { private static final Set<String> domCreationMethods = new HashSet<String>(); static { @@ -50,9 +50,9 @@ } private BugReporter bugReporter; - private OpcodeStack stack = new OpcodeStack(); - private Map<OpcodeStack.Item, Integer> nodeCreations = new HashMap<OpcodeStack.Item, Integer>(); - private Map<Integer, Integer> nodeStores = new HashMap<Integer, Integer>(); + private OpcodeStack stack; + private Map<OpcodeStack.Item, Integer> nodeCreations; + private Map<Integer, Integer> nodeStores; /** * constructs a ODN detector given the reporter to report bugs on @@ -63,16 +63,24 @@ this.bugReporter = bugReporter; } - /** - * clone this detector so that it can be a StatelessDetector - * - * @return a clone of this object - */ + /** + * implements the visitor to create and clear the stack, node creations and store maps + * + * @param classContext the context object for the currently parsed class + */ @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + nodeCreations = new HashMap<OpcodeStack.Item, Integer>(); + nodeStores = new HashMap<Integer, Integer>(); + super.visitClassContext(classContext); + } finally { + stack = null; + nodeCreations = null; + nodeStores = null; + } } - /** * implements the visitor to clear the opcode stack for the next code * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-21 02:47:30
|
Revision: 622 Author: dbrosius Date: 2006-08-20 19:47:24 -0700 (Sun, 20 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=622&view=rev Log Message: ----------- Remove some false positives due to a DOM node being loaded, and method called on it, leaving an entry in the nodeCreations map. Now remove entries when a method is called on it, as the DOM api, never leaves this on the stack. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java 2006-08-20 00:41:27 UTC (rev 621) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java 2006-08-21 02:47:24 UTC (rev 622) @@ -27,6 +27,7 @@ import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.Integer14; +import com.mebigfatguy.fbcontrib.utils.RegisterUtils; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -141,11 +142,7 @@ } } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && seen <= ASTORE_3)) { Integer pc = findDOMNodeCreationPoint(0); - int reg; - if (seen == ASTORE) - reg = getRegisterOperand(); - else - reg = seen - ASTORE_0; + int reg = RegisterUtils.getAStoreReg(this, seen); if (pc != null) nodeStores.put(Integer14.valueOf(reg), pc); else @@ -154,11 +151,7 @@ //Stores to member variables are assumed ok findDOMNodeCreationPoint(0); } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { - int reg; - if (seen == ALOAD) - reg = getRegisterOperand(); - else - reg = seen - ALOAD_0; + int reg = RegisterUtils.getALoadReg(this, seen); itemPC = nodeStores.get(Integer14.valueOf(reg)); if (itemPC != null) sawCreate = true; @@ -187,6 +180,9 @@ nodeStores.remove(Integer14.valueOf(reg)); } } + if ((seen != INVOKESTATIC) && (stack.getStackDepth() > argCount)) { + nodeCreations.remove(stack.getStackItem(argCount)); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |