[Fb-contrib-commit] fb-contrib/src/com/mebigfatguy/fbcontrib/detect AbnormalFinallyBlockReturn.java,
Brought to you by:
dbrosius
|
From: Dave B. <dbr...@us...> - 2005-12-05 05:01:00
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13952/src/com/mebigfatguy/fbcontrib/detect Modified Files: AbnormalFinallyBlockReturn.java Log Message: javadoc Index: AbnormalFinallyBlockReturn.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- AbnormalFinallyBlockReturn.java 22 Nov 2005 03:51:05 -0000 1.5 +++ AbnormalFinallyBlockReturn.java 5 Dec 2005 05:00:50 -0000 1.6 @@ -30,6 +30,10 @@ import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; +/** + * find methods that return or throw exception from a finally block. Doing so short-circuits the + * return or exception thrown from the try block, and masks it. + */ public class AbnormalFinallyBlockReturn extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; private CodeException[] exc; @@ -37,15 +41,29 @@ private int majorVersion; private int loadedReg; + /** + * constructs a AFBR detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ public AbnormalFinallyBlockReturn(final BugReporter bugReporter) { 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(); } + /** + * overrides the visitor to check for java class version being as good or better than 1.4 + * + * @param classContext the context object that holds the JavaClass parsed + */ @Override public void visitClassContext(ClassContext classContext) { majorVersion = classContext.getJavaClass().getMajor(); @@ -53,6 +71,11 @@ super.visitClassContext(classContext); } + /** + * overrides the visitor to collect finally block info + * + * @param obj the code object to scan for finally blocks + */ @Override public void visitCode(Code obj) { fbInfo.clear(); @@ -72,6 +95,11 @@ super.visitCode(obj); } + /** + * overrides the visitor to find return/exceptions from the finally block + * + * @param seen the opcode that is being visited + */ @Override public void sawOpcode(int seen) { if (fbInfo.size() == 0) @@ -127,6 +155,9 @@ } } + /** + * holds the finally block information for a particular method + */ public static class FinallyBlockInfo { public int startPC; @@ -134,6 +165,12 @@ public int monitorCount; public int exReg; + /** + * create a finally block info for a specific code range + * + * @param start the start of the try block + * @param end the end of the try block + */ public FinallyBlockInfo(int start, int end) { startPC = start; endPC = end; |