[Fb-contrib-commit] fb-contrib/src/com/mebigfatguy/fbcontrib/detect DubiousListCollection.java,1.8,1
Brought to you by:
dbrosius
|
From: Dave B. <dbr...@us...> - 2005-12-06 05:48:28
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13651/src/com/mebigfatguy/fbcontrib/detect Modified Files: DubiousListCollection.java Log Message: javadoc Index: DubiousListCollection.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- DubiousListCollection.java 5 Dec 2005 05:21:15 -0000 1.8 +++ DubiousListCollection.java 6 Dec 2005 05:48:21 -0000 1.9 @@ -70,6 +70,11 @@ this.bugReporter = bugReporter; } + /** + * overrides the visitor to accept classes that define List based fields + * + * @param classContext the context object for the currently parsed class + */ @Override public void visitClassContext(final ClassContext classContext) { JavaClass cls = classContext.getJavaClass(); @@ -90,12 +95,23 @@ } } + /** + * overrides the visitor to reset the opcode stack object + * + * @param obj the code object for the currently parse method + */ @Override public void visitCode(final Code obj) { stack.resetForMethodEntry(this); super.visitCode(obj); } + /** + * overrides the visitor to record all method calls on List fields. If a method + * is not a set based method, remove it from further consideration + * + * @param seen the current opcode parsed. + */ @Override public void sawOpcode(final int seen) { try { @@ -134,7 +150,16 @@ stack.sawOpcode(this, seen); } } - + + /** + * return the field object that the current method was called on, by finding the reference + * down in the stack based on the number of parameters + * + * @param stk the opcode stack where fields are stored + * @param signature the signature of the called method + * + * @return the field annotation for the field whose method was executed + */ private FieldAnnotation getFieldFromStack(final OpcodeStack stk, final String signature) { int parmCount = Type.getArgumentTypes(signature).length; if (stk.getStackDepth() > parmCount) { @@ -144,6 +169,9 @@ return null; } + /** + * implements the detector, by reporting all remaining fields that only have set based access + */ private void reportBugs() { for (Map.Entry<String, Integer> entry : fieldsReported.entrySet()) { String field = entry.getKey(); @@ -159,6 +187,13 @@ } } + /** + * builds a field annotation by finding the field in the classes' field list + * + * @param fieldName the field for which to built the field annotation + * + * @return the field annotation of the specified field + */ private FieldAnnotation getFieldAnnotation(final String fieldName) { JavaClass cls = getClassContext().getJavaClass(); Field[] fields = cls.getFields(); |