[Fb-contrib-commit] SF.net SVN: fb-contrib: [486] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/det
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-04-19 00:50:30
|
Revision: 486 Author: dbrosius Date: 2006-04-18 17:50:25 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=486&view=rev Log Message: ----------- Manually cleanup memory now that StatelessDetector is removed. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ParallelLists.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ParallelLists.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ParallelLists.java 2006-04-19 00:48:13 UTC (rev 485) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ParallelLists.java 2006-04-19 00:50:25 UTC (rev 486) @@ -32,7 +32,6 @@ import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.FieldAnnotation; import edu.umd.cs.findbugs.OpcodeStack; -import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; /** @@ -40,12 +39,12 @@ * to hold two or more pieces of related information. It would be better to create a new class that holds * all of these pieces of information, and place instances of this class in one list. */ -public class ParallelLists extends BytecodeScanningDetector implements StatelessDetector +public class ParallelLists extends BytecodeScanningDetector { private BugReporter bugReporter; - private OpcodeStack stack = new OpcodeStack(); - private Set<String> listFields = new HashSet<String>(); - private Map<Integer, String> indexToFieldMap = new HashMap<Integer, String>(); + private OpcodeStack stack; + private Set<String> listFields; + private Map<Integer, String> indexToFieldMap; /** * constructs a PL detector given the reporter to report bugs on @@ -55,35 +54,33 @@ this.bugReporter = bugReporter; } - /** - * clone this detector so that it can be a StatelessDetector - * - * @return a clone of this object - */ @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - @Override public void visitClassContext(final ClassContext classContext) { - JavaClass cls = classContext.getJavaClass(); - - listFields.clear(); - Field[] flds = cls.getFields(); - for (Field f : flds) { - String sig = f.getSignature(); - if (sig.charAt(0) == 'L') { - sig = sig.substring(1, sig.length() - 1); - if (sig.startsWith("java/util/") && sig.endsWith("List")) { + try { + JavaClass cls = classContext.getJavaClass(); + + listFields = new HashSet<String>(); + Field[] flds = cls.getFields(); + for (Field f : flds) { + String sig = f.getSignature(); + if (sig.charAt(0) == 'L') { + sig = sig.substring(1, sig.length() - 1); + if (sig.startsWith("java/util/") && sig.endsWith("List")) { + listFields.add(f.getName()); + } + } else if ((sig.charAt(0) == '[') && (sig.charAt(1) != '[')) listFields.add(f.getName()); - } - } else if ((sig.charAt(0) == '[') && (sig.charAt(1) != '[')) - listFields.add(f.getName()); + } + + if (listFields.size() > 0) { + stack = new OpcodeStack(); + indexToFieldMap = new HashMap<Integer, String>(); + super.visitClassContext(classContext); + } + } finally { + stack = null; + indexToFieldMap = null; } - - if (listFields.size() > 0) - super.visitClassContext(classContext); } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |