fb-contrib-commit Mailing List for fb-contrib (Page 61)
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-11 03:35:49
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25858/src/com/mebigfatguy/fbcontrib/detect Modified Files: PossibleMemoryBloat.java Log Message: add copyright Index: PossibleMemoryBloat.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- PossibleMemoryBloat.java 8 Mar 2006 05:01:57 -0000 1.6 +++ PossibleMemoryBloat.java 11 Mar 2006 03:35:46 -0000 1.7 @@ -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.HashMap; |
From: Dave B. <dbr...@us...> - 2006-03-08 05:02:04
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13624/src/com/mebigfatguy/fbcontrib/detect Modified Files: PossibleMemoryBloat.java Log Message: fix javadoc Index: PossibleMemoryBloat.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- PossibleMemoryBloat.java 8 Mar 2006 04:45:19 -0000 1.5 +++ PossibleMemoryBloat.java 8 Mar 2006 05:01:57 -0000 1.6 @@ -101,7 +101,7 @@ * collects static fields that are likely bloatable objects and if found * allows the visitor to proceed, at the end report all leftover fields * - * @param obj the class context object of the currently parsed java class + * @param classContext the class context object of the currently parsed java class */ @Override public void visitClassContext(ClassContext classContext) { |
From: Dave B. <dbr...@us...> - 2006-03-08 04:45:25
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5938/etc Modified Files: messages.xml Log Message: more wording Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- messages.xml 8 Mar 2006 04:40:21 -0000 1.60 +++ messages.xml 8 Mar 2006 04:45:16 -0000 1.61 @@ -475,7 +475,7 @@ <![CDATA[ <p>looks for classes that maintain collections or StringBuffer/StringBuilders in static member variables, and that do not appear to provide a way to clear or remove - items from these members. Such member variables are likely causes of memory bloat.</p> + items from these members. Such class fields are likely causes of memory bloat.</p> <p>It is a fast detector</p> ]]> </Details> |
From: Dave B. <dbr...@us...> - 2006-03-08 04:45:24
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5938/src/com/mebigfatguy/fbcontrib/detect Modified Files: PossibleMemoryBloat.java Log Message: more wording Index: PossibleMemoryBloat.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- PossibleMemoryBloat.java 8 Mar 2006 04:40:55 -0000 1.4 +++ PossibleMemoryBloat.java 8 Mar 2006 04:45:19 -0000 1.5 @@ -23,7 +23,7 @@ /** * looks for classes that maintain collections or StringBuffer/StringBuilders in static member * variables, and that do not appear to provide a way to clear or remove items from these members. - * Such member variables are likely causes of memory bloat. + * Such class fields are likely causes of memory bloat. * */ public class PossibleMemoryBloat extends BytecodeScanningDetector implements StatelessDetector { |
From: Dave B. <dbr...@us...> - 2006-03-08 04:45:23
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5938/htdocs Modified Files: index.html Log Message: more wording Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.70 retrieving revision 1.71 diff -u -d -r1.70 -r1.71 --- index.html 7 Mar 2006 06:28:33 -0000 1.70 +++ index.html 8 Mar 2006 04:45:17 -0000 1.71 @@ -62,9 +62,9 @@ Looks for uses of jdbc vendor specific classes and methods making the database access code non portable.</li> <li><b>[PMB] Possible Memory Bloat</b><br/> - Looks for classes that maintain collections or StringBuffer/StringBuilder in static member + Looks for classes that maintain collections or StringBuffer/StringBuilders in static member variables, and that do not appear to provide a way to clear or remove items from these members. - Such member variables are likely causes of memory bloat.</li> + Such class fields are likely causes of memory bloat.</li> </ul> </div> |
From: Dave B. <dbr...@us...> - 2006-03-08 04:41:04
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4127/src/com/mebigfatguy/fbcontrib/detect Modified Files: PossibleMemoryBloat.java Log Message: javadoc Index: PossibleMemoryBloat.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- PossibleMemoryBloat.java 8 Mar 2006 04:38:31 -0000 1.3 +++ PossibleMemoryBloat.java 8 Mar 2006 04:40:55 -0000 1.4 @@ -21,7 +21,7 @@ import edu.umd.cs.findbugs.ba.ClassContext; /** - * looks for classes that maintain collections or StringBuffer/StringBuilder in static member + * looks for classes that maintain collections or StringBuffer/StringBuilders in static member * variables, and that do not appear to provide a way to clear or remove items from these members. * Such member variables are likely causes of memory bloat. * |
From: Dave B. <dbr...@us...> - 2006-03-08 04:40:25
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3867/etc Modified Files: messages.xml Log Message: wow i'm struggling with descriptions Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- messages.xml 7 Mar 2006 06:28:33 -0000 1.59 +++ messages.xml 8 Mar 2006 04:40:21 -0000 1.60 @@ -473,7 +473,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleMemoryBloat"> <Details> <![CDATA[ - <p>looks for classes that maintain collections or StringBuffer/StringBuilder in + <p>looks for classes that maintain collections or StringBuffer/StringBuilders in static member variables, and that do not appear to provide a way to clear or remove items from these members. Such member variables are likely causes of memory bloat.</p> <p>It is a fast detector</p> @@ -969,8 +969,8 @@ </BugPattern> <BugPattern type="PMB_POSSIBLE_MEMORY_BLOAT"> - <ShortDescription>class defines static field that appears to a memory bloat</ShortDescription> - <LongDescription>class {0} defines static field that appears to a memory bloat</LongDescription> + <ShortDescription>class defines static field that appears to allow memory bloat</ShortDescription> + <LongDescription>class {0} defines static field that appears to allow memory bloat</LongDescription> <Details> <![CDATA[ <p>This class defines static fields that are collections or StringBuffers that do not |
From: Dave B. <dbr...@us...> - 2006-03-08 04:38:35
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3019/src/com/mebigfatguy/fbcontrib/detect Modified Files: PossibleMemoryBloat.java Log Message: don't report static collections that have no 'increasing' methods eg. .add in methods other then constructors of static initializers. Also report the line number of this first increasing method. Index: PossibleMemoryBloat.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- PossibleMemoryBloat.java 7 Mar 2006 06:28:33 -0000 1.2 +++ PossibleMemoryBloat.java 8 Mar 2006 04:38:31 -0000 1.3 @@ -1,11 +1,14 @@ package com.mebigfatguy.fbcontrib.detect; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; 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.Type; import edu.umd.cs.findbugs.BugInstance; @@ -13,6 +16,7 @@ import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.FieldAnnotation; import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.SourceLineAnnotation; import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; @@ -45,18 +49,35 @@ bloatableSigs.add("Ljava/util/TreeSet;"); bloatableSigs.add("Ljava/util/Vector;"); } - private static final Set<String> clearingMethods = new HashSet<String>(); + private static final Set<String> decreasingMethods = new HashSet<String>(); static { - clearingMethods.add("clear"); - clearingMethods.add("delete"); - clearingMethods.add("deleteCharAt"); - clearingMethods.add("pop"); - clearingMethods.add("remove"); - clearingMethods.add("setLength"); + decreasingMethods.add("clear"); + decreasingMethods.add("delete"); + decreasingMethods.add("deleteCharAt"); + decreasingMethods.add("pop"); + decreasingMethods.add("remove"); + decreasingMethods.add("removeAll"); + decreasingMethods.add("removeAllElements"); + decreasingMethods.add("removeElementAt"); + decreasingMethods.add("removeRange"); + decreasingMethods.add("setLength"); + } + + private static final Set<String> increasingMethods = new HashSet<String>(); + static { + increasingMethods.add("add"); + increasingMethods.add("addAll"); + increasingMethods.add("addElement"); + increasingMethods.add("addFirst"); + increasingMethods.add("addLast"); + increasingMethods.add("append"); + increasingMethods.add("insertElementAt"); + increasingMethods.add("put"); } private BugReporter bugReporter; - private Set<FieldAnnotation> bloatableFields = new HashSet<FieldAnnotation>(); + private Map<FieldAnnotation, SourceLineAnnotation> bloatableFields = new HashMap<FieldAnnotation, SourceLineAnnotation>(); private OpcodeStack stack = new OpcodeStack(); + private String methodName; /** * constructs a PMB detector given the reporter to report bugs on @@ -91,7 +112,7 @@ if (f.isStatic()) { String sig = f.getSignature(); if (bloatableSigs.contains(sig)) { - bloatableFields.add(FieldAnnotation.fromBCELField(cls.getClassName(), f)); + bloatableFields.put(FieldAnnotation.fromBCELField(cls.getClassName(), f), null); } } } @@ -99,15 +120,29 @@ if (bloatableFields.size() > 0) { super.visitClassContext(classContext); - for (FieldAnnotation fa : bloatableFields) { - bugReporter.reportBug(new BugInstance(this, "PMB_POSSIBLE_MEMORY_BLOAT", NORMAL_PRIORITY) - .addClass(this) - .addField(fa)); + for (Map.Entry<FieldAnnotation, SourceLineAnnotation> entry : bloatableFields.entrySet()) { + SourceLineAnnotation sla = entry.getValue(); + if (sla != null) { + bugReporter.reportBug(new BugInstance(this, "PMB_POSSIBLE_MEMORY_BLOAT", NORMAL_PRIORITY) + .addClass(this) + .addSourceLine(sla) + .addField(entry.getKey())); + } } } } /** + * implements the visitor to collect the method name + * + * @param obj the context object of the currently parsed method + */ + @Override + public void visitMethod(Method obj) { + methodName = obj.getName(); + } + + /** * implements the visitor to reset the opcode stack * * @param obj the context object of the currently parsed code block @@ -115,6 +150,11 @@ @Override public void visitCode(Code obj) { stack.resetForMethodEntry(this); + + if ("<clinit>".equals(methodName) + || "<init>".equals(methodName)) + return; + if (bloatableFields.size() > 0) super.visitCode(obj); } @@ -141,10 +181,15 @@ OpcodeStack.Item itm = stack.getStackItem(argCount); FieldAnnotation fa = itm.getField(); if (fa != null) { - if (bloatableFields.contains(fa)) { + if (bloatableFields.containsKey(fa)) { String methodName = getNameConstantOperand(); - if (clearingMethods.contains(methodName)) { + if (decreasingMethods.contains(methodName)) { bloatableFields.remove(fa); + } else if (increasingMethods.contains(methodName)) { + if (bloatableFields.get(fa) == null) { + SourceLineAnnotation sla = SourceLineAnnotation.fromVisitedInstruction(this); + bloatableFields.put(fa, sla); + } } } } |
From: Dave B. <dbr...@us...> - 2006-03-07 06:28:37
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29061/etc Modified Files: messages.xml Log Message: me speaky english very goodly Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- messages.xml 7 Mar 2006 06:17:24 -0000 1.58 +++ messages.xml 7 Mar 2006 06:28:33 -0000 1.59 @@ -473,9 +473,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleMemoryBloat"> <Details> <![CDATA[ - <p>looks for classes that maintain collections or StringBuffer/StringBuilders in + <p>looks for classes that maintain collections or StringBuffer/StringBuilder in static member variables, and that do not appear to provide a way to clear or remove - items from this members. Such member variables are likely causes of memory bloat.</p> + items from these members. Such member variables are likely causes of memory bloat.</p> <p>It is a fast detector</p> ]]> </Details> |
From: Dave B. <dbr...@us...> - 2006-03-07 06:28:36
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29061/htdocs Modified Files: index.html Log Message: me speaky english very goodly Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.69 retrieving revision 1.70 diff -u -d -r1.69 -r1.70 --- index.html 7 Mar 2006 06:18:50 -0000 1.69 +++ index.html 7 Mar 2006 06:28:33 -0000 1.70 @@ -62,8 +62,8 @@ Looks for uses of jdbc vendor specific classes and methods making the database access code non portable.</li> <li><b>[PMB] Possible Memory Bloat</b><br/> - Looks for classes that maintain collections or StringBuffer/StringBuilders in static member - variables, and that do not appear to provide a way to clear or remove items from this members. + Looks for classes that maintain collections or StringBuffer/StringBuilder in static member + variables, and that do not appear to provide a way to clear or remove items from these members. Such member variables are likely causes of memory bloat.</li> </ul> </div> |
From: Dave B. <dbr...@us...> - 2006-03-07 06:28:36
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29061/src/com/mebigfatguy/fbcontrib/detect Modified Files: PossibleMemoryBloat.java Log Message: me speaky english very goodly Index: PossibleMemoryBloat.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PossibleMemoryBloat.java 7 Mar 2006 06:17:24 -0000 1.1 +++ PossibleMemoryBloat.java 7 Mar 2006 06:28:33 -0000 1.2 @@ -17,8 +17,8 @@ import edu.umd.cs.findbugs.ba.ClassContext; /** - * looks for classes that maintain collections or StringBuffer/StringBuilders in static member - * variables, and that do not appear to provide a way to clear or remove items from this members. + * looks for classes that maintain collections or StringBuffer/StringBuilder in static member + * variables, and that do not appear to provide a way to clear or remove items from these members. * Such member variables are likely causes of memory bloat. * */ |
From: Dave B. <dbr...@us...> - 2006-03-07 06:18:53
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24666/htdocs Modified Files: index.html Log Message: doc PMB Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.68 retrieving revision 1.69 diff -u -d -r1.68 -r1.69 --- index.html 6 Mar 2006 04:18:19 -0000 1.68 +++ index.html 7 Mar 2006 06:18:50 -0000 1.69 @@ -61,6 +61,10 @@ <li><b>[JVR] JDBC Vendor Reliance</b><br/> Looks for uses of jdbc vendor specific classes and methods making the database access code non portable.</li> + <li><b>[PMB] Possible Memory Bloat</b><br/> + Looks for classes that maintain collections or StringBuffer/StringBuilders in static member + variables, and that do not appear to provide a way to clear or remove items from this members. + Such member variables are likely causes of memory bloat.</li> </ul> </div> |
From: Dave B. <dbr...@us...> - 2006-03-07 06:17:28
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24111/src/com/mebigfatguy/fbcontrib/detect Added Files: PossibleMemoryBloat.java Log Message: initial checkin - new PMB detector --- NEW FILE: PossibleMemoryBloat.java --- package com.mebigfatguy.fbcontrib.detect; import java.util.HashSet; 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.generic.Type; 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.OpcodeStack; import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; /** * looks for classes that maintain collections or StringBuffer/StringBuilders in static member * variables, and that do not appear to provide a way to clear or remove items from this members. * Such member variables are likely causes of memory bloat. * */ public class PossibleMemoryBloat extends BytecodeScanningDetector implements StatelessDetector { private static final Set<String> bloatableSigs = new HashSet<String>(); static { bloatableSigs.add("Ljava/util/ArrayList;"); bloatableSigs.add("Ljava/util/Collection;"); bloatableSigs.add("Ljava/util/HashMap;"); bloatableSigs.add("Ljava/util/HashSet;"); bloatableSigs.add("Ljava/util/Hashtable;"); bloatableSigs.add("Ljava/util/IdentityHashMap;"); bloatableSigs.add("Ljava/util/LinkedHashMap;"); bloatableSigs.add("Ljava/util/LinkedList;"); bloatableSigs.add("Ljava/util/List;"); bloatableSigs.add("Ljava/util/Map;"); bloatableSigs.add("Ljava/util/Set;"); bloatableSigs.add("Ljava/util/SortedSet;"); bloatableSigs.add("Ljava/util/SortedMap;"); bloatableSigs.add("Ljava/util/Stack;"); bloatableSigs.add("Ljava/lang/StringBuffer;"); bloatableSigs.add("Ljava/lang/StringBuilder;"); bloatableSigs.add("Ljava/util/TreeMap;"); bloatableSigs.add("Ljava/util/TreeSet;"); bloatableSigs.add("Ljava/util/Vector;"); } private static final Set<String> clearingMethods = new HashSet<String>(); static { clearingMethods.add("clear"); clearingMethods.add("delete"); clearingMethods.add("deleteCharAt"); clearingMethods.add("pop"); clearingMethods.add("remove"); clearingMethods.add("setLength"); } private BugReporter bugReporter; private Set<FieldAnnotation> bloatableFields = new HashSet<FieldAnnotation>(); private OpcodeStack stack = new OpcodeStack(); /** * constructs a PMB detector given the reporter to report bugs on * @param bugReporter the sync of bug reports */ public PossibleMemoryBloat(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(); } /** * collects static fields that are likely bloatable objects and if found * allows the visitor to proceed, at the end report all leftover fields * * @param obj the class context object of the currently parsed java class */ @Override public void visitClassContext(ClassContext classContext) { bloatableFields.clear(); JavaClass cls = classContext.getJavaClass(); Field[] fields = cls.getFields(); for (Field f : fields) { if (f.isStatic()) { String sig = f.getSignature(); if (bloatableSigs.contains(sig)) { bloatableFields.add(FieldAnnotation.fromBCELField(cls.getClassName(), f)); } } } if (bloatableFields.size() > 0) { super.visitClassContext(classContext); for (FieldAnnotation fa : bloatableFields) { bugReporter.reportBug(new BugInstance(this, "PMB_POSSIBLE_MEMORY_BLOAT", NORMAL_PRIORITY) .addClass(this) .addField(fa)); } } } /** * implements the visitor to reset the opcode stack * * @param obj the context object of the currently parsed code block */ @Override public void visitCode(Code obj) { stack.resetForMethodEntry(this); if (bloatableFields.size() > 0) super.visitCode(obj); } /** * implements the visitor to look for methods that empty a bloatable field * if found, remove these fields from the current list * * @param obj the context object of the currently parsed instruction */ @Override public void sawOpcode(int seen) { try { stack.mergeJumps(this); if (bloatableFields.size() == 0) return; if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE)) { String sig = getSigConstantOperand(); int argCount = Type.getArgumentTypes(sig).length; if (stack.getStackDepth() > argCount) { OpcodeStack.Item itm = stack.getStackItem(argCount); FieldAnnotation fa = itm.getField(); if (fa != null) { if (bloatableFields.contains(fa)) { String methodName = getNameConstantOperand(); if (clearingMethods.contains(methodName)) { bloatableFields.remove(fa); } } } } } } finally { stack.sawOpcode(this, seen); } } } |
From: Dave B. <dbr...@us...> - 2006-03-07 06:17:27
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24111/samples Added Files: PMB_Sample.java Log Message: initial checkin - new PMB detector --- NEW FILE: PMB_Sample.java --- import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; public class PMB_Sample { private static Set<String> bl_data = new HashSet<String>(); private static List<String> data = new ArrayList<String>(); public void add(String s) { bl_data.add(s); data.add(s); } public void remove(String s) { data.remove(s); } } |
From: Dave B. <dbr...@us...> - 2006-03-07 06:17:27
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24111/etc Modified Files: findbugs.xml messages.xml Log Message: initial checkin - new PMB detector Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- messages.xml 6 Mar 2006 04:16:37 -0000 1.57 +++ messages.xml 7 Mar 2006 06:17:24 -0000 1.58 @@ -470,6 +470,17 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleMemoryBloat"> + <Details> + <![CDATA[ + <p>looks for classes that maintain collections or StringBuffer/StringBuilders in + static member variables, and that do not appear to provide a way to clear or remove + items from this members. Such member variables are likely causes of memory bloat.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -957,6 +968,18 @@ </Details> </BugPattern> + <BugPattern type="PMB_POSSIBLE_MEMORY_BLOAT"> + <ShortDescription>class defines static field that appears to a memory bloat</ShortDescription> + <LongDescription>class {0} defines static field that appears to a memory bloat</LongDescription> + <Details> + <![CDATA[ + <p>This class defines static fields that are collections or StringBuffers that do not + appear to have any way to clear or reduce their size. This is a potential cause of + memory bloat.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -996,4 +1019,5 @@ <BugCode abbrev="DDC">Double Date comparison</BugCode> <BugCode abbrev="SWCO">Suspicious Wait on Concurrent Object</BugCode> <BugCode abbrev="JVR">JDBC Vendor Reliance</BugCode> + <BugCode abbrev="PMB">Possible Memory Bloat</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.67 retrieving revision 1.68 diff -u -d -r1.67 -r1.68 --- findbugs.xml 6 Mar 2006 04:16:36 -0000 1.67 +++ findbugs.xml 7 Mar 2006 06:17:24 -0000 1.68 @@ -163,6 +163,10 @@ speed="moderate" reports="JVR_JDBC_VENDOR_RELIANCE" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleMemoryBloat" + speed="fast" + reports="PMB_POSSIBLE_MEMORY_BLOAT" /> + <!-- BugPattern --> @@ -203,4 +207,5 @@ <BugPattern abbrev="DDC" type="DDC_DOUBLE_DATE_COMPARISON" category="PERFORMANCE" experimental="true" /> <BugPattern abbrev="SWCO" type="SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="JVR" type="JVR_JDBC_VENDOR_RELIANCE" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="PMB" type="PMB_POSSIBLE_MEMORY_BLOAT" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2006-03-07 04:58:45
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20310/src/com/mebigfatguy/fbcontrib/detect Modified Files: JDBCVendorReliance.java Log Message: a variable isn't only available AFTER the store Index: JDBCVendorReliance.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- JDBCVendorReliance.java 7 Mar 2006 03:33:11 -0000 1.2 +++ JDBCVendorReliance.java 7 Mar 2006 04:58:42 -0000 1.3 @@ -58,7 +58,7 @@ for (Type arg : argTypes) { String sig = arg.getSignature(); if (isJDBCClass(sig)) - jdbcLocals.put(new Integer(reg), new Integer(getLocalVariableEndRange(reg, 1))); + jdbcLocals.put(new Integer(reg), new Integer(getLocalVariableEndRange(reg, 0))); reg += (sig.equals("L") || sig.equals("D")) ? 2 : 1; } @@ -110,7 +110,7 @@ OpcodeStack.Item itm = stack.getStackItem(0); if (itm.getUserValue() != null) { int reg = getAStoreReg(seen); - jdbcLocals.put(new Integer(reg), new Integer(getLocalVariableEndRange(reg, getPC()))); + jdbcLocals.put(new Integer(reg), new Integer(getLocalVariableEndRange(reg, getNextPC()))); } } |
From: Dave B. <dbr...@us...> - 2006-03-07 03:33:14
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15253/src/com/mebigfatguy/fbcontrib/detect Modified Files: JDBCVendorReliance.java Log Message: centralize checking of jdbc class, and respect local variable ranges Index: JDBCVendorReliance.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- JDBCVendorReliance.java 6 Mar 2006 04:16:37 -0000 1.1 +++ JDBCVendorReliance.java 7 Mar 2006 03:33:11 -0000 1.2 @@ -1,8 +1,11 @@ package com.mebigfatguy.fbcontrib.detect; -import java.util.HashSet; -import java.util.Set; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import org.apache.bcel.classfile.LocalVariable; +import org.apache.bcel.classfile.LocalVariableTable; import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.Type; @@ -20,7 +23,7 @@ private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); - private Set<Integer> jdbcLocals = new HashSet<Integer>(); + private Map<Integer, Integer> jdbcLocals = new HashMap<Integer, Integer>(); /** * constructs a JVR detector given the reporter to report bugs on @@ -54,10 +57,8 @@ int reg = obj.isStatic() ? 0 : 1; for (Type arg : argTypes) { String sig = arg.getSignature(); - if (sig.startsWith("Ljavax/sql/") - || sig.startsWith("Ljava/sql/")) { - jdbcLocals.add(new Integer(reg)); - } + if (isJDBCClass(sig)) + jdbcLocals.put(new Integer(reg), new Integer(getLocalVariableEndRange(reg, 1))); reg += (sig.equals("L") || sig.equals("D")) ? 2 : 1; } @@ -68,11 +69,19 @@ try { stack.mergeJumps(this); + int curPC = getPC(); + Iterator<Integer> it = jdbcLocals.values().iterator(); + while (it.hasNext()) { + Integer endPCRange = it.next(); + if (endPCRange.intValue() < curPC) { + it.remove(); + } + } + if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE)) { String clsName = getClassConstantOperand(); - if (!clsName.startsWith("javax/sql/") - && !clsName.startsWith("java/sql")) { + if (!isJDBCClass(clsName)) { int parmCnt = Type.getArgumentTypes(getSigConstantOperand()).length; if (stack.getStackDepth() > parmCnt) { OpcodeStack.Item itm = stack.getStackItem(parmCnt); @@ -89,28 +98,25 @@ if (seen == INVOKEINTERFACE) { String infName = getClassConstantOperand(); - if (infName.startsWith("javax/sql/") - || infName.startsWith("java/sql/")) { + if (isJDBCClass(infName)) { String sig = getSigConstantOperand(); Type retType = Type.getReturnType(sig); infName = retType.getSignature(); - if (infName.startsWith("Ljavax/sql/") - || infName.startsWith("Ljava/sql/")) { + if (isJDBCClass(infName)) tosIsJDBC = true; - } } } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); if (itm.getUserValue() != null) { int reg = getAStoreReg(seen); - jdbcLocals.add(new Integer(reg)); + jdbcLocals.put(new Integer(reg), new Integer(getLocalVariableEndRange(reg, getPC()))); } } } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { int reg = getALoadReg(seen); - if (jdbcLocals.contains(new Integer(reg))) + if (jdbcLocals.containsKey(new Integer(reg))) tosIsJDBC = true; } } finally { @@ -147,4 +153,43 @@ return getRegisterOperand(); return seen - ALOAD_0; } + + /** + * returns the end pc of the visible range of this register at this pc + * + * @param reg the register to examine + * @param curPC the pc of the current instruction + * @return the endpc + */ + private int getLocalVariableEndRange(int reg, int curPC) { + int endRange = Integer.MAX_VALUE; + LocalVariableTable lvt = this.getMethod().getLocalVariableTable(); + if (lvt != null) { + LocalVariable lv = lvt.getLocalVariable(reg, curPC); + if (lv != null) + endRange = lv.getStartPC() + lv.getLength(); + } + return endRange; + } + + /** + * returns whether the class is a jdbc class + * + * @param a class name or signature of a class + * + * @return if the class name is a jdbc one + */ + private boolean isJDBCClass(String clsName) { + if (clsName.endsWith(";")) + clsName = clsName.substring(1, clsName.length() - 1); + clsName = clsName.replace('.', '/'); + + if (!clsName.startsWith("java/sql/") + && !clsName.startsWith("javax/sql/")) + return false; + + if (clsName.endsWith("Exception")) + return false; + return true; + } } |
From: Dave B. <dbr...@us...> - 2006-03-06 04:18:22
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23140/htdocs Modified Files: index.html Log Message: doc JVR Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.67 retrieving revision 1.68 diff -u -d -r1.67 -r1.68 --- index.html 6 Mar 2006 01:43:18 -0000 1.67 +++ index.html 6 Mar 2006 04:18:19 -0000 1.68 @@ -58,6 +58,9 @@ <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> + <li><b>[JVR] JDBC Vendor Reliance</b><br/> + Looks for uses of jdbc vendor specific classes and methods making the database access code + non portable.</li> </ul> </div> |
From: Dave B. <dbr...@us...> - 2006-03-06 04:16:41
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22371/samples Added Files: JVR_Sample.java Log Message: initial checkin, new JVR detector --- NEW FILE: JVR_Sample.java --- import java.io.InputStream; import java.io.OutputStream; import java.sql.Blob; import java.sql.ResultSet; import java.sql.SQLException; public class JVR_Sample { public String getBlobAsString(ResultSet rs) throws SQLException { VendorBlob vb = (VendorBlob)rs.getBlob(1); return vb.convertBlobToString(); } } class VendorBlob implements Blob { public String convertBlobToString() { return "Booya"; } public InputStream getBinaryStream() throws SQLException { return null; } public byte[] getBytes(long arg0, int arg1) throws SQLException { return null; } public long length() throws SQLException { return 0; } public long position(Blob arg0, long arg1) throws SQLException { return 0; } public long position(byte[] arg0, long arg1) throws SQLException { return 0; } public OutputStream setBinaryStream(long arg0) throws SQLException { return null; } public int setBytes(long arg0, byte[] arg1, int arg2, int arg3) throws SQLException { return 0; } public int setBytes(long arg0, byte[] arg1) throws SQLException { return 0; } public void truncate(long arg0) throws SQLException { } } |
From: Dave B. <dbr...@us...> - 2006-03-06 04:16:40
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22371/src/com/mebigfatguy/fbcontrib/detect Added Files: JDBCVendorReliance.java Log Message: initial checkin, new JVR detector --- NEW FILE: JDBCVendorReliance.java --- package com.mebigfatguy.fbcontrib.detect; import java.util.HashSet; import java.util.Set; import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.Type; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.StatelessDetector; /** * looks for uses of jdbc vendor specific classes and methods making the database access code * non portable. */ public class JDBCVendorReliance extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); private Set<Integer> jdbcLocals = new HashSet<Integer>(); /** * constructs a JVR detector given the reporter to report bugs on * @param bugReporter the sync of bug reports */ public JDBCVendorReliance(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(); } /** * implement the visitor to reset the opcode stack and set of locals that are jdbc objects * * @param obj the context param of the currently parsed method */ @Override public void visitMethod(Method obj) { stack.resetForMethodEntry(this); jdbcLocals.clear(); Type[] argTypes = obj.getArgumentTypes(); int reg = obj.isStatic() ? 0 : 1; for (Type arg : argTypes) { String sig = arg.getSignature(); if (sig.startsWith("Ljavax/sql/") || sig.startsWith("Ljava/sql/")) { jdbcLocals.add(new Integer(reg)); } reg += (sig.equals("L") || sig.equals("D")) ? 2 : 1; } } public void sawOpcode(int seen) { boolean tosIsJDBC = false; try { stack.mergeJumps(this); if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE)) { String clsName = getClassConstantOperand(); if (!clsName.startsWith("javax/sql/") && !clsName.startsWith("java/sql")) { int parmCnt = Type.getArgumentTypes(getSigConstantOperand()).length; if (stack.getStackDepth() > parmCnt) { OpcodeStack.Item itm = stack.getStackItem(parmCnt); if (itm.getUserValue() != null) { bugReporter.reportBug(new BugInstance(this, "JVR_JDBC_VENDOR_RELIANCE", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this)); return; } } } } if (seen == INVOKEINTERFACE) { String infName = getClassConstantOperand(); if (infName.startsWith("javax/sql/") || infName.startsWith("java/sql/")) { String sig = getSigConstantOperand(); Type retType = Type.getReturnType(sig); infName = retType.getSignature(); if (infName.startsWith("Ljavax/sql/") || infName.startsWith("Ljava/sql/")) { tosIsJDBC = true; } } } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); if (itm.getUserValue() != null) { int reg = getAStoreReg(seen); jdbcLocals.add(new Integer(reg)); } } } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { int reg = getALoadReg(seen); if (jdbcLocals.contains(new Integer(reg))) tosIsJDBC = true; } } finally { stack.sawOpcode(this, seen); if (tosIsJDBC) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); itm.setUserValue(Boolean.TRUE); } } } } /** * returns the register used to store a reference * * @param seen the opcode of the store * @return the register stored into */ private int getAStoreReg(int seen) { if (seen == ASTORE) return getRegisterOperand(); return seen - ASTORE_0; } /** * returns the register used to load a reference * * @param seen the opcode of the load * @return the register loaded from */ private int getALoadReg(int seen) { if (seen == ALOAD) return getRegisterOperand(); return seen - ALOAD_0; } } |
From: Dave B. <dbr...@us...> - 2006-03-06 04:16:40
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22371/etc Modified Files: findbugs.xml messages.xml Log Message: initial checkin, new JVR detector Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- messages.xml 5 Mar 2006 04:37:15 -0000 1.56 +++ messages.xml 6 Mar 2006 04:16:37 -0000 1.57 @@ -365,7 +365,7 @@ and custom values together. Doing so makes brittle code, that is difficult to modify, validate and understand. It is cleaner to create external xml files that are transformed at runtime, using parameters set through Transformer.setParameter. - <p>It is a moderately fast Detector</p> + <p>It is a moderately fast detector</p> ]]> </Details> </Detector> @@ -376,7 +376,7 @@ <p>Looks for methods that are implemented using synchronized blocks, but are overly synchronized because the beginning of the block only accesses local variables, and not member variables, or this.</p> - <p>It is a fast Detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -388,7 +388,7 @@ using a constant integer for the index. This is often a typo intented to be a loop variable, but if specific indices mean certain things, perhaps a first class object would be a better choice for a container.</p> - <p>It is a fast Detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -401,7 +401,7 @@ XXX.class, and doing so protects the integrity of this code from such transformations as obfuscation. Use of Class.forName should only be used when the class in question isn't already statically bound to this context.</p> - <p>It is a fast Detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -412,7 +412,7 @@ <p>Looks for methods that use an array of length one to pass a variable to achieve call by pointer ala C++. It is better to define a proper return class type that holds all the relevant information retrieved from the called method.</p> - <p>It is a fast Detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -425,7 +425,7 @@ interface to appear sluggish and non-responsive to the user. It is better to use a separate thread to do the time consuming work so that the user has a better experience.</p> - <p>It is a fast Detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -436,7 +436,7 @@ <p>Looks for methods that call a method to retrieve a reference to an object, to use to load a constant. It is simpler and more performant to access the static variable directly from the class itself.</p> - <p>It is a fast Detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -444,8 +444,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.DateComparison"> <Details> <![CDATA[ - <p> Looks for inefficient comparison of Date objects using two comparisons when one would do. - It is a fast detector. + <p> Looks for inefficient comparison of Date objects using two comparisons when one would do.</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -454,7 +454,18 @@ <Details> <![CDATA[ <p>Looks for calls to the wait method on mutexes defined in the java.util.concurrent - package where it is likely that await was intended. + package where it is likely that await was intended.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.JDBCVendorReliance"> + <Details> + <![CDATA[ + <p>Looks for uses of jdbc vendor specific classes and methods making the database + access code non portable.</p> + <p>It is a moderately fast detector</p> ]]> </Details> </Detector> @@ -935,6 +946,17 @@ </Details> </BugPattern> + <BugPattern type="JVR_JDBC_VENDOR_RELIANCE"> + <ShortDescription>method uses jdbc vendor specific classes and methods</ShortDescription> + <LongDescription>method {1} uses jdbc vendor specific classes and methods</LongDescription> + <Details> + <![CDATA[ + <p>This method uses jdbc vendor specific classes and method to perform database work. + This makes the code specific to this vendor, and unable to run on other databases.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -973,4 +995,5 @@ <BugCode abbrev="NIR">Needless Instance Retrieval</BugCode> <BugCode abbrev="DDC">Double Date comparison</BugCode> <BugCode abbrev="SWCO">Suspicious Wait on Concurrent Object</BugCode> + <BugCode abbrev="JVR">JDBC Vendor Reliance</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.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- findbugs.xml 5 Mar 2006 04:37:13 -0000 1.66 +++ findbugs.xml 6 Mar 2006 04:16:36 -0000 1.67 @@ -159,6 +159,10 @@ speed="fast" reports="SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.JDBCVendorReliance" + speed="moderate" + reports="JVR_JDBC_VENDOR_RELIANCE" /> + <!-- BugPattern --> @@ -198,4 +202,5 @@ <BugPattern abbrev="NIR" type="NIR_NEEDLESS_INSTANCE_RETRIEVAL" category="PERFORMANCE" /> <BugPattern abbrev="DDC" type="DDC_DOUBLE_DATE_COMPARISON" category="PERFORMANCE" experimental="true" /> <BugPattern abbrev="SWCO" type="SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="JVR" type="JVR_JDBC_VENDOR_RELIANCE" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2006-03-06 01:43:20
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25848/htdocs Modified Files: index.html Log Message: have cvs expanded now Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- index.html 28 Feb 2006 03:20:44 -0000 1.66 +++ index.html 6 Mar 2006 01:43:18 -0000 1.67 @@ -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,10 +62,10 @@ </div> <hr/> - <img id="v2_2_0_image" src="flip2.gif" onClick="toggleBlock('v2_2_0', 'v2_2_0_image');" align="top"/> + <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/> Note: fb-contrib v2.2.0 requires FindBugs™ v0.95 or later<br/> - <div id="v2_2_0" style="display:block;"> + <div id="v2_2_0" style="display:none;"> <ul> <li><b>[CLI] Constant List Index</b><br/> Looks for methods that access an array or list using a constant integer index. Often, |
From: Dave B. <dbr...@us...> - 2006-03-05 04:37:20
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7897/src/com/mebigfatguy/fbcontrib/detect Added Files: SuspiciousWaitOnConcurrentObject.java Log Message: initial checkin - new SWCO detector --- NEW FILE: SuspiciousWaitOnConcurrentObject.java --- package com.mebigfatguy.fbcontrib.detect; import java.util.HashSet; import java.util.Set; import org.apache.bcel.Constants; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; import edu.umd.cs.findbugs.BugInstance; 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 calls to the wait method on mutexes defined in the java.util.concurrent package * where it is likely that await was intended. */ public class SuspiciousWaitOnConcurrentObject extends BytecodeScanningDetector implements StatelessDetector { private static final Set<String> concurrentAwaitClasses = new HashSet<String>(); static { concurrentAwaitClasses.add("java.util.concurrent.CountDownLatch"); concurrentAwaitClasses.add("java.util.concurrent.CyclicBarrier"); } private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); /** * constructs a SWCO detector given the reporter to report bugs on * @param bugReporter the sync of bug reports */ public SuspiciousWaitOnConcurrentObject(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(); } /** * implements the visitor to check for class file version 1.5 or better * * @param classContext the context object of the currently parsed class */ @Override public void visitClassContext(ClassContext classContext) { JavaClass cls = classContext.getJavaClass(); int major = cls.getMajor(); if (major >= Constants.MAJOR_1_5) { super.visitClassContext(classContext); } } /** * implements the visitor to reset the opcode stack * * @param obj the context object for the currently parsed method */ @Override public void visitMethod(Method obj) { stack.resetForMethodEntry(this); } /** * implements the visitor to look for calls to wait, on java.util.concurrent * classes that define await. * * @param seen the opcode of the currently visited instruction */ @Override public void sawOpcode(int seen) { try { stack.mergeJumps(this); if (seen == INVOKEVIRTUAL) { String methodName = getNameConstantOperand(); if ("wait".equals(methodName)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); JavaClass cls = itm.getJavaClass(); String clsName = cls.getClassName(); if (concurrentAwaitClasses.contains(clsName)) { bugReporter.reportBug(new BugInstance(this, "SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this)); } } } } } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); } finally { stack.sawOpcode(this, seen); } } } |
From: Dave B. <dbr...@us...> - 2006-03-05 04:37:19
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7897/etc Modified Files: findbugs.xml messages.xml Log Message: initial checkin - new SWCO detector Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- messages.xml 28 Feb 2006 03:17:23 -0000 1.55 +++ messages.xml 5 Mar 2006 04:37:15 -0000 1.56 @@ -449,6 +449,15 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousWaitOnConcurrentObject"> + <Details> + <![CDATA[ + <p>Looks for calls to the wait method on mutexes defined in the java.util.concurrent + package where it is likely that await was intended. + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -914,6 +923,18 @@ </Details> </BugPattern> + <BugPattern type="SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT"> + <ShortDescription>method calls wait when await was probably intended</ShortDescription> + <LongDescription>method {1} calls wait when await was probably intended</LongDescription> + <Details> + <![CDATA[ + <p>This method calls wait() on a on mutex defined in the java.util.concurrent package. + These classes, define await, instead of wait, and it is most likely that await + was intended.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -951,4 +972,5 @@ <BugCode abbrev="SG">Sluggish Gui</BugCode> <BugCode abbrev="NIR">Needless Instance Retrieval</BugCode> <BugCode abbrev="DDC">Double Date comparison</BugCode> + <BugCode abbrev="SWCO">Suspicious Wait on Concurrent Object</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.65 retrieving revision 1.66 diff -u -d -r1.65 -r1.66 --- findbugs.xml 28 Feb 2006 03:17:23 -0000 1.65 +++ findbugs.xml 5 Mar 2006 04:37:13 -0000 1.66 @@ -154,6 +154,11 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.DateComparison" speed="fast" reports="DDC_DOUBLE_DATE_COMPARISON" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousWaitOnConcurrentObject" + speed="fast" + reports="SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT" /> + <!-- BugPattern --> @@ -192,4 +197,5 @@ <BugPattern abbrev="SG" type="SG_SLUGGISH_GUI" category="PERFORMANCE" /> <BugPattern abbrev="NIR" type="NIR_NEEDLESS_INSTANCE_RETRIEVAL" category="PERFORMANCE" /> <BugPattern abbrev="DDC" type="DDC_DOUBLE_DATE_COMPARISON" category="PERFORMANCE" experimental="true" /> + <BugPattern abbrev="SWCO" type="SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2006-03-05 04:37:19
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7897/samples Added Files: SWCO_Sample.java Log Message: initial checkin - new SWCO detector --- NEW FILE: SWCO_Sample.java --- import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; public class SWCO_Sample { CountDownLatch cdl; CyclicBarrier cb; public SWCO_Sample() { cdl = new CountDownLatch(2); cb = new CyclicBarrier(2); } public void waitCDL() throws InterruptedException { cdl.wait(); } public void waitCB() throws InterruptedException { cb.wait(); } } |