[Fb-contrib-commit] SF.net SVN: fb-contrib: [478] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/det
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2006-04-18 22:26:44
|
Revision: 478 Author: dbrosius Date: 2006-04-18 15:26:38 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=478&view=rev Log Message: ----------- Manually cleanup memory now that StatelessDetector is removed. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-18 22:24:26 UTC (rev 477) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-18 22:26:38 UTC (rev 478) @@ -15,7 +15,7 @@ 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 synchronize on variables that are not owned by the @@ -24,13 +24,14 @@ * synchronize on private fields of the class. Note that 'this' is not owned by * the current class and synchronization on 'this' should be avoided as well. */ -public class NonOwnedSynchronization extends BytecodeScanningDetector implements StatelessDetector { +public class NonOwnedSynchronization extends BytecodeScanningDetector +{ private static final Integer OWNED = new Integer(Integer.MAX_VALUE); private static final Integer LOW = new Integer(LOW_PRIORITY); private static final Integer NORMAL = new Integer(NORMAL_PRIORITY); private BugReporter bugReporter; - private OpcodeStack stack = new OpcodeStack(); - private Map<Integer, Integer> regPriorities = new HashMap<Integer, Integer>(); + private OpcodeStack stack; + private Map<Integer, Integer> regPriorities; /** * constructs a NOS detector given the reporter to report bugs on @@ -38,18 +39,23 @@ */ public NonOwnedSynchronization(BugReporter bugReporter) { this.bugReporter = bugReporter; } + + /** + * implements the visitor to set and clear the stack and priorities + */ + @Override + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + regPriorities = new HashMap<Integer, Integer>(); + super.visitClassContext(classContext); + } finally { + stack = null; + regPriorities = null; + } + } /** - * 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(); - } - - /** * looks for methods that contain a MONITORENTER opcode * * @param method the context object of the current method This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |