Thread: [Fb-contrib-commit] SF.net SVN: fb-contrib: [441] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/det
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-04-12 00:57:00
|
Revision: 441 Author: dbrosius Date: 2006-04-11 17:56:54 -0700 (Tue, 11 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=441&view=rev Log Message: ----------- simplify Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2006-04-11 14:34:15 UTC (rev 440) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2006-04-12 00:56:54 UTC (rev 441) @@ -235,27 +235,25 @@ * @return true if the class is counted */ private boolean countClassAccess(final int classAtStackIndex) { - String calledClass = null; + String calledClass; try { if (stack.getStackDepth() > classAtStackIndex) { OpcodeStack.Item itm = stack.getStackItem(classAtStackIndex); JavaClass cls = itm.getJavaClass(); - if (cls != null) + if (cls != null) { calledClass = cls.getClassName(); - else - return false; - } else - return false; - } catch (ClassNotFoundException cfne) { + countClassAccess(calledClass); + return true; + } + } + } catch (ClassNotFoundException cfne) { bugReporter.reportMissingClass(cfne); - return false; } + + return false; + } - countClassAccess(calledClass); - return true; - } - /** * increment the count of class access of the specified class if it is in a similar * package to the caller, and is not general purpose This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-17 03:41:49
|
Revision: 455 Author: dbrosius Date: 2006-04-16 20:41:44 -0700 (Sun, 16 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=455&view=rev Log Message: ----------- Manually cleanup memory now that StatelessDetector is removed. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2006-04-17 03:38:12 UTC (rev 454) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2006-04-17 03:41:44 UTC (rev 455) @@ -36,14 +36,13 @@ 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; /** * finds methods that excessively use methods from another class. This probably means * these methods should be defined in that other class. */ -public class ClassEnvy extends BytecodeScanningDetector implements StatelessDetector +public class ClassEnvy extends BytecodeScanningDetector { private static final String ENVY_PERCENT_PROPERTY = "fb-contrib.ce.percent"; private static final Set<String> ignorableInterfaces = new HashSet<String>(); @@ -70,7 +69,6 @@ */ public ClassEnvy(final BugReporter bugReporter) { this.bugReporter = bugReporter; - stack = new OpcodeStack(); String percent = System.getProperty(ENVY_PERCENT_PROPERTY); if (percent != null) { try { @@ -85,16 +83,6 @@ } /** - * 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(); - } - - /** * overrides the visitor to collect package and class names * * @param classContext the context object that holds the JavaClass being parsed @@ -104,7 +92,10 @@ JavaClass cls = classContext.getJavaClass(); packageName = cls.getPackageName(); clsName = cls.getClassName(); + stack = new OpcodeStack(); super.visitClassContext(classContext); + stack = null; + clsAccessCount = null; } /** @@ -127,11 +118,11 @@ @Override public void visitCode(final Code obj) { stack.resetForMethodEntry(this); - clsAccessCount = new HashMap<String, Set<Integer>>(); thisClsAccessCount = 0; if ("<clinit>".equals(methodName)) return; + clsAccessCount = new HashMap<String, Set<Integer>>(); super.visitCode(obj); if (clsAccessCount.size() > 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |