[Fb-contrib-commit] SF.net SVN: fb-contrib: [555] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/de
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-06-06 16:02:27
|
Revision: 555 Author: dbrosius Date: 2006-06-06 09:02:16 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=555&view=rev Log Message: ----------- add javadoc, copyright Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 15:57:07 UTC (rev 554) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 16:02:16 UTC (rev 555) @@ -1,3 +1,21 @@ +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2006 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.mebigfatguy.fbcontrib.detect; import java.util.Arrays; @@ -42,10 +60,19 @@ private Map<String, MethodCall> fieldMethodCalls = null; private Set<Integer> branchTargets = null; + /** + * constructs a RMC detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ public RedundantMethodCalls(BugReporter bugReporter) { this.bugReporter = bugReporter; } + /** + * implements the visitor to create and clear the stack, method call maps, and branch targets + * + * @param classContext the context object of the currently visited class + */ public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); @@ -60,6 +87,12 @@ branchTargets = null; } } + + /** + * implements the visitor to reset the stack, and method call maps for new method + * + * @param obj the context object of the currently parsed code block + */ public void visitCode(Code obj) { stack.resetForMethodEntry(this); localMethodCalls.clear(); @@ -67,6 +100,12 @@ super.visitCode(obj); } + /** + * implements the visitor to look for repetitive calls to the same method on the same object + * using the same constant parameters. These methods must return a value. + * + * @param seen the opcode of the currently parsed instruction + */ public void sawOpcode(int seen) { try { stack.mergeJumps(this); @@ -141,6 +180,12 @@ } } + /** + * returns true if the method name contains a pattern that is considered likely to be this modifying + * + * @param methodName the method name to check + * @return whether the method sounds like it modifies this + */ private boolean isRiskyName(String methodName) { methodName = methodName.toLowerCase(Locale.ENGLISH); for (String riskyName : riskyMethodNameContents) { @@ -150,6 +195,9 @@ return false; } + /** + * contains information about a method call + */ private static class MethodCall { private String methodName; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |