Thread: [Fb-contrib-commit] SF.net SVN: fb-contrib: [492] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/det
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-04-19 01:02:48
|
Revision: 492 Author: dbrosius Date: 2006-04-18 18:02:44 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=492&view=rev Log Message: ----------- Manually cleanup memory now that StatelessDetector is removed. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java 2006-04-19 00:59:29 UTC (rev 491) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java 2006-04-19 01:02:44 UTC (rev 492) @@ -35,7 +35,6 @@ import edu.umd.cs.findbugs.FieldAnnotation; import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.SourceLineAnnotation; -import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; /** @@ -46,7 +45,7 @@ * which defines the different types required, and add an instance of that class to the * collection, or array. */ -public class UnrelatedCollectionContents extends BytecodeScanningDetector implements StatelessDetector +public class UnrelatedCollectionContents extends BytecodeScanningDetector { private static final Set<String> COLLECTION_CLASSES = new HashSet<String>(); static { @@ -71,33 +70,40 @@ */ public UnrelatedCollectionContents(final BugReporter bugReporter) { this.bugReporter = bugReporter; - stack = new OpcodeStack(); } /** - * clone this detector so that it can be a StatelessDetector + * implements the visitor to create and destroy the stack and member collections * - * @return a clone of this object + * @param classContext the context object for the currently parsed class */ @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - @Override public void visitClassContext(final ClassContext classContext) { - memberCollections = new HashMap<String, Set<String>>(); - memberSourceLineAnnotations = new HashMap<String, Set<SourceLineAnnotation>>(); - super.visitClassContext(classContext); + try { + stack = new OpcodeStack(); + memberCollections = new HashMap<String, Set<String>>(); + memberSourceLineAnnotations = new HashMap<String, Set<SourceLineAnnotation>>(); + super.visitClassContext(classContext); + } finally { + stack = null; + memberCollections = null; + memberSourceLineAnnotations = null; + } } @Override public void visitCode(final Code obj) { - localCollections = new HashMap<Integer, Set<String>>(); - localScopeEnds = new HashMap<Integer, Set<Integer>>(); - localSourceLineAnnotations = new HashMap<Integer, Set<SourceLineAnnotation>>(); - stack.resetForMethodEntry(this); - super.visitCode(obj); + try { + localCollections = new HashMap<Integer, Set<String>>(); + localScopeEnds = new HashMap<Integer, Set<Integer>>(); + localSourceLineAnnotations = new HashMap<Integer, Set<SourceLineAnnotation>>(); + stack.resetForMethodEntry(this); + super.visitCode(obj); + } finally { + localCollections = null; + localScopeEnds = null; + localSourceLineAnnotations = null; + } } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-07-07 18:32:50
|
Revision: 574 Author: dbrosius Date: 2006-07-07 11:32:44 -0700 (Fri, 07 Jul 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=574&view=rev Log Message: ----------- guard against odd npe due to empty signature Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java 2006-06-28 18:59:10 UTC (rev 573) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java 2006-07-07 18:32:44 UTC (rev 574) @@ -232,9 +232,13 @@ private void addNewItem(final Set<String> supers, final OpcodeStack.Item addItm) throws ClassNotFoundException { - if (addItm.getSignature().charAt(0) == '[') { - supers.add(addItm.getSignature()); + String itemSignature = addItm.getSignature(); + if (itemSignature.length() == 0) return; + + if (itemSignature.charAt(0) == '[') { + supers.add(itemSignature); + return; } JavaClass cls = addItm.getJavaClass(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |