fb-contrib-commit Mailing List for fb-contrib (Page 59)
Brought to you by:
dbrosius
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(56) |
Oct
(60) |
Nov
(58) |
Dec
(89) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(66) |
Feb
(55) |
Mar
(85) |
Apr
(115) |
May
(35) |
Jun
(28) |
Jul
(3) |
Aug
(48) |
Sep
(37) |
Oct
(22) |
Nov
(14) |
Dec
(66) |
2007 |
Jan
(45) |
Feb
(63) |
Mar
(10) |
Apr
(1) |
May
(1) |
Jun
(12) |
Jul
|
Aug
|
Sep
(25) |
Oct
(21) |
Nov
(39) |
Dec
|
2008 |
Jan
(7) |
Feb
|
Mar
(26) |
Apr
(5) |
May
(2) |
Jun
(32) |
Jul
(9) |
Aug
(10) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
|
2009 |
Jan
(10) |
Feb
(31) |
Mar
(32) |
Apr
(35) |
May
(25) |
Jun
|
Jul
(31) |
Aug
(10) |
Sep
(95) |
Oct
(35) |
Nov
(10) |
Dec
(34) |
2010 |
Jan
(90) |
Feb
(4) |
Mar
(7) |
Apr
(20) |
May
(20) |
Jun
(13) |
Jul
(7) |
Aug
(18) |
Sep
(25) |
Oct
(4) |
Nov
(16) |
Dec
(2) |
2011 |
Jan
(1) |
Feb
|
Mar
(11) |
Apr
(3) |
May
(2) |
Jun
(26) |
Jul
(10) |
Aug
(2) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
2012 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(14) |
Nov
(3) |
Dec
(4) |
2013 |
Jan
(3) |
Feb
(2) |
Mar
(1) |
Apr
(4) |
May
|
Jun
(1) |
Jul
(3) |
Aug
|
Sep
|
Oct
(4) |
Nov
(3) |
Dec
(3) |
2014 |
Jan
(4) |
Feb
(2) |
Mar
(4) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(3) |
Dec
(3) |
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
(2) |
Nov
(7) |
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
(5) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(3) |
2018 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(5) |
Jun
(2) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Dave B. <dbr...@us...> - 2006-03-28 02:22:22
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23585/htdocs Modified Files: index.html Log Message: expand cvs now Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.76 retrieving revision 1.77 diff -u -d -r1.76 -r1.77 --- index.html 27 Mar 2006 06:28:36 -0000 1.76 +++ index.html 28 Mar 2006 02:22:19 -0000 1.77 @@ -46,10 +46,10 @@ <a href="javadoc/index.html">JavaDoc</a> <hr/> - <img id="cvs_image" src="flip1.gif" onClick="toggleBlock('cvs', 'cvs_image');" align="top"/> + <img id="cvs_image" src="flip2.gif" onClick="toggleBlock('cvs', 'cvs_image');" align="top"/> Detectors added in CVS<br/> Note: these detectors are still in testing<br/> - <div id="cvs" style="display:none;"> + <div id="cvs" style="display:block;"> <ul> <li><b>[BSB] Bloated Synchronized Block</b><br/> Looks for methods that implement synchronized blocks that appear to contain some code at @@ -62,9 +62,9 @@ </ul> </div> <hr/> - <img id="v2_4_0_image" src="flip2.gif" onClick="toggleBlock('v2_4_0', 'v2_4_0_image');" align="top"/> + <img id="v2_4_0_image" src="flip1.gif" onClick="toggleBlock('v2_4_0', 'v2_4_0_image');" align="top"/> Detectors added in v2.4.0<br/> - <div id="v2_4_0" style="display:block;"> + <div id="v2_4_0" style="display:none;"> <ul> <li><b>[DDC] Double Date Compare</b><br/> Looks for methods that compare two dates using .equals and after or before. |
From: Dave B. <dbr...@us...> - 2006-03-28 02:19:59
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21568/src/com/mebigfatguy/fbcontrib/detect Modified Files: FieldCouldBeLocal.java Log Message: add sourcelineannotation for FCBL where possible Index: FieldCouldBeLocal.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- FieldCouldBeLocal.java 27 Mar 2006 06:26:18 -0000 1.3 +++ FieldCouldBeLocal.java 28 Mar 2006 02:19:55 -0000 1.4 @@ -40,6 +40,7 @@ import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.FieldAnnotation; +import edu.umd.cs.findbugs.SourceLineAnnotation; import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.BasicBlock; import edu.umd.cs.findbugs.ba.CFG; @@ -55,7 +56,7 @@ private BugReporter bugReporter; private ClassContext clsContext; - private Map<String, FieldAnnotation> localizableFields = new HashMap<String, FieldAnnotation>(); + private Map<String, FieldInfo> localizableFields = new HashMap<String, FieldInfo>(); private CFG cfg; private ConstantPoolGen cpg; private BitSet visitedBlocks = new BitSet(); @@ -96,16 +97,21 @@ for (Field f : fields) { if ((!f.isStatic() && f.getName().indexOf("$") < 0) && (f.isPrivate() || (clsIsFinal && f.isProtected()))) { FieldAnnotation fa = new FieldAnnotation(cls.getClassName(), f.getName(), f.getSignature(), false); - localizableFields.put(f.getName(), fa); + localizableFields.put(f.getName(), new FieldInfo(fa)); } } if (localizableFields.size() > 0) { super.visitClassContext(classContext); - for (FieldAnnotation fa : localizableFields.values()) { - bugReporter.reportBug(new BugInstance(this, "FCBL_FIELD_COULD_BE_LOCAL", NORMAL_PRIORITY) - .addClass(this) - .addField(fa)); + for (FieldInfo fi : localizableFields.values()) { + FieldAnnotation fa = fi.getFieldAnnotation(); + SourceLineAnnotation sla = fi.getSrcLineAnnotation(); + BugInstance bug = new BugInstance(this, "FCBL_FIELD_COULD_BE_LOCAL", NORMAL_PRIORITY) + .addClass(this) + .addField(fa); + if (sla != null) + bug.addSourceLine(sla); + bugReporter.reportBug(bug); } } } @@ -164,10 +170,15 @@ FieldInstruction fi = (FieldInstruction) ins; String fieldName = fi.getFieldName(cpg); uncheckedFields.remove(fieldName); + if (ins instanceof GETFIELD) { localizableFields.remove(fieldName); if (localizableFields.size() == 0) return; + } else { + FieldInfo finfo = localizableFields.get(fieldName); + if (finfo != null) + finfo.setSrcLineAnnotation(SourceLineAnnotation.fromVisitedInstruction(clsContext, this, ih.getPosition())); } if (uncheckedFields.size() == 0) return; @@ -188,4 +199,27 @@ } } } + + private static class FieldInfo { + private FieldAnnotation fieldAnnotation; + private SourceLineAnnotation srcLineAnnotation; + + public FieldInfo(FieldAnnotation fa) { + fieldAnnotation = fa; + srcLineAnnotation = null; + } + + public void setSrcLineAnnotation(SourceLineAnnotation sla) { + if (srcLineAnnotation == null) + srcLineAnnotation = sla; + } + + public FieldAnnotation getFieldAnnotation() { + return fieldAnnotation; + } + + public SourceLineAnnotation getSrcLineAnnotation() { + return srcLineAnnotation; + } + } } |
From: Dave B. <dbr...@us...> - 2006-03-27 06:28:40
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30598/htdocs Modified Files: index.html Log Message: doc FCBL Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.75 retrieving revision 1.76 diff -u -d -r1.75 -r1.76 --- index.html 25 Mar 2006 02:19:51 -0000 1.75 +++ index.html 27 Mar 2006 06:28:36 -0000 1.76 @@ -55,6 +55,10 @@ Looks for methods that implement synchronized blocks that appear to contain some code at the beginning that does not need to be synchronized. Moving these lines out of the synchronized block should help multithreaded performance.</li> + <li><b>[FCBL] Field could be Local</b><br/> + Looks for classes that declare fields that are used in a locals-only fashion, specifically private fields + or protected fields in final classes that are accessed first in each method with a store vs. a load. + These fields can be declared as one or more locals.</li> </ul> </div> <hr/> |
From: Dave B. <dbr...@us...> - 2006-03-27 06:26:26
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29521/src/com/mebigfatguy/fbcontrib/detect Modified Files: FieldCouldBeLocal.java Log Message: don't report fields that have $ in them (internals) Index: FieldCouldBeLocal.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- FieldCouldBeLocal.java 27 Mar 2006 06:21:56 -0000 1.2 +++ FieldCouldBeLocal.java 27 Mar 2006 06:26:18 -0000 1.3 @@ -94,7 +94,7 @@ boolean clsIsFinal = cls.isFinal(); Field[] fields = cls.getFields(); for (Field f : fields) { - if ((!f.isStatic()) && (f.isPrivate() || (clsIsFinal && f.isProtected()))) { + if ((!f.isStatic() && f.getName().indexOf("$") < 0) && (f.isPrivate() || (clsIsFinal && f.isProtected()))) { FieldAnnotation fa = new FieldAnnotation(cls.getClassName(), f.getName(), f.getSignature(), false); localizableFields.put(f.getName(), fa); } @@ -164,13 +164,13 @@ FieldInstruction fi = (FieldInstruction) ins; String fieldName = fi.getFieldName(cpg); uncheckedFields.remove(fieldName); - if (uncheckedFields.size() == 0) - return; if (ins instanceof GETFIELD) { localizableFields.remove(fieldName); if (localizableFields.size() == 0) return; } + if (uncheckedFields.size() == 0) + return; } } |
From: Dave B. <dbr...@us...> - 2006-03-27 06:22:06
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27585/src/com/mebigfatguy/fbcontrib/detect Modified Files: FieldCouldBeLocal.java Log Message: FieldAnnotation's don't play nice with hashsets, so use a String keyed HashMap Index: FieldCouldBeLocal.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- FieldCouldBeLocal.java 27 Mar 2006 05:56:54 -0000 1.1 +++ FieldCouldBeLocal.java 27 Mar 2006 06:21:56 -0000 1.2 @@ -20,8 +20,10 @@ package com.mebigfatguy.fbcontrib.detect; import java.util.BitSet; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; import java.util.Set; import org.apache.bcel.classfile.Code; @@ -53,7 +55,7 @@ private BugReporter bugReporter; private ClassContext clsContext; - private Set<FieldAnnotation> localizableFields = new HashSet<FieldAnnotation>(); + private Map<String, FieldAnnotation> localizableFields = new HashMap<String, FieldAnnotation>(); private CFG cfg; private ConstantPoolGen cpg; private BitSet visitedBlocks = new BitSet(); @@ -94,13 +96,13 @@ for (Field f : fields) { if ((!f.isStatic()) && (f.isPrivate() || (clsIsFinal && f.isProtected()))) { FieldAnnotation fa = new FieldAnnotation(cls.getClassName(), f.getName(), f.getSignature(), false); - localizableFields.add(fa); + localizableFields.put(f.getName(), fa); } } if (localizableFields.size() > 0) { super.visitClassContext(classContext); - for (FieldAnnotation fa : localizableFields) { + for (FieldAnnotation fa : localizableFields.values()) { bugReporter.reportBug(new BugInstance(this, "FCBL_FIELD_COULD_BE_LOCAL", NORMAL_PRIORITY) .addClass(this) .addField(fa)); @@ -125,7 +127,7 @@ cpg = new ConstantPoolGen(getConstantPool()); cfg = clsContext.getCFG(obj); BasicBlock bb = cfg.getEntry(); - Set<FieldAnnotation> uncheckedFields = new HashSet<FieldAnnotation>(localizableFields); + Set<String> uncheckedFields = new HashSet<String>(localizableFields.keySet()); visitedBlocks.clear(); checkBlock(bb, uncheckedFields); } @@ -139,6 +141,7 @@ * * @param obj the context object of the currently parsed code attribute */ + @Override public void visitCode(Code obj) { } @@ -151,7 +154,7 @@ * @param bb this basic block * @param uncheckedFields the list of fields to look for */ - private void checkBlock(BasicBlock bb, Set<FieldAnnotation> uncheckedFields) { + private void checkBlock(BasicBlock bb, Set<String> uncheckedFields) { visitedBlocks.set(bb.getId()); InstructionIterator ii = bb.instructionIterator(); while (ii.hasNext()) { @@ -159,10 +162,15 @@ Instruction ins = ih.getInstruction(); if (ins instanceof FieldInstruction) { FieldInstruction fi = (FieldInstruction) ins; - FieldAnnotation fa = new FieldAnnotation(getClassName(), fi.getFieldName(cpg), fi.getSignature(cpg), false); - uncheckedFields.remove(fa); - if (ins instanceof GETFIELD) - localizableFields.remove(fa); + String fieldName = fi.getFieldName(cpg); + uncheckedFields.remove(fieldName); + if (uncheckedFields.size() == 0) + return; + if (ins instanceof GETFIELD) { + localizableFields.remove(fieldName); + if (localizableFields.size() == 0) + return; + } } } @@ -172,7 +180,7 @@ Edge e = oei.next(); BasicBlock cb = e.getTarget(); if (!visitedBlocks.get(cb.getId())) { - Set<FieldAnnotation> subCheckedFields = new HashSet<FieldAnnotation>(uncheckedFields); + Set<String> subCheckedFields = new HashSet<String>(uncheckedFields); checkBlock(cb, subCheckedFields); if (localizableFields.size() == 0) return; |
From: Dave B. <dbr...@us...> - 2006-03-27 05:56:58
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16920/src/com/mebigfatguy/fbcontrib/detect Added Files: FieldCouldBeLocal.java Log Message: Initial checkin - new FCBL detector --- NEW FILE: FieldCouldBeLocal.java --- /* * FindBugs - Find bugs in Java programs * Copyright (C) 2005 Dave Brosius <dbr...@us...> * Copyright (C) 2005 University of Maryland * * 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.BitSet; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Field; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.ConstantPoolGen; import org.apache.bcel.generic.FieldInstruction; import org.apache.bcel.generic.GETFIELD; import org.apache.bcel.generic.Instruction; import org.apache.bcel.generic.InstructionHandle; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.FieldAnnotation; import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.BasicBlock; import edu.umd.cs.findbugs.ba.CFG; import edu.umd.cs.findbugs.ba.ClassContext; import edu.umd.cs.findbugs.ba.Edge; import edu.umd.cs.findbugs.ba.BasicBlock.InstructionIterator; /** * finds fields that are used in a locals only fashion, specifically private fields or protected fields * in final classes that are accessed first in each method with a store vs. a load. */ public class FieldCouldBeLocal extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; private ClassContext clsContext; private Set<FieldAnnotation> localizableFields = new HashSet<FieldAnnotation>(); private CFG cfg; private ConstantPoolGen cpg; private BitSet visitedBlocks = new BitSet(); /** * constructs a FCBL detector given the reporter to report bugs on. * @param bugReporter the sync of bug reports */ public FieldCouldBeLocal(BugReporter bugReporter) { this.bugReporter = bugReporter; } /** * clone this detector so that it can be a StatelessDetector. * * @return a clone of this object * @throws CloneNotSupportedException should not happen */ @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * overrides the visitor to collect localizable fields, and then report those that * survive all method checks. * * @param classContext the context object that holds the JavaClass parsed */ @Override public void visitClassContext(ClassContext classContext) { localizableFields.clear(); clsContext = classContext; JavaClass cls = classContext.getJavaClass(); boolean clsIsFinal = cls.isFinal(); Field[] fields = cls.getFields(); for (Field f : fields) { if ((!f.isStatic()) && (f.isPrivate() || (clsIsFinal && f.isProtected()))) { FieldAnnotation fa = new FieldAnnotation(cls.getClassName(), f.getName(), f.getSignature(), false); localizableFields.add(fa); } } if (localizableFields.size() > 0) { super.visitClassContext(classContext); for (FieldAnnotation fa : localizableFields) { bugReporter.reportBug(new BugInstance(this, "FCBL_FIELD_COULD_BE_LOCAL", NORMAL_PRIORITY) .addClass(this) .addField(fa)); } } } /** * overrides the visitor to navigate basic blocks looking for all first usages of fields, removing * those that are read from first. * * @param obj the context object of the currently parsed method */ public void visitMethod(Method obj) { if (localizableFields.size() == 0) return; String methodName = obj.getName(); if ("<clinit>".equals(methodName) || "<init>".equals(methodName)) return; try { cpg = new ConstantPoolGen(getConstantPool()); cfg = clsContext.getCFG(obj); BasicBlock bb = cfg.getEntry(); Set<FieldAnnotation> uncheckedFields = new HashSet<FieldAnnotation>(localizableFields); visitedBlocks.clear(); checkBlock(bb, uncheckedFields); } catch (Exception e) { localizableFields.clear(); } } /** * implements the visitor to do nothing * * @param obj the context object of the currently parsed code attribute */ public void visitCode(Code obj) { } /** * looks in this basic block for the first access to the fields in uncheckedFields. Once found * the item is removed from uncheckedFields, and removed from localizableFields if the access is * a GETFIELD. If any unchecked fields remain, this method is recursively called on all outgoing edges * of this basic block. * * @param bb this basic block * @param uncheckedFields the list of fields to look for */ private void checkBlock(BasicBlock bb, Set<FieldAnnotation> uncheckedFields) { visitedBlocks.set(bb.getId()); InstructionIterator ii = bb.instructionIterator(); while (ii.hasNext()) { InstructionHandle ih = ii.next(); Instruction ins = ih.getInstruction(); if (ins instanceof FieldInstruction) { FieldInstruction fi = (FieldInstruction) ins; FieldAnnotation fa = new FieldAnnotation(getClassName(), fi.getFieldName(cpg), fi.getSignature(cpg), false); uncheckedFields.remove(fa); if (ins instanceof GETFIELD) localizableFields.remove(fa); } } if (uncheckedFields.size() > 0) { Iterator<Edge> oei = cfg.outgoingEdgeIterator(bb); while (oei.hasNext()) { Edge e = oei.next(); BasicBlock cb = e.getTarget(); if (!visitedBlocks.get(cb.getId())) { Set<FieldAnnotation> subCheckedFields = new HashSet<FieldAnnotation>(uncheckedFields); checkBlock(cb, subCheckedFields); if (localizableFields.size() == 0) return; } } } } } |
From: Dave B. <dbr...@us...> - 2006-03-27 05:56:58
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16920/samples Added Files: FCBL_Sample.java Log Message: Initial checkin - new FCBL detector --- NEW FILE: FCBL_Sample.java --- public final class FCBL_Sample { public int foo; private int moo; protected int boo; int hoo; private int fp; public FCBL_Sample() { foo = 0; moo = 1; boo = 2; hoo = 3; fp = 4; } public void test1() { foo = 2; moo = 3; boo = 4; fp = 5; } public void test2() { boo = fp; } } |
From: Dave B. <dbr...@us...> - 2006-03-27 05:56:58
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16920/etc Modified Files: findbugs.xml messages.xml Log Message: Initial checkin - new FCBL detector Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- messages.xml 14 Mar 2006 04:36:29 -0000 1.63 +++ messages.xml 27 Mar 2006 05:56:54 -0000 1.64 @@ -494,6 +494,17 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.FieldCouldBeLocal"> + <Details> + <![CDATA[ + <p>looks for classes that define fields that are used in a locals only fashion, + specifically private fields or protected fields in final classes that are accessed + first in each method with a store vs. a load.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -1006,6 +1017,19 @@ </Details> </BugPattern> + <BugPattern type="FCBL_FIELD_COULD_BE_LOCAL"> + <ShortDescription>class defines fields that are used only as locals</ShortDescription> + <LongDescription>class {0} defines fields that are used only as locals</LongDescription> + <Details> + <![CDATA[ + <p>This class defines fields that are used in a locals only fashion, + specifically private fields or protected fields in final classes that are accessed + first in each method with a store vs. a load. This field could be replaced by one + or more local variables.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -1047,4 +1071,5 @@ <BugCode abbrev="JVR">JDBC Vendor Reliance</BugCode> <BugCode abbrev="PMB">Possible Memory Bloat</BugCode> <BugCode abbrev="LSYC">Local Synchronized Collection</BugCode> + <BugCode abbrev="FCBL">Field Could Be Local</BugCode> </MessageCollection> \ No newline at end of file Index: findbugs.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/findbugs.xml,v retrieving revision 1.69 retrieving revision 1.70 diff -u -d -r1.69 -r1.70 --- findbugs.xml 11 Mar 2006 05:01:35 -0000 1.69 +++ findbugs.xml 27 Mar 2006 05:56:54 -0000 1.70 @@ -171,6 +171,10 @@ speed="fast" reports="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.FieldCouldBeLocal" + speed="fast" + reports="FCBL_FIELD_COULD_BE_LOCAL" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -212,4 +216,5 @@ <BugPattern abbrev="JVR" type="JVR_JDBC_VENDOR_RELIANCE" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="PMB" type="PMB_POSSIBLE_MEMORY_BLOAT" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="LSYC" type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="FCBL" type="FCBL_FIELD_COULD_BE_LOCAL" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2006-03-26 03:43:16
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11950/src/com/mebigfatguy/fbcontrib/detect Modified Files: DateComparison.java Log Message: guard against npes Index: DateComparison.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- DateComparison.java 26 Mar 2006 03:39:25 -0000 1.4 +++ DateComparison.java 26 Mar 2006 03:43:10 -0000 1.5 @@ -172,11 +172,11 @@ case SEEN_LOAD2_2: if (seen == INVOKEVIRTUAL) { String cls = getDottedClassConstantOperand(); - if ((cls.equals("java.util.Date")) || (cls.equals("java.sql.Date"))) { + if (dateClasses.contains(cls)) { String methodName = getNameConstantOperand(); - if (methodName.equals( "equals" ) - || methodName.equals( "after" ) - || methodName.equals( "before" )) { + if ("equals".equals(methodName) + || "after".equals(methodName) + || "before".equals(methodName)) { state = SEEN_CMP_2; } } |
From: Dave B. <dbr...@us...> - 2006-03-26 03:39:29
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9969/src/com/mebigfatguy/fbcontrib/detect Modified Files: DateComparison.java Log Message: guard against npes Index: DateComparison.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- DateComparison.java 26 Mar 2006 03:18:44 -0000 1.3 +++ DateComparison.java 26 Mar 2006 03:39:25 -0000 1.4 @@ -125,9 +125,9 @@ String cls = getDottedClassConstantOperand(); if (dateClasses.contains(cls)) { String methodName = getNameConstantOperand(); - if (methodName.equals( "equals" ) - || methodName.equals( "after" ) - || methodName.equals( "before" )) { + if ("equals".equals(methodName) + || "after".equals(methodName) + || "before".equals(methodName)) { state = SEEN_CMP_1; } } |
From: Dave B. <dbr...@us...> - 2006-03-26 03:25:43
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2632/src/com/mebigfatguy/fbcontrib/detect Modified Files: DubiousListCollection.java Log Message: add finals Index: DubiousListCollection.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- DubiousListCollection.java 26 Feb 2006 03:51:35 -0000 1.15 +++ DubiousListCollection.java 26 Mar 2006 03:25:38 -0000 1.16 @@ -233,7 +233,7 @@ { } - public void addUse(int pc) + public void addUse(final int pc) { setCnt++; if (slAnnotation == null) |
From: Dave B. <dbr...@us...> - 2006-03-26 03:25:43
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2632/src/com/mebigfatguy/fbcontrib/utils Modified Files: RegisterUtils.java Log Message: add finals Index: RegisterUtils.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- RegisterUtils.java 13 Mar 2006 06:47:39 -0000 1.4 +++ RegisterUtils.java 26 Mar 2006 03:25:38 -0000 1.5 @@ -44,7 +44,7 @@ * @param seen the opcode of the store * @return the register stored into */ - public static int getAStoreReg(DismantleBytecode dbc, int seen) { + public static int getAStoreReg(final DismantleBytecode dbc, final int seen) { if (seen == Constants.ASTORE) return dbc.getRegisterOperand(); if ((seen >= Constants.ASTORE_0) && (seen <= Constants.ASTORE_3)) |
From: Dave B. <dbr...@us...> - 2006-03-26 03:18:49
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31129/src/com/mebigfatguy/fbcontrib/detect Modified Files: DateComparison.java Log Message: redundant interface Index: DateComparison.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- DateComparison.java 2 Mar 2006 02:05:46 -0000 1.2 +++ DateComparison.java 26 Mar 2006 03:18:44 -0000 1.3 @@ -27,12 +27,11 @@ import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.StatelessDetector; -import edu.umd.cs.findbugs.visitclass.Constants2; /** * Looks for inefficient comparison of Date objects using two comparisons when one would do. */ -public class DateComparison extends BytecodeScanningDetector implements Constants2, StatelessDetector { +public class DateComparison extends BytecodeScanningDetector implements StatelessDetector { private static final int SEEN_NOTHING = 0; private static final int SEEN_LOAD1_1 = 1; |
From: Dave B. <dbr...@us...> - 2006-03-25 15:48:49
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28489/src/com/mebigfatguy/fbcontrib Modified Files: FBContrib.java Log Message: add title Index: FBContrib.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- FBContrib.java 13 Mar 2006 07:46:51 -0000 1.6 +++ FBContrib.java 25 Mar 2006 15:48:43 -0000 1.7 @@ -28,7 +28,7 @@ * @param args standard command line args */ public static void main(final String[] args) { - JOptionPane.showMessageDialog( null, "To use fb-contrib, copy this jar file into your local FindBugs plugin directory, and use FindBugs as usual.\n\nfb-contrib is a trademark of MeBigFatGuy.com\nFindBugs is a trademark of the University of Maryland"); + JOptionPane.showMessageDialog( null, "To use fb-contrib, copy this jar file into your local FindBugs plugin directory, and use FindBugs as usual.\n\nfb-contrib is a trademark of MeBigFatGuy.com\nFindBugs is a trademark of the University of Maryland", "fb-contrib: copyright 2005-2006", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } } |
From: Dave B. <dbr...@us...> - 2006-03-25 02:19:57
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1772/htdocs Modified Files: index.html Log Message: fix the gizmo Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- index.html 14 Mar 2006 04:36:29 -0000 1.74 +++ index.html 25 Mar 2006 02:19:51 -0000 1.75 @@ -58,9 +58,9 @@ </ul> </div> <hr/> - <img id="v2_4_0_image" src="flip2.gif" onClick="toggleBlock('v2_4_0', 'v_2_4_0_image');" align="top"/> + <img id="v2_4_0_image" src="flip2.gif" onClick="toggleBlock('v2_4_0', 'v2_4_0_image');" align="top"/> Detectors added in v2.4.0<br/> - <div id="cvs" style="display:block;"> + <div id="v2_4_0" style="display:block;"> <ul> <li><b>[DDC] Double Date Compare</b><br/> Looks for methods that compare two dates using .equals and after or before. |
From: Dave B. <dbr...@us...> - 2006-03-22 06:51:49
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12363/src/com/mebigfatguy/fbcontrib/detect Modified Files: AbstractOverriddenMethod.java Log Message: try to report source lines, and short circuit once you find a bug Index: AbstractOverriddenMethod.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- AbstractOverriddenMethod.java 11 Mar 2006 06:35:25 -0000 1.3 +++ AbstractOverriddenMethod.java 22 Mar 2006 06:51:46 -0000 1.4 @@ -18,6 +18,7 @@ */ package com.mebigfatguy.fbcontrib.detect; +import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; @@ -33,6 +34,7 @@ */ public class AbstractOverriddenMethod extends PreorderVisitor implements Detector, StatelessDetector { private BugReporter bugReporter; + private ClassContext clsContext; private JavaClass[] superClasses; /** @@ -59,6 +61,7 @@ */ public void visitClassContext(ClassContext classContext) { try { + clsContext = classContext; JavaClass cls = classContext.getJavaClass(); superClasses = cls.getSuperClasses(); cls.accept(this); @@ -79,20 +82,25 @@ String methodName = obj.getName(); String methodSig = obj.getSignature(); - for (JavaClass cls : superClasses) { + outer: for (JavaClass cls : superClasses) { Method[] methods = cls.getMethods(); for (Method m : methods) { if (m.isPrivate() || m.isAbstract()) continue; - if (methodName.equals(m.getName()) && methodSig.equals(m.getSignature())) { - bugReporter.reportBug(new BugInstance(this, "AOM_ABSTRACT_OVERRIDDEN_METHOD", NORMAL_PRIORITY) + BugInstance bug = new BugInstance(this, "AOM_ABSTRACT_OVERRIDDEN_METHOD", NORMAL_PRIORITY) .addClass(this) - .addMethod(this)); + .addMethod(this); + + Code code = obj.getCode(); + if (code != null) + bug.addSourceLineRange(clsContext, this, 0, code.getLength()-1); + bugReporter.reportBug(bug); + + break outer; } } - } - + } } /** |
From: Dave B. <dbr...@us...> - 2006-03-22 05:07:27
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29941/src/com/mebigfatguy/fbcontrib/detect Modified Files: LocalSynchronizedCollection.java Log Message: if a collection is stored in an array, don't report LSYC Index: LocalSynchronizedCollection.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- LocalSynchronizedCollection.java 13 Mar 2006 06:47:39 -0000 1.10 +++ LocalSynchronizedCollection.java 22 Mar 2006 05:07:18 -0000 1.11 @@ -193,6 +193,11 @@ OpcodeStack.Item item = stack.getStackItem(0); syncRegs.remove(item.getUserValue()); } + } else if (seen == AASTORE) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + syncRegs.remove(item.getUserValue()); + } } } |
From: Dave B. <dbr...@us...> - 2006-03-14 04:36:32
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26682/htdocs Modified Files: index.html Log Message: get ready for v2.4.0 Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.73 retrieving revision 1.74 diff -u -d -r1.73 -r1.74 --- index.html 11 Mar 2006 14:31:26 -0000 1.73 +++ index.html 14 Mar 2006 04:36:29 -0000 1.74 @@ -46,15 +46,22 @@ <a href="javadoc/index.html">JavaDoc</a> <hr/> - <img id="cvs_image" src="flip2.gif" onClick="toggleBlock('cvs', 'cvs_image');" align="top"/> + <img id="cvs_image" src="flip1.gif" onClick="toggleBlock('cvs', 'cvs_image');" align="top"/> Detectors added in CVS<br/> Note: these detectors are still in testing<br/> - <div id="cvs" style="display:block;"> + <div id="cvs" style="display:none;"> <ul> <li><b>[BSB] Bloated Synchronized Block</b><br/> Looks for methods that implement synchronized blocks that appear to contain some code at the beginning that does not need to be synchronized. Moving these lines out of the synchronized block should help multithreaded performance.</li> + </ul> + </div> + <hr/> + <img id="v2_4_0_image" src="flip2.gif" onClick="toggleBlock('v2_4_0', 'v_2_4_0_image');" align="top"/> + Detectors added in v2.4.0<br/> + <div id="cvs" style="display:block;"> + <ul> <li><b>[DDC] Double Date Compare</b><br/> Looks for methods that compare two dates using .equals and after or before. This combination of two comparisons can be accomplished with just one comparison.</li> @@ -74,7 +81,7 @@ <hr/> <img id="v2_2_0_image" src="flip1.gif" onClick="toggleBlock('v2_2_0', 'v2_2_0_image');" align="top"/> - Detectors added in 2.2.0<br/> + Detectors added in v2.2.0<br/> Note: fb-contrib v2.2.0 requires FindBugs™ v0.95 or later<br/> <div id="v2_2_0" style="display:none;"> <ul> |
From: Dave B. <dbr...@us...> - 2006-03-14 04:36:32
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26682 Modified Files: build.xml Log Message: get ready for v2.4.0 Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- build.xml 5 Mar 2006 04:37:13 -0000 1.32 +++ build.xml 14 Mar 2006 04:36:28 -0000 1.33 @@ -18,7 +18,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="2.3.0"/> + <property name="fb-contrib.version" value="2.4.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |
From: Dave B. <dbr...@us...> - 2006-03-14 04:36:32
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26682/etc Modified Files: messages.xml Log Message: get ready for v2.4.0 Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.62 retrieving revision 1.63 diff -u -d -r1.62 -r1.63 --- messages.xml 11 Mar 2006 05:01:35 -0000 1.62 +++ messages.xml 14 Mar 2006 04:36:29 -0000 1.63 @@ -103,6 +103,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy"> <Details> <![CDATA[ + <p><b>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</b></p> <p> Looks for methods that use a high percentage of methods from another class over it's own methods. When this is the case, it is often better to implement this method in that other class, by refactoring the class to accept parameters it needs from the source class. @@ -586,6 +587,7 @@ <LongDescription>method {1} excessively uses methods of another class</LongDescription> <Details> <![CDATA[ + <p><b>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</b></p> <p>This method makes extensive use of methods from another class over methods of it's own class. Typically this means that the functionality that is accomplished by this method most likely belongs with the class that is being used so liberally. Consider refactoring this |
From: Dave B. <dbr...@us...> - 2006-03-13 07:51:00
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24430/src/com/mebigfatguy/fbcontrib/detect Modified Files: UnrelatedCollectionContents.java Log Message: simple cleanups Index: UnrelatedCollectionContents.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- UnrelatedCollectionContents.java 13 Mar 2006 06:13:42 -0000 1.16 +++ UnrelatedCollectionContents.java 13 Mar 2006 07:50:54 -0000 1.17 @@ -163,15 +163,13 @@ commonSupers = new HashSet<String>(); localCollections.put(new Integer(reg), commonSupers); addNewItem(commonSupers, addItm); - Integer scopeEnd = RegisterUtils.getLocalVariableEndRange(getMethod().getLocalVariableTable(), reg, getNextPC()); - if (scopeEnd != null) { - Set<Integer> regs = localScopeEnds.get(scopeEnd); - if (regs == null) { - regs = new HashSet<Integer>(); - localScopeEnds.put(scopeEnd, regs); - } - regs.add(new Integer(reg)); - } + Integer scopeEnd = new Integer(RegisterUtils.getLocalVariableEndRange(getMethod().getLocalVariableTable(), reg, getNextPC())); + Set<Integer> regs = localScopeEnds.get(scopeEnd); + if (regs == null) { + regs = new HashSet<Integer>(); + localScopeEnds.put(scopeEnd, regs); + } + regs.add(new Integer(reg)); } } else { FieldAnnotation fa = colItm.getField(); |
From: Dave B. <dbr...@us...> - 2006-03-13 07:48:35
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23207/src/com/mebigfatguy/fbcontrib/detect Modified Files: AbstractClassEmptyMethods.java Log Message: javadoc Index: AbstractClassEmptyMethods.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- AbstractClassEmptyMethods.java 4 Jan 2006 02:40:42 -0000 1.5 +++ AbstractClassEmptyMethods.java 13 Mar 2006 07:48:32 -0000 1.6 @@ -64,9 +64,10 @@ } /** - * clone this detector so that it can be a StatelessDetector + * clone this detector so that it can be a StatelessDetector. * * @return a clone of this object + * @throws CloneNotSupportedException never */ @Override public Object clone() throws CloneNotSupportedException { @@ -74,7 +75,7 @@ } /** - * overrides the visitor to check for abstract classes + * overrides the visitor to check for abstract classes. * * @param classContext the context object that holds the JavaClass being parsed */ @@ -86,9 +87,9 @@ } /** - * overrides the visitor to grab the method name and reset the state + * overrides the visitor to grab the method name and reset the state. * - * obj the method being parsed + * @param obj the method being parsed */ @Override public void visitMethod(Method obj) { @@ -97,7 +98,7 @@ } /** - * overrides the visitor to filter out constructors + * overrides the visitor to filter out constructors. * * @param obj the code to parse */ @@ -110,7 +111,7 @@ } /** - * overrides the visitor to look for empty methods or simple exception throwers + * overrides the visitor to look for empty methods or simple exception throwers. * * @param seen the opcode currently being parsed */ |
From: Dave B. <dbr...@us...> - 2006-03-13 07:46:54
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22446/src/com/mebigfatguy/fbcontrib Modified Files: FBContrib.java Log Message: javadoc Index: FBContrib.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- FBContrib.java 4 Jan 2006 02:40:41 -0000 1.5 +++ FBContrib.java 13 Mar 2006 07:46:51 -0000 1.6 @@ -22,7 +22,12 @@ public class FBContrib { - public static void main(final String[] args) { + /** + * shows the simple help + * + * @param args standard command line args + */ + public static void main(final String[] args) { JOptionPane.showMessageDialog( null, "To use fb-contrib, copy this jar file into your local FindBugs plugin directory, and use FindBugs as usual.\n\nfb-contrib is a trademark of MeBigFatGuy.com\nFindBugs is a trademark of the University of Maryland"); System.exit(0); } |
From: Dave B. <dbr...@us...> - 2006-03-13 07:05:54
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5120/src/com/mebigfatguy/fbcontrib/utils Added Files: package.html Log Message: javadoc --- NEW FILE: package.html --- <html> <body> provides general utilities to support various detectors. </body> </html> |
From: Dave B. <dbr...@us...> - 2006-03-13 06:47:42
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30845/src/com/mebigfatguy/fbcontrib/utils Modified Files: RegisterUtils.java Log Message: more more impl to RegisterUtils Index: RegisterUtils.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- RegisterUtils.java 13 Mar 2006 06:13:42 -0000 1.3 +++ RegisterUtils.java 13 Mar 2006 06:47:39 -0000 1.4 @@ -21,6 +21,8 @@ import org.apache.bcel.Constants; import org.apache.bcel.classfile.LocalVariable; import org.apache.bcel.classfile.LocalVariableTable; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; import edu.umd.cs.findbugs.visitclass.DismantleBytecode; @@ -45,7 +47,7 @@ public static int getAStoreReg(DismantleBytecode dbc, int seen) { if (seen == Constants.ASTORE) return dbc.getRegisterOperand(); - if ((seen >= Constants.ALOAD_0) && (seen <= Constants.ALOAD_3)) + if ((seen >= Constants.ASTORE_0) && (seen <= Constants.ASTORE_3)) return seen - Constants.ASTORE_0; return -1; } @@ -132,4 +134,24 @@ } return endRange; } + + /** + * gets the set of registers used for parameters + * + * @param obj the context object for the method to get the parameters of + */ + public static int[] getParameterRegisters(Method obj) { + Type[] argTypes = obj.getArgumentTypes(); + int[] regs = new int[argTypes.length]; + + int curReg = obj.isStatic() ? 0 : 1; + for (int t = 0; t < argTypes.length; t++) { + String sig = argTypes[t].getSignature(); + regs[t] = curReg; + if ("J".equals(sig) || "D".equals(sig)) + curReg++; + curReg++; + } + return regs; + } } |