fb-contrib-commit Mailing List for fb-contrib (Page 71)
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...> - 2005-11-16 05:46:36
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22422/samples Added Files: SMII_Sample.java Log Message: new SMII detector, intial checkin --- NEW FILE: SMII_Sample.java --- public class SMII_Sample { public static void static_empty() { } public static void static_one(String s) { } public void test_empty(SMII_Sample smii) { smii.static_empty(); } public void test_empty2(SMII_Sample smii) { smii.static_one("foo".toUpperCase()); } } |
From: Dave B. <dbr...@us...> - 2005-11-11 04:29:36
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21236/src/com/mebigfatguy/fbcontrib/detect Modified Files: SyncCollectionIterators.java Log Message: report synchronized collections that are iterated over, when synced on an object that is NOT the collection. Index: SyncCollectionIterators.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- SyncCollectionIterators.java 5 Nov 2005 02:23:26 -0000 1.6 +++ SyncCollectionIterators.java 11 Nov 2005 04:29:25 -0000 1.7 @@ -18,7 +18,9 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; import org.apache.bcel.classfile.Code; @@ -28,6 +30,7 @@ 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; @@ -41,7 +44,7 @@ add("synchronizedMap"); add("synchronizedList"); add("synchronizedSortedSet"); - add("synchronzedSortedMap"); + add("synchronizedSortedMap"); }}; private static Set<String> mapToSetMethods = new HashSet<String>() {{ @@ -57,7 +60,9 @@ private int state; private Set<String> memberCollections = new HashSet<String>(); private Set<Integer> localCollections = new HashSet<Integer>(); - private int monitorCount; + private List<Object> monitorObjects = new ArrayList<Object>(); + private OpcodeStack stack = new OpcodeStack(); + private Object collectionInfo = null; public SyncCollectionIterators(final BugReporter bugReporter) { this.bugReporter = bugReporter; @@ -79,89 +84,125 @@ if (obj.getCode() != null) { state = SEEN_NOTHING; localCollections.clear(); - monitorCount = 0; + monitorObjects.clear(); + stack.resetForMethodEntry(this); super.visitCode(obj); } } @Override public void sawOpcode(final int seen) { - switch (state) { - case SEEN_NOTHING: - if ((seen == INVOKESTATIC) && "java/util/Collections".equals(getClassConstantOperand())) { - if (synchCollectionNames.contains(getNameConstantOperand())) { - state = SEEN_SYNC; - } - } else if (seen == ALOAD) { - int reg = getRegisterOperand(); - if (localCollections.contains(new Integer(reg))) { - state = SEEN_LOAD; + try { + switch (state) { + case SEEN_NOTHING: + if ((seen == INVOKESTATIC) && "java/util/Collections".equals(getClassConstantOperand())) { + if (synchCollectionNames.contains(getNameConstantOperand())) { + state = SEEN_SYNC; + } + } else if (seen == ALOAD) { + int reg = getRegisterOperand(); + if (localCollections.contains(new Integer(reg))) { + collectionInfo = new Integer(reg); + state = SEEN_LOAD; + } + } else if ((seen >= ALOAD_0) && (seen <= ALOAD_3)) { + int reg = seen - ALOAD_0; + if (localCollections.contains(new Integer(reg))) { + collectionInfo = new Integer(reg); + state = SEEN_LOAD; + } + } else if (seen == GETFIELD) { + ConstantFieldref ref = (ConstantFieldref)getConstantRefOperand(); + ConstantNameAndType nandt = (ConstantNameAndType)getConstantPool().getConstant(ref.getNameAndTypeIndex()); + + String fieldName = nandt.getName(getConstantPool()); + if (memberCollections.contains(fieldName)) { + collectionInfo = fieldName; + state = SEEN_LOAD; + } } - } else if ((seen >= ALOAD_0) && (seen <= ALOAD_3)) { - int reg = seen - ALOAD_0; - if (localCollections.contains(new Integer(reg))) { - state = SEEN_LOAD; + break; + + case SEEN_SYNC: + if (seen == ASTORE) { + int reg = getRegisterOperand(); + localCollections.add(new Integer(reg)); + } else if ((seen >= ASTORE_0) && (seen <= ASTORE_3)) { + int reg = seen - ASTORE_0; + localCollections.add(new Integer(reg)); } - } else if (seen == GETFIELD) { - ConstantFieldref ref = (ConstantFieldref)getConstantRefOperand(); - ConstantNameAndType nandt = (ConstantNameAndType)getConstantPool().getConstant(ref.getNameAndTypeIndex()); - - if (memberCollections.contains(nandt.getName(getConstantPool()))) { - state = SEEN_LOAD; + else if (seen == PUTFIELD) { + ConstantFieldref ref = (ConstantFieldref)getConstantRefOperand(); + ConstantNameAndType nandt = (ConstantNameAndType)getConstantPool().getConstant(ref.getNameAndTypeIndex()); + memberCollections.add(nandt.getName(getConstantPool())); } - } - break; - - case SEEN_SYNC: - if (seen == ASTORE) { - int reg = getRegisterOperand(); - localCollections.add(new Integer(reg)); - } else if ((seen >= ASTORE_0) && (seen <= ASTORE_3)) { - int reg = seen - ASTORE_0; - localCollections.add(new Integer(reg)); - } - else if (seen == PUTFIELD) { - ConstantFieldref ref = (ConstantFieldref)getConstantRefOperand(); - ConstantNameAndType nandt = (ConstantNameAndType)getConstantPool().getConstant(ref.getNameAndTypeIndex()); - memberCollections.add(nandt.getName(getConstantPool())); - } - state = SEEN_NOTHING; - break; - - case SEEN_LOAD: - if (seen == INVOKEINTERFACE) { - String calledClass = getClassConstantOperand(); - if ("java/lang/Map".equals(calledClass)) { - if (mapToSetMethods.contains(getNameConstantOperand())) { - state = SEEN_LOAD; - } else { - state = SEEN_NOTHING; - } - } else if (calledClass.startsWith("java/util/")) { - if ("iterator".equals(getNameConstantOperand())) { - if (monitorCount == 0) { - bugReporter.reportBug( new BugInstance( this, "SCI_SYNCHRONIZED_COLLECTION_ITERATORS", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - state = SEEN_NOTHING; + state = SEEN_NOTHING; + break; + + case SEEN_LOAD: + if (seen == INVOKEINTERFACE) { + String calledClass = getClassConstantOperand(); + if ("java/lang/Map".equals(calledClass)) { + if (mapToSetMethods.contains(getNameConstantOperand())) { + state = SEEN_LOAD; } else { state = SEEN_NOTHING; } + } else if (calledClass.startsWith("java/util/")) { + if ("iterator".equals(getNameConstantOperand())) { + if (monitorObjects.size() == 0) { + bugReporter.reportBug( new BugInstance( this, "SCI_SYNCHRONIZED_COLLECTION_ITERATORS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + state = SEEN_NOTHING; + } else { + Object syncObj = monitorObjects.get(monitorObjects.size() - 1); + + if (!syncIsMap(syncObj, collectionInfo)) { + bugReporter.reportBug( new BugInstance( this, "SCI_SYNCHRONIZED_COLLECTION_ITERATORS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + state = SEEN_NOTHING; + } + } + } else { + state = SEEN_NOTHING; } } else { state = SEEN_NOTHING; } - } else { - state = SEEN_NOTHING; + break; + } + + if (seen == MONITORENTER) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + int reg = item.getRegisterNumber(); + if (reg >= 0) + monitorObjects.add(new Integer(reg)); + else { + FieldAnnotation fa = item.getField(); + if (fa != null) + monitorObjects.add(fa.getFieldName()); + } } - break; + } else if (seen == MONITOREXIT) { + if (monitorObjects.size() > 0) + monitorObjects.remove(monitorObjects.size()-1); + } + } finally { + stack.sawOpcode(this, seen); } + } + + private boolean syncIsMap(Object syncObject, Object collectionInfo) { + if ((syncObject != null) && (collectionInfo != null) && syncObject.getClass().equals(collectionInfo.getClass())) + return syncObject.equals(collectionInfo); - if (seen == MONITORENTER) { - monitorCount++; - } else if (seen == MONITOREXIT) { - monitorCount--; - } + //Something went wrong... don't report + return true; } } |
From: Dave B. <dbr...@us...> - 2005-11-11 03:05:55
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5813/samples Modified Files: SCI_Sample.java Log Message: add test to differentiate sync on the collection, vs. some other object Index: SCI_Sample.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/samples/SCI_Sample.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SCI_Sample.java 5 Nov 2005 02:23:26 -0000 1.2 +++ SCI_Sample.java 11 Nov 2005 03:05:40 -0000 1.3 @@ -93,4 +93,17 @@ } } } + + public void testSyncCollectionInOtherSync() + { + SortedMap<String, String> sm = Collections.synchronizedSortedMap(new TreeMap<String, String>()); + synchronized(this) + { + Iterator<Map.Entry<String, String>> it = sm.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry<String, String> entry = it.next(); + System.out.println(entry.getKey() + "=" + entry.getValue()); + } + } + } } \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-11-11 02:51:21
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3621/src/com/mebigfatguy/fbcontrib/detect Modified Files: OverlyConcreteParameter.java Log Message: don't report on parameters of methods that implement interfaces. Index: OverlyConcreteParameter.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- OverlyConcreteParameter.java 3 Nov 2005 03:20:12 -0000 1.23 +++ OverlyConcreteParameter.java 11 Nov 2005 02:51:11 -0000 1.24 @@ -40,15 +40,18 @@ 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; public class OverlyConcreteParameter extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; + private JavaClass[] interfaces = null; private Map<Integer, Map<JavaClass, List<String>>> parameterDefiners = new HashMap<Integer, Map<JavaClass, List<String>>>(); private Set<Integer> usedParameters = new HashSet<Integer>(); private JavaClass objectClass; private OpcodeStack stack = new OpcodeStack(); private int parmCount; + private boolean methodImplementsInterface; private boolean methodIsStatic; public OverlyConcreteParameter(final BugReporter bugReporter) { @@ -67,8 +70,47 @@ } @Override + public void visitClassContext(ClassContext classContext) { + try { + interfaces = classContext.getJavaClass().getAllInterfaces(); + super.visitClassContext(classContext); + interfaces = null; + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + } + } + + @Override + public void visitMethod(Method obj) { + methodImplementsInterface = false; + String methodName = obj.getName(); + + if (!"<init>".equals(methodName) + && !"<clinit>".equals(methodName)) { + String methodSig = obj.getSignature(); + + outer:for (JavaClass inf : interfaces) { + Method[] methods = inf.getMethods(); + for (Method m : methods) { + if (methodName.equals(m.getName())) { + if (methodSig.equals(m.getSignature())) { + methodImplementsInterface = true; + break outer; + } + } + } + } + } + + super.visitMethod(obj); + } + + @Override public void visitCode(final Code obj) { try { + if (methodImplementsInterface) + return; + parameterDefiners.clear(); usedParameters.clear(); stack.resetForMethodEntry(this); @@ -82,6 +124,9 @@ methodIsStatic = m.isStatic(); parmCount = m.getArgumentTypes().length; + if (parmCount == 0) + return; + if (buildParameterDefiners()) { super.visitCode(obj); reportBugs(); |
From: Dave B. <dbr...@us...> - 2005-11-11 02:51:20
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3621/samples Modified Files: OCP_Sample.java Log Message: don't report on parameters of methods that implement interfaces. Index: OCP_Sample.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/samples/OCP_Sample.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- OCP_Sample.java 1 Nov 2005 04:29:49 -0000 1.3 +++ OCP_Sample.java 11 Nov 2005 02:51:11 -0000 1.4 @@ -1,4 +1,5 @@ -import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -14,7 +15,7 @@ import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; -public class OCP_Sample +public class OCP_Sample implements ActionListener { public String getDisplay(HashSet<String> s, String a, String b) { @@ -61,4 +62,9 @@ } } + + public void actionPerformed(ActionEvent ae) + { + + } } |
From: Dave B. <dbr...@us...> - 2005-11-10 07:32:35
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7369/htdocs Modified Files: index.html Log Message: stop the insanity Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- index.html 10 Nov 2005 07:29:16 -0000 1.27 +++ index.html 10 Nov 2005 07:32:26 -0000 1.28 @@ -20,8 +20,10 @@ } } -Image f1 = new Image("flip1.gif"); -Image f2 = new Image("flip2.gif"); +var im = new Image; +im.src = "flip1.gif"; +im.src = "flip2.gif"; + </script> </head> <body background> |
From: Dave B. <dbr...@us...> - 2005-11-10 07:29:29
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6750/htdocs Modified Files: index.html Log Message: sigh more tweeks Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- index.html 10 Nov 2005 07:25:21 -0000 1.26 +++ index.html 10 Nov 2005 07:29:16 -0000 1.27 @@ -19,6 +19,9 @@ el.src="flip2.gif"; } } + +Image f1 = new Image("flip1.gif"); +Image f2 = new Image("flip2.gif"); </script> </head> <body background> @@ -37,7 +40,7 @@ <a href="http://www.sourceforge.net/projects/fb-contrib">Project Page</a> <hr/> - <img id="cvs_image" src="flip2.gif" onClick="toggleBlock('cvs', 'cvs_image');"/> + <img id="cvs_image" src="flip2.gif" onClick="toggleBlock('cvs', 'cvs_image');" align="top"/> Detectors added in CVS<br/> <div id="cvs" style="display:block;"> Note: these detectors are still in testing @@ -59,7 +62,7 @@ </div> <hr/> - <img id="v1_4_0_image" src="flip1.gif" onClick="toggleBlock('v1_4_0', 'v1_4_0_image');"/> + <img id="v1_4_0_image" src="flip1.gif" onClick="toggleBlock('v1_4_0', 'v1_4_0_image');" align="top"/> Detectors added in v1.4.0<br/> <div id="v1_4_0" style="display:none;"> <ul> @@ -81,7 +84,7 @@ </div> <hr/> - <img id="v1_2_0_image" src="flip1.gif" onClick="toggleBlock('v1_2_0', 'v1_2_0_image');"/> + <img id="v1_2_0_image" src="flip1.gif" onClick="toggleBlock('v1_2_0', 'v1_2_0_image');" align="top"/> Detectors added in v1.2.0<br/> <div id="v1_2_0" style="display:none;"> <ul> @@ -105,7 +108,7 @@ </div> <hr/> - <img id="v1_0_0_image" src="flip1.gif" onClick="toggleBlock('v1_0_0', 'v1_0_0_image');"/> + <img id="v1_0_0_image" src="flip1.gif" onClick="toggleBlock('v1_0_0', 'v1_0_0_image');" align="top"/> Detectors added in v1.0.0<br/> <div id="v1_0_0" style="display:none;"> <ul> @@ -132,7 +135,7 @@ </div> <hr/> - <img id="v0_9_3_image" src="flip1.gif" onClick="toggleBlock('v0_9_3', 'v0_9_3_image');"/> + <img id="v0_9_3_image" src="flip1.gif" onClick="toggleBlock('v0_9_3', 'v0_9_3_image');" align="top"/> Detectors added in v0.9.3 <div id="v0_9_3" style="display:none;"> <ul> |
From: Dave B. <dbr...@us...> - 2005-11-10 07:25:29
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5893/htdocs Modified Files: index.html Log Message: tweaks Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- index.html 10 Nov 2005 07:18:11 -0000 1.25 +++ index.html 10 Nov 2005 07:25:21 -0000 1.26 @@ -25,7 +25,7 @@ <div style="position:absolute;top:0;left:0;width:256;height:100%;z-index:1;background-image:url(blend.jpg);"> </div> - <div style="position:absolute;top:0;left:10;right=100%;bottom=100%;z-index:2;"> + <div style="position:absolute;top:20;left:20;z-index:2;"> <h1>fb-contrib: A FindBugs auxiliary detector plugin</h1> <p>fb-contrib is an extra detector plugin to be used with the static bug |
From: Dave B. <dbr...@us...> - 2005-11-10 07:18:22
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4752/htdocs Modified Files: index.html Added Files: flip1.gif flip2.gif Log Message: proof that i'm only a programmer Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- index.html 10 Nov 2005 06:36:45 -0000 1.24 +++ index.html 10 Nov 2005 07:18:11 -0000 1.25 @@ -2,6 +2,24 @@ <head> <meta name="keywords" content="findbugs,plugin,detector,bug,static,jar"/> <title>fb-contrib: A FindBugs auxiliary detector plugin</title> +<script language="javascript"> +function toggleBlock(divId, imgId) +{ + var el = document.getElementById(divId); + if (el.style.display=="block") + { + el.style.display="none"; + el = document.getElementById(imgId); + el.src="flip1.gif"; + } + else + { + el.style.display="block"; + el = document.getElementById(imgId); + el.src="flip2.gif"; + } +} +</script> </head> <body background> <div style="position:absolute;top:0;left:0;width:256;height:100%;z-index:1;background-image:url(blend.jpg);"> @@ -19,98 +37,117 @@ <a href="http://www.sourceforge.net/projects/fb-contrib">Project Page</a> <hr/> + <img id="cvs_image" src="flip2.gif" onClick="toggleBlock('cvs', 'cvs_image');"/> Detectors added in CVS<br/> - Note: these detectors are still in testing - <ul> - <li><b>Abnormal Finally Block Return</b><br/> - Finds methods that return or throw an exception from a finally block. Since a finally block is - executed after any return or throw statements that are present in the try or catch block, these exit - values are swallowed by the finally block's actions.</li> - <li><b>Non Collections Method Use</b><br/> - Finds calls to collections objects using methods that are not defined in the Collections interfaces, - but that have equivalent methods defined in such. By using the new methods, it allows for the - replacement of concrete classes with interfaces, and simplifies changing collection types if - desired.</li> - <li><b>Confusing Autoboxed Overloading</b><br/> - Finds classes that define overloaded methods where the only difference is a parameter being - of type java.lang.Character, and int, long, float or double. Due to autoboxing, one might conclude - that a parameter of 'a' would autobox to Character, but would instead be cast to a double.</li> - </ul> + <div id="cvs" style="display:block;"> + Note: these detectors are still in testing + <ul> + <li><b>Abnormal Finally Block Return</b><br/> + Finds methods that return or throw an exception from a finally block. Since a finally block is + executed after any return or throw statements that are present in the try or catch block, these exit + values are swallowed by the finally block's actions.</li> + <li><b>Non Collections Method Use</b><br/> + Finds calls to collections objects using methods that are not defined in the Collections interfaces, + but that have equivalent methods defined in such. By using the new methods, it allows for the + replacement of concrete classes with interfaces, and simplifies changing collection types if + desired.</li> + <li><b>Confusing Autoboxed Overloading</b><br/> + Finds classes that define overloaded methods where the only difference is a parameter being + of type java.lang.Character, and int, long, float or double. Due to autoboxing, one might conclude + that a parameter of 'a' would autobox to Character, but would instead be cast to a double.</li> + </ul> + </div> + <hr/> + <img id="v1_4_0_image" src="flip1.gif" onClick="toggleBlock('v1_4_0', 'v1_4_0_image');"/> Detectors added in v1.4.0<br/> - <ul> - <li><b>Final Parameters</b><br/> - Finds parameters that could be marked as final, but aren't. Doing so helps document the method, keeps - unwanted changes to creep in, and may help the jvm jit compiler to optimize better.</li> - <li><b>Abstract Class Empty Methods</b><br/> - Finds empty methods, or methods that just throw an exception in abstract classes. In these cases, it - probably is more correct to just define the method to be abstract as well, so that proper subclass - implementation is enforced.</li> - <li><b>Manual Array Copy</b><br/> - Finds methods that copy elements from one array to another manually using a loop. It is better - performing to use System.arraycopy, as this method is native.</li> - <li><b>Floating Point Loops</b><br/> - Finds methods that use floating point variables as the index to loops. Since floating point math is inprecise, - errors will accumulate each time through the loop, making the logic suspect. It is better to use an - integer index, and calculate the desired floating point value from this integer.</li> - </ul> + <div id="v1_4_0" style="display:none;"> + <ul> + <li><b>Final Parameters</b><br/> + Finds parameters that could be marked as final, but aren't. Doing so helps document the method, keeps + unwanted changes to creep in, and may help the jvm jit compiler to optimize better.</li> + <li><b>Abstract Class Empty Methods</b><br/> + Finds empty methods, or methods that just throw an exception in abstract classes. In these cases, it + probably is more correct to just define the method to be abstract as well, so that proper subclass + implementation is enforced.</li> + <li><b>Manual Array Copy</b><br/> + Finds methods that copy elements from one array to another manually using a loop. It is better + performing to use System.arraycopy, as this method is native.</li> + <li><b>Floating Point Loops</b><br/> + Finds methods that use floating point variables as the index to loops. Since floating point math is inprecise, + errors will accumulate each time through the loop, making the logic suspect. It is better to use an + integer index, and calculate the desired floating point value from this integer.</li> + </ul> + </div> + <hr/> + <img id="v1_2_0_image" src="flip1.gif" onClick="toggleBlock('v1_2_0', 'v1_2_0_image');"/> Detectors added in v1.2.0<br/> - <ul> - <li><b>Parallel Lists</b><br/> - Finds classes that maintain two or more lists or arrays that appear to share a one-to-one relationship - through a common index. It is usually better to create a separate class that holds all corresponding attributes, - and add instances of this class to just one list or array.</li> - <li><b>Dubious List Collection</b><br/> - Finds fields that are implementations of java.util.List, but that are used in a set-like fashion. - Since lookup type operations are performed using a linear search for Lists, the performance for large - Lists will be poor. Consideration should be made as to whether these fields should be sets.</li> - <li><b>Partially Constructed Object Access</b><br/> - Finds constructors that call non-final methods in non-final classes. If this class is derived from, and the - method is overridden, then that method will be executing on an object that hasn't been constructed in regards - to the subclass implementation. These methods should probably be defined as final.</li> - <li><b>Literal String Comparison</b><br/> - Finds methods that call the equals or compareTo methods on a String variable passing in a String literal. - A NullPointerException may occur if the string variable is null. If instead the method was called on - the string literal, and the variable was passed as an argument, this exception could never happen</li> - </ul> + <div id="v1_2_0" style="display:none;"> + <ul> + <li><b>Parallel Lists</b><br/> + Finds classes that maintain two or more lists or arrays that appear to share a one-to-one relationship + through a common index. It is usually better to create a separate class that holds all corresponding attributes, + and add instances of this class to just one list or array.</li> + <li><b>Dubious List Collection</b><br/> + Finds fields that are implementations of java.util.List, but that are used in a set-like fashion. + Since lookup type operations are performed using a linear search for Lists, the performance for large + Lists will be poor. Consideration should be made as to whether these fields should be sets.</li> + <li><b>Partially Constructed Object Access</b><br/> + Finds constructors that call non-final methods in non-final classes. If this class is derived from, and the + method is overridden, then that method will be executing on an object that hasn't been constructed in regards + to the subclass implementation. These methods should probably be defined as final.</li> + <li><b>Literal String Comparison</b><br/> + Finds methods that call the equals or compareTo methods on a String variable passing in a String literal. + A NullPointerException may occur if the string variable is null. If instead the method was called on + the string literal, and the variable was passed as an argument, this exception could never happen</li> + </ul> + </div> + <hr/> + <img id="v1_0_0_image" src="flip1.gif" onClick="toggleBlock('v1_0_0', 'v1_0_0_image');"/> Detectors added in v1.0.0<br/> - <ul> - <li><b>Overly Concrete Parameters</b><br/> - Finds parameters to methods that are defined as concrete classes, - when they're usage pattern can be defined by an implemented interface. - By switching to the interface, you can reduce coupling, which helps making - the code more testable and changeable.</li> - <li><b>List Indexed Iterating</b><br/> - Looks for uses of using loop indexed variables to 'iterate' over a List by calling get(i) - each time thru the loop. Depending on the List implementation, using Iterators can be - significantly faster. Using Iterators also makes it easier to substitute other collection types.</li> - <li><b>Unrelated Collection Contents</b><br/> - Looks for collections that hold objects that are unrelated by class or interface inheritance, other - than java.lang.Object. Doing so, leads to brittle code, either by 'encoding' type knowledge in the position - of an element, or using instanceof tests. It is usually better to create a separate class, add the individual - types as members to it, and add an instance of this class to the collection.</li> - <li><b>Declared Runtime Exception</b><br/> - Finds methods that declare RuntimeExceptions in their throws clause. While not illegal, - this may indicate a misunderstanding as to how unchecked exceptions are handled. - If is felt that a RuntimeException is so prevalent that it should be declared, it - is probably a better idea to prevent the occurance in code.</li> - </ul> + <div id="v1_0_0" style="display:none;"> + <ul> + <li><b>Overly Concrete Parameters</b><br/> + Finds parameters to methods that are defined as concrete classes, + when they're usage pattern can be defined by an implemented interface. + By switching to the interface, you can reduce coupling, which helps making + the code more testable and changeable.</li> + <li><b>List Indexed Iterating</b><br/> + Looks for uses of using loop indexed variables to 'iterate' over a List by calling get(i) + each time thru the loop. Depending on the List implementation, using Iterators can be + significantly faster. Using Iterators also makes it easier to substitute other collection types.</li> + <li><b>Unrelated Collection Contents</b><br/> + Looks for collections that hold objects that are unrelated by class or interface inheritance, other + than java.lang.Object. Doing so, leads to brittle code, either by 'encoding' type knowledge in the position + of an element, or using instanceof tests. It is usually better to create a separate class, add the individual + types as members to it, and add an instance of this class to the collection.</li> + <li><b>Declared Runtime Exception</b><br/> + Finds methods that declare RuntimeExceptions in their throws clause. While not illegal, + this may indicate a misunderstanding as to how unchecked exceptions are handled. + If is felt that a RuntimeException is so prevalent that it should be declared, it + is probably a better idea to prevent the occurance in code.</li> + </ul> + </div> + <hr/> + <img id="v0_9_3_image" src="flip1.gif" onClick="toggleBlock('v0_9_3', 'v0_9_3_image');"/> Detectors added in v0.9.3 - <ul> - <li><b>Inefficient String Buffering</b><br/> - Finds Concatenation inside of a StringBuffer.append call, which - creates temporary StringBuffers.</li> - <li><b>Synchronized Collection Iterators</b><br/> - Finds use of iterators on collections built from Collection.synchronizedXXX() - calls. As iterators are by default not multithread safe, there use with a - synchronized collections seems dubious.</li> - <li><b>Cyclomatic Complexity</b><br/> - Finds methods that are overly complex based on the McCabe algorithm for - counting number of unique branches in the method</li> - </ul> + <div id="v0_9_3" style="display:none;"> + <ul> + <li><b>Inefficient String Buffering</b><br/> + Finds Concatenation inside of a StringBuffer.append call, which + creates temporary StringBuffers.</li> + <li><b>Synchronized Collection Iterators</b><br/> + Finds use of iterators on collections built from Collection.synchronizedXXX() + calls. As iterators are by default not multithread safe, there use with a + synchronized collections seems dubious.</li> + <li><b>Cyclomatic Complexity</b><br/> + Finds methods that are overly complex based on the McCabe algorithm for + counting number of unique branches in the method</li> + </ul> + </div> </div> </body> </html> \ No newline at end of file --- NEW FILE: flip1.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: flip2.gif --- (This appears to be a binary file; contents omitted.) |
From: Dave B. <dbr...@us...> - 2005-11-10 06:36:59
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25331/htdocs Modified Files: index.html Added Files: blend.jpg Log Message: make it slightly less fugly Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- index.html 10 Nov 2005 03:17:13 -0000 1.23 +++ index.html 10 Nov 2005 06:36:45 -0000 1.24 @@ -4,108 +4,113 @@ <title>fb-contrib: A FindBugs auxiliary detector plugin</title> </head> <body background> - <h1>fb-contrib: A FindBugs auxiliary detector plugin</h1> - - <p>fb-contrib is an extra detector plugin to be used with the static bug - finder FindBugs (findbugs.sourceforge.net). Just download the fb-contrib.jar - file, and place it in your FindBugs' plugin directory. FindBugs will - automatically pick up the jar file, and incorporate these detectors with its - own. - </p> - <a href="http://www.sourceforge.net/projects/fb-contrib">Project Page</a> + <div style="position:absolute;top:0;left:0;width:256;height:100%;z-index:1;background-image:url(blend.jpg);"> + </div> - <hr/> - Detectors added in CVS<br/> - Note: these detectors are still in testing - <ul> - <li><b>Abnormal Finally Block Return</b><br/> - Finds methods that return or throw an exception from a finally block. Since a finally block is - executed after any return or throw statements that are present in the try or catch block, these exit - values are swallowed by the finally block's actions.</li> - <li><b>Non Collections Method Use</b><br/> - Finds calls to collections objects using methods that are not defined in the Collections interfaces, - but that have equivalent methods defined in such. By using the new methods, it allows for the - replacement of concrete classes with interfaces, and simplifies changing collection types if - desired.</li> - <li><b>Confusing Autoboxed Overloading</b><br/> - Finds classes that define overloaded methods where the only difference is a parameter being - of type java.lang.Character, and int, long, float or double. Due to autoboxing, one might conclude - that a parameter of 'a' would autobox to Character, but would instead be cast to a double.</li> - </ul> - <hr/> - Detectors added in v1.4.0<br/> - <ul> - <li><b>Final Parameters</b><br/> - Finds parameters that could be marked as final, but aren't. Doing so helps document the method, keeps - unwanted changes to creep in, and may help the jvm jit compiler to optimize better.</li> - <li><b>Abstract Class Empty Methods</b><br/> - Finds empty methods, or methods that just throw an exception in abstract classes. In these cases, it - probably is more correct to just define the method to be abstract as well, so that proper subclass - implementation is enforced.</li> - <li><b>Manual Array Copy</b><br/> - Finds methods that copy elements from one array to another manually using a loop. It is better - performing to use System.arraycopy, as this method is native.</li> - <li><b>Floating Point Loops</b><br/> - Finds methods that use floating point variables as the index to loops. Since floating point math is inprecise, - errors will accumulate each time through the loop, making the logic suspect. It is better to use an - integer index, and calculate the desired floating point value from this integer.</li> - </ul> - <hr/> - Detectors added in v1.2.0<br/> - <ul> - <li><b>Parallel Lists</b><br/> - Finds classes that maintain two or more lists or arrays that appear to share a one-to-one relationship - through a common index. It is usually better to create a separate class that holds all corresponding attributes, - and add instances of this class to just one list or array.</li> - <li><b>Dubious List Collection</b><br/> - Finds fields that are implementations of java.util.List, but that are used in a set-like fashion. - Since lookup type operations are performed using a linear search for Lists, the performance for large - Lists will be poor. Consideration should be made as to whether these fields should be sets.</li> - <li><b>Partially Constructed Object Access</b><br/> - Finds constructors that call non-final methods in non-final classes. If this class is derived from, and the - method is overridden, then that method will be executing on an object that hasn't been constructed in regards - to the subclass implementation. These methods should probably be defined as final.</li> - <li><b>Literal String Comparison</b><br/> - Finds methods that call the equals or compareTo methods on a String variable passing in a String literal. - A NullPointerException may occur if the string variable is null. If instead the method was called on - the string literal, and the variable was passed as an argument, this exception could never happen</li> - </ul> - <hr/> - Detectors added in v1.0.0<br/> - <ul> - <li><b>Overly Concrete Parameters</b><br/> - Finds parameters to methods that are defined as concrete classes, - when they're usage pattern can be defined by an implemented interface. - By switching to the interface, you can reduce coupling, which helps making - the code more testable and changeable.</li> - <li><b>List Indexed Iterating</b><br/> - Looks for uses of using loop indexed variables to 'iterate' over a List by calling get(i) - each time thru the loop. Depending on the List implementation, using Iterators can be - significantly faster. Using Iterators also makes it easier to substitute other collection types.</li> - <li><b>Unrelated Collection Contents</b><br/> - Looks for collections that hold objects that are unrelated by class or interface inheritance, other - than java.lang.Object. Doing so, leads to brittle code, either by 'encoding' type knowledge in the position - of an element, or using instanceof tests. It is usually better to create a separate class, add the individual - types as members to it, and add an instance of this class to the collection.</li> - <li><b>Declared Runtime Exception</b><br/> - Finds methods that declare RuntimeExceptions in their throws clause. While not illegal, - this may indicate a misunderstanding as to how unchecked exceptions are handled. - If is felt that a RuntimeException is so prevalent that it should be declared, it - is probably a better idea to prevent the occurance in code.</li> - </ul> - <hr/> - Detectors added in v0.9.3 - <ul> - <li><b>Inefficient String Buffering</b><br/> - Finds Concatenation inside of a StringBuffer.append call, which - creates temporary StringBuffers.</li> - <li><b>Synchronized Collection Iterators</b><br/> - Finds use of iterators on collections built from Collection.synchronizedXXX() - calls. As iterators are by default not multithread safe, there use with a - synchronized collections seems dubious.</li> - <li><b>Cyclomatic Complexity</b><br/> - Finds methods that are overly complex based on the McCabe algorithm for - counting number of unique branches in the method</li> - </ul> + <div style="position:absolute;top:0;left:10;right=100%;bottom=100%;z-index:2;"> + <h1>fb-contrib: A FindBugs auxiliary detector plugin</h1> + + <p>fb-contrib is an extra detector plugin to be used with the static bug + finder FindBugs (findbugs.sourceforge.net). Just download the fb-contrib.jar + file, and place it in your FindBugs' plugin directory. FindBugs will + automatically pick up the jar file, and incorporate these detectors with its + own. + </p> + <a href="http://www.sourceforge.net/projects/fb-contrib">Project Page</a> + + <hr/> + Detectors added in CVS<br/> + Note: these detectors are still in testing + <ul> + <li><b>Abnormal Finally Block Return</b><br/> + Finds methods that return or throw an exception from a finally block. Since a finally block is + executed after any return or throw statements that are present in the try or catch block, these exit + values are swallowed by the finally block's actions.</li> + <li><b>Non Collections Method Use</b><br/> + Finds calls to collections objects using methods that are not defined in the Collections interfaces, + but that have equivalent methods defined in such. By using the new methods, it allows for the + replacement of concrete classes with interfaces, and simplifies changing collection types if + desired.</li> + <li><b>Confusing Autoboxed Overloading</b><br/> + Finds classes that define overloaded methods where the only difference is a parameter being + of type java.lang.Character, and int, long, float or double. Due to autoboxing, one might conclude + that a parameter of 'a' would autobox to Character, but would instead be cast to a double.</li> + </ul> + <hr/> + Detectors added in v1.4.0<br/> + <ul> + <li><b>Final Parameters</b><br/> + Finds parameters that could be marked as final, but aren't. Doing so helps document the method, keeps + unwanted changes to creep in, and may help the jvm jit compiler to optimize better.</li> + <li><b>Abstract Class Empty Methods</b><br/> + Finds empty methods, or methods that just throw an exception in abstract classes. In these cases, it + probably is more correct to just define the method to be abstract as well, so that proper subclass + implementation is enforced.</li> + <li><b>Manual Array Copy</b><br/> + Finds methods that copy elements from one array to another manually using a loop. It is better + performing to use System.arraycopy, as this method is native.</li> + <li><b>Floating Point Loops</b><br/> + Finds methods that use floating point variables as the index to loops. Since floating point math is inprecise, + errors will accumulate each time through the loop, making the logic suspect. It is better to use an + integer index, and calculate the desired floating point value from this integer.</li> + </ul> + <hr/> + Detectors added in v1.2.0<br/> + <ul> + <li><b>Parallel Lists</b><br/> + Finds classes that maintain two or more lists or arrays that appear to share a one-to-one relationship + through a common index. It is usually better to create a separate class that holds all corresponding attributes, + and add instances of this class to just one list or array.</li> + <li><b>Dubious List Collection</b><br/> + Finds fields that are implementations of java.util.List, but that are used in a set-like fashion. + Since lookup type operations are performed using a linear search for Lists, the performance for large + Lists will be poor. Consideration should be made as to whether these fields should be sets.</li> + <li><b>Partially Constructed Object Access</b><br/> + Finds constructors that call non-final methods in non-final classes. If this class is derived from, and the + method is overridden, then that method will be executing on an object that hasn't been constructed in regards + to the subclass implementation. These methods should probably be defined as final.</li> + <li><b>Literal String Comparison</b><br/> + Finds methods that call the equals or compareTo methods on a String variable passing in a String literal. + A NullPointerException may occur if the string variable is null. If instead the method was called on + the string literal, and the variable was passed as an argument, this exception could never happen</li> + </ul> + <hr/> + Detectors added in v1.0.0<br/> + <ul> + <li><b>Overly Concrete Parameters</b><br/> + Finds parameters to methods that are defined as concrete classes, + when they're usage pattern can be defined by an implemented interface. + By switching to the interface, you can reduce coupling, which helps making + the code more testable and changeable.</li> + <li><b>List Indexed Iterating</b><br/> + Looks for uses of using loop indexed variables to 'iterate' over a List by calling get(i) + each time thru the loop. Depending on the List implementation, using Iterators can be + significantly faster. Using Iterators also makes it easier to substitute other collection types.</li> + <li><b>Unrelated Collection Contents</b><br/> + Looks for collections that hold objects that are unrelated by class or interface inheritance, other + than java.lang.Object. Doing so, leads to brittle code, either by 'encoding' type knowledge in the position + of an element, or using instanceof tests. It is usually better to create a separate class, add the individual + types as members to it, and add an instance of this class to the collection.</li> + <li><b>Declared Runtime Exception</b><br/> + Finds methods that declare RuntimeExceptions in their throws clause. While not illegal, + this may indicate a misunderstanding as to how unchecked exceptions are handled. + If is felt that a RuntimeException is so prevalent that it should be declared, it + is probably a better idea to prevent the occurance in code.</li> + </ul> + <hr/> + Detectors added in v0.9.3 + <ul> + <li><b>Inefficient String Buffering</b><br/> + Finds Concatenation inside of a StringBuffer.append call, which + creates temporary StringBuffers.</li> + <li><b>Synchronized Collection Iterators</b><br/> + Finds use of iterators on collections built from Collection.synchronizedXXX() + calls. As iterators are by default not multithread safe, there use with a + synchronized collections seems dubious.</li> + <li><b>Cyclomatic Complexity</b><br/> + Finds methods that are overly complex based on the McCabe algorithm for + counting number of unique branches in the method</li> + </ul> + </div> </body> </html> \ No newline at end of file --- NEW FILE: blend.jpg --- (This appears to be a binary file; contents omitted.) |
From: Dave B. <dbr...@us...> - 2005-11-10 03:17:21
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12169/htdocs Modified Files: index.html Log Message: doc abnormal finally block return Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- index.html 2 Nov 2005 06:13:55 -0000 1.22 +++ index.html 10 Nov 2005 03:17:13 -0000 1.23 @@ -18,6 +18,10 @@ Detectors added in CVS<br/> Note: these detectors are still in testing <ul> + <li><b>Abnormal Finally Block Return</b><br/> + Finds methods that return or throw an exception from a finally block. Since a finally block is + executed after any return or throw statements that are present in the try or catch block, these exit + values are swallowed by the finally block's actions.</li> <li><b>Non Collections Method Use</b><br/> Finds calls to collections objects using methods that are not defined in the Collections interfaces, but that have equivalent methods defined in such. By using the new methods, it allows for the |
From: Dave B. <dbr...@us...> - 2005-11-10 01:53:56
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29797/src/com/mebigfatguy/fbcontrib/detect Modified Files: AbnormalFinallyBlockReturn.java Log Message: afbr is somewhat working Index: AbnormalFinallyBlockReturn.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- AbnormalFinallyBlockReturn.java 8 Nov 2005 05:43:42 -0000 1.2 +++ AbnormalFinallyBlockReturn.java 10 Nov 2005 01:53:49 -0000 1.3 @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.List; +import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.CodeException; @@ -28,11 +29,15 @@ import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.StatelessDetector; +import edu.umd.cs.findbugs.ba.ClassContext; +import edu.umd.cs.findbugs.visitclass.Constants2; public class AbnormalFinallyBlockReturn extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; private CodeException[] exc; private List<FinallyBlockInfo> fbInfo = new ArrayList<FinallyBlockInfo>(); + private int majorVersion; + private int loadedReg; public AbnormalFinallyBlockReturn(final BugReporter bugReporter) { this.bugReporter = bugReporter; @@ -41,51 +46,52 @@ public Object clone() throws CloneNotSupportedException { return super.clone(); } + + public void visitClassContext(ClassContext classContext) { + majorVersion = classContext.getJavaClass().getMajor(); + if (majorVersion >= MAJOR_1_4) + super.visitClassContext(classContext); + } public void visitCode(Code obj) { fbInfo.clear(); + loadedReg = -1; + exc = obj.getExceptionTable(); if (exc != null) { for (CodeException ce : exc) { if ((ce.getCatchType() == 0) && (ce.getStartPC() == ce.getHandlerPC())) { - fbInfo.add(new FinallyBlockInfo(ce.getStartPC(), ce.getEndPC())); + fbInfo.add(new FinallyBlockInfo(ce.getStartPC(), ce.getEndPC())); } } - } - + } + if (fbInfo.size() > 0) super.visitCode(obj); } - - public void sawOpcode(int seen) { - if (fbInfo.size() == 0) - return; - + + public void sawOpcode(int seen) { + if (fbInfo.size() == 0) + return; + FinallyBlockInfo fbi = fbInfo.get(0); - if ((seen == GOTO) && ((getPC() + 3) == fbi.startPC)) { - fbi.afterFinallyPC = getBranchTarget(); - return; - } else if ((seen == ATHROW) && ((getPC() + 1) == fbi.startPC)) { - fbi.afterFinallyPC = getMaxPC() + 1; - return; - } - if (getPC() < fbi.startPC) return; - - if ((getPC() == fbi.startPC) && (fbi.afterFinallyPC == 0)) { - fbInfo.remove(0); - sawOpcode(seen); - return; - } - - if (getPC() >= fbi.afterFinallyPC) { - fbInfo.remove(0); - sawOpcode(seen); - return; - } + + if (getPC() == fbi.startPC) { + if (seen == ASTORE) + fbi.exReg = getRegisterOperand(); + else if ((seen >= ASTORE_0) && (seen <= ASTORE_3)) + fbi.exReg = seen - ASTORE_0; + else { + fbInfo.remove(0); + sawOpcode(seen); + return; + } + return; + } if (seen == MONITORENTER) { fbi.monitorCount++; @@ -97,7 +103,19 @@ return; } } - + + if ((seen == ATHROW) && (loadedReg == fbi.exReg)) { + fbInfo.remove(0); + sawOpcode(seen); + return; + } + else if (seen == ALOAD) + loadedReg = getRegisterOperand(); + else if ((seen >= ALOAD_0) && (seen <= ALOAD_3)) + loadedReg = seen - ALOAD_0; + else + loadedReg = -1; + if (((seen >= IRETURN) && (seen <= RETURN)) || (seen == ATHROW)) { bugReporter.reportBug(new BugInstance( this, "AFBR_ABNORMAL_FINALLY_BLOCK_RETURN", NORMAL_PRIORITY) .addClass(this) @@ -111,14 +129,14 @@ { public int startPC; public int endPC; - public int afterFinallyPC; public int monitorCount; + public int exReg; public FinallyBlockInfo(int start, int end) { startPC = start; endPC = end; - afterFinallyPC = 0; monitorCount = 0; + exReg = -1; } } -} +} \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-11-08 05:43:52
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8339/src/com/mebigfatguy/fbcontrib/detect Modified Files: AbnormalFinallyBlockReturn.java Log Message: copyright Index: AbnormalFinallyBlockReturn.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- AbnormalFinallyBlockReturn.java 8 Nov 2005 05:18:10 -0000 1.1 +++ AbnormalFinallyBlockReturn.java 8 Nov 2005 05:43:42 -0000 1.2 @@ -1,3 +1,21 @@ +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005 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.ArrayList; |
From: Dave B. <dbr...@us...> - 2005-11-08 05:18:18
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4247/src/com/mebigfatguy/fbcontrib/detect Added Files: AbnormalFinallyBlockReturn.java Log Message: new detector, AFBR - initial checkin --- NEW FILE: AbnormalFinallyBlockReturn.java --- package com.mebigfatguy.fbcontrib.detect; import java.util.ArrayList; import java.util.List; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.CodeException; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.StatelessDetector; public class AbnormalFinallyBlockReturn extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; private CodeException[] exc; private List<FinallyBlockInfo> fbInfo = new ArrayList<FinallyBlockInfo>(); public AbnormalFinallyBlockReturn(final BugReporter bugReporter) { this.bugReporter = bugReporter; } public Object clone() throws CloneNotSupportedException { return super.clone(); } public void visitCode(Code obj) { fbInfo.clear(); exc = obj.getExceptionTable(); if (exc != null) { for (CodeException ce : exc) { if ((ce.getCatchType() == 0) && (ce.getStartPC() == ce.getHandlerPC())) { fbInfo.add(new FinallyBlockInfo(ce.getStartPC(), ce.getEndPC())); } } } if (fbInfo.size() > 0) super.visitCode(obj); } public void sawOpcode(int seen) { if (fbInfo.size() == 0) return; FinallyBlockInfo fbi = fbInfo.get(0); if ((seen == GOTO) && ((getPC() + 3) == fbi.startPC)) { fbi.afterFinallyPC = getBranchTarget(); return; } else if ((seen == ATHROW) && ((getPC() + 1) == fbi.startPC)) { fbi.afterFinallyPC = getMaxPC() + 1; return; } if (getPC() < fbi.startPC) return; if ((getPC() == fbi.startPC) && (fbi.afterFinallyPC == 0)) { fbInfo.remove(0); sawOpcode(seen); return; } if (getPC() >= fbi.afterFinallyPC) { fbInfo.remove(0); sawOpcode(seen); return; } if (seen == MONITORENTER) { fbi.monitorCount++; } else if (seen == MONITOREXIT) { fbi.monitorCount--; if (fbi.monitorCount < 0) { fbInfo.remove(0); sawOpcode(seen); return; } } if (((seen >= IRETURN) && (seen <= RETURN)) || (seen == ATHROW)) { bugReporter.reportBug(new BugInstance( this, "AFBR_ABNORMAL_FINALLY_BLOCK_RETURN", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this)); fbInfo.remove(0); } } public static class FinallyBlockInfo { public int startPC; public int endPC; public int afterFinallyPC; public int monitorCount; public FinallyBlockInfo(int start, int end) { startPC = start; endPC = end; afterFinallyPC = 0; monitorCount = 0; } } } |
From: Dave B. <dbr...@us...> - 2005-11-08 05:18:18
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4247/etc Modified Files: findbugs.xml messages.xml Log Message: new detector, AFBR - initial checkin Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- messages.xml 2 Nov 2005 06:07:00 -0000 1.30 +++ messages.xml 8 Nov 2005 05:18:10 -0000 1.31 @@ -245,7 +245,16 @@ </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.AbnormalFinallyBlockReturn"> + <Details> + <![CDATA[ + <p> Looks for methods that have finally blocks that return values + or throw exceptions. This code will swallow normal program flow and + hide real program logic. + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -468,6 +477,18 @@ </Details> </BugPattern> + <BugPattern type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN"> + <ShortDescription>class has abnormal exit from finally block</ShortDescription> + <LongDescription>class {0} has abnormal exit from finally block</LongDescription> + <Details> + <![CDATA[ + <p>This class returns or throws exceptions from a finally block. This will + mask real program logic in the try block, and short-circuit normal method termination. + </p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -488,5 +509,6 @@ <BugCode abbrev="FPL">Floating Point Loops</BugCode> <BugCode abbrev="NCMU">Non Collection Method Use</BugCode> <BugCode abbrev="CAO">Confusing Autoboxed Overloading</BugCode> + <BugCode abbrev="AFBR">Abnormal Finally Block Return</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.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- findbugs.xml 5 Nov 2005 02:42:04 -0000 1.35 +++ findbugs.xml 8 Nov 2005 05:18:10 -0000 1.36 @@ -86,6 +86,10 @@ speed="fast" reports="CAO_CONFUSING_AUTOBOXED_OVERLOADING" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.AbnormalFinallyBlockReturn" + speed="fast" + reports="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -106,5 +110,6 @@ <BugPattern abbrev="FPL" type="FPL_FLOATING_POINT_LOOPS" category="CORRECTNESS" /> <BugPattern abbrev="NCMU" type="NCMU_NON_COLLECTION_METHOD_USE" category="STYLE" experimental="true" /> <BugPattern abbrev="CAO" type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="AFBR" type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-11-08 05:18:18
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4247/samples Added Files: AFBR_Sample.java Log Message: new detector, AFBR - initial checkin --- NEW FILE: AFBR_Sample.java --- import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; public class AFBR_Sample { public int test1(boolean b) { try { int i = 0; } finally { if (b) return 0; int j = 0; } return 2; } public int test2() { try { return 0; } finally { throw new NullPointerException(); } } public int test3() throws Exception { try { return 0; } finally { throw new Exception(); } } public int test4() { try { throw new Exception(); } catch (Exception e) { return 1; } finally { return 0; } } public int test5() throws IOException { InputStream is = null; try { is = new FileInputStream("test"); return 1; } catch (IOException ioe) { System.out.println("error"); } finally { if (is != null) is.close(); } return 0; } } |
From: Dave B. <dbr...@us...> - 2005-11-07 02:51:57
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19427/src/com/mebigfatguy/fbcontrib/detect Modified Files: FloatingPointLoops.java Log Message: ima Index: FloatingPointLoops.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FloatingPointLoops.java 7 Nov 2005 02:50:11 -0000 1.4 +++ FloatingPointLoops.java 7 Nov 2005 02:51:49 -0000 1.5 @@ -37,7 +37,7 @@ private static final int SEEN_IFX = 3; private static final int SEEN_STORE = 4; - private BugReporter bugReporter; + BugReporter bugReporter; private Set<FloatForLoop> forLoops = new HashSet<FloatForLoop>(); public FloatingPointLoops(BugReporter bugReporter) { |
From: Dave B. <dbr...@us...> - 2005-11-07 02:50:20
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19136/src/com/mebigfatguy/fbcontrib/detect Modified Files: ClassEnvy.java DubiousListCollection.java FloatingPointLoops.java Log Message: run fb on fb-contrib Index: ClassEnvy.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- ClassEnvy.java 19 Oct 2005 04:11:01 -0000 1.14 +++ ClassEnvy.java 7 Nov 2005 02:50:11 -0000 1.15 @@ -108,7 +108,7 @@ Map.Entry<String, Set<Integer>>[]envies = clsAccessCount.entrySet().toArray(new Map.Entry[clsAccessCount.size()]); Arrays.sort(envies, new Comparator<Map.Entry<String, Set<Integer>>>() { - public int compare(Map.Entry<String, Set<Integer>> entry1, Map.Entry<String, Set<Integer>> entry2) { + public int compare(final Map.Entry<String, Set<Integer>> entry1, final Map.Entry<String, Set<Integer>> entry2) { return entry2.getValue().size() - entry1.getValue().size(); } }); Index: FloatingPointLoops.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- FloatingPointLoops.java 7 Nov 2005 02:48:01 -0000 1.3 +++ FloatingPointLoops.java 7 Nov 2005 02:50:11 -0000 1.4 @@ -83,7 +83,7 @@ gotoPC = -1; } - public boolean sawOpcode(int seen) { + public boolean sawOpcode(final int seen) { switch (state) { case SEEN_LOAD: if ((seen == FCMPG) Index: DubiousListCollection.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- DubiousListCollection.java 1 Oct 2005 07:38:02 -0000 1.5 +++ DubiousListCollection.java 7 Nov 2005 02:50:11 -0000 1.6 @@ -67,7 +67,7 @@ } @Override - public void visitClassContext(ClassContext classContext) { + public void visitClassContext(final ClassContext classContext) { JavaClass cls = classContext.getJavaClass(); Field[] flds = cls.getFields(); for (Field f : flds) { |
From: Dave B. <dbr...@us...> - 2005-11-07 02:48:10
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18795/src/com/mebigfatguy/fbcontrib/detect Modified Files: FloatingPointLoops.java Log Message: run fb on fb-contrib Index: FloatingPointLoops.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- FloatingPointLoops.java 4 Nov 2005 02:20:37 -0000 1.2 +++ FloatingPointLoops.java 7 Nov 2005 02:48:01 -0000 1.3 @@ -98,7 +98,7 @@ (seen == INVOKESPECIAL)) { String methodSig = FloatingPointLoops.this.getSigConstantOperand(); Type t = Type.getReturnType(methodSig); - return t.getSignature() != "V"; + return !"V".equals(t.getSignature()); } else if ((seen < ISTORE) || (seen > SASTORE)) { return true; } |
From: Dave B. <dbr...@us...> - 2005-11-05 02:42:12
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1424 Modified Files: build.xml Log Message: go back to 1.5.0 development Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- build.xml 5 Nov 2005 02:25:50 -0000 1.15 +++ build.xml 5 Nov 2005 02:42:04 -0000 1.16 @@ -17,7 +17,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="1.4.2"/> + <property name="fb-contrib.version" value="1.5.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |
From: Dave B. <dbr...@us...> - 2005-11-05 02:42:12
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1424/etc Modified Files: findbugs.xml Log Message: go back to 1.5.0 development Index: findbugs.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/findbugs.xml,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- findbugs.xml 5 Nov 2005 02:25:50 -0000 1.34 +++ findbugs.xml 5 Nov 2005 02:42:04 -0000 1.35 @@ -80,13 +80,11 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NonCollectionMethodUse" speed="fast" - reports="NCMU_NON_COLLECTION_METHOD_USE" - hidden="true" /> + reports="NCMU_NON_COLLECTION_METHOD_USE" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingAutoboxedOverloading" speed="fast" - reports="CAO_CONFUSING_AUTOBOXED_OVERLOADING" - hidden="true" /> + reports="CAO_CONFUSING_AUTOBOXED_OVERLOADING" /> <!-- BugPattern --> |
From: Dave B. <dbr...@us...> - 2005-11-05 02:25:58
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30812 Modified Files: build.xml Log Message: do the dance again for cutting a patch release (1.4.2) Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- build.xml 4 Nov 2005 04:31:46 -0000 1.14 +++ build.xml 5 Nov 2005 02:25:50 -0000 1.15 @@ -17,7 +17,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="1.5.0"/> + <property name="fb-contrib.version" value="1.4.2"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |
From: Dave B. <dbr...@us...> - 2005-11-05 02:25:58
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30812/etc Modified Files: findbugs.xml Log Message: do the dance again for cutting a patch release (1.4.2) Index: findbugs.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/findbugs.xml,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- findbugs.xml 4 Nov 2005 04:32:14 -0000 1.33 +++ findbugs.xml 5 Nov 2005 02:25:50 -0000 1.34 @@ -80,11 +80,13 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NonCollectionMethodUse" speed="fast" - reports="NCMU_NON_COLLECTION_METHOD_USE" /> + reports="NCMU_NON_COLLECTION_METHOD_USE" + hidden="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingAutoboxedOverloading" speed="fast" - reports="CAO_CONFUSING_AUTOBOXED_OVERLOADING" /> + reports="CAO_CONFUSING_AUTOBOXED_OVERLOADING" + hidden="true" /> <!-- BugPattern --> |
From: Dave B. <dbr...@us...> - 2005-11-05 02:23:40
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30417/samples Modified Files: SCI_Sample.java Log Message: if a synchronized collection has a synchronized block around it's iterator don't report it. -- for now. Revisit this later especially if the synchronizing object is not the collection itself. Index: SCI_Sample.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/samples/SCI_Sample.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SCI_Sample.java 4 Sep 2005 02:20:34 -0000 1.1 +++ SCI_Sample.java 5 Nov 2005 02:23:26 -0000 1.2 @@ -80,4 +80,17 @@ System.out.println(entry.getKey() + "=" + entry.getValue()); } } + + public void testSyncCollectionInSync() + { + SortedMap<String, String> sm = Collections.synchronizedSortedMap(new TreeMap<String, String>()); + synchronized(sm) + { + Iterator<Map.Entry<String, String>> it = sm.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry<String, String> entry = it.next(); + System.out.println(entry.getKey() + "=" + entry.getValue()); + } + } + } } \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-11-05 02:23:35
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30417/src/com/mebigfatguy/fbcontrib/detect Modified Files: SyncCollectionIterators.java Log Message: if a synchronized collection has a synchronized block around it's iterator don't report it. -- for now. Revisit this later especially if the synchronizing object is not the collection itself. Index: SyncCollectionIterators.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- SyncCollectionIterators.java 1 Oct 2005 07:38:02 -0000 1.5 +++ SyncCollectionIterators.java 5 Nov 2005 02:23:26 -0000 1.6 @@ -28,6 +28,7 @@ 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; @@ -56,6 +57,7 @@ private int state; private Set<String> memberCollections = new HashSet<String>(); private Set<Integer> localCollections = new HashSet<Integer>(); + private int monitorCount; public SyncCollectionIterators(final BugReporter bugReporter) { this.bugReporter = bugReporter; @@ -77,6 +79,7 @@ if (obj.getCode() != null) { state = SEEN_NOTHING; localCollections.clear(); + monitorCount = 0; super.visitCode(obj); } } @@ -136,14 +139,17 @@ } } else if (calledClass.startsWith("java/util/")) { if ("iterator".equals(getNameConstantOperand())) { - bugReporter.reportBug( new BugInstance( this, "SCI_SYNCHRONIZED_COLLECTION_ITERATORS", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - state = SEEN_NOTHING; + if (monitorCount == 0) { + bugReporter.reportBug( new BugInstance( this, "SCI_SYNCHRONIZED_COLLECTION_ITERATORS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + state = SEEN_NOTHING; + } else { + state = SEEN_NOTHING; + } } - } - else { + } else { state = SEEN_NOTHING; } } else { @@ -151,5 +157,11 @@ } break; } + + if (seen == MONITORENTER) { + monitorCount++; + } else if (seen == MONITOREXIT) { + monitorCount--; + } } } |