[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. |