fb-contrib-commit Mailing List for fb-contrib (Page 70)
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-12-03 03:33:32
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11646/src/com/mebigfatguy/fbcontrib/detect Added Files: NeedlessAutoboxing.java Log Message: initial checkin, NAB detector --- NEW FILE: NeedlessAutoboxing.java --- package com.mebigfatguy.fbcontrib.detect; import java.util.HashMap; import java.util.Map; 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.StatelessDetector; public class NeedlessAutoboxing extends BytecodeScanningDetector implements StatelessDetector { private static final int SEEN_NOTHING = 0; private static final int SEEN_VALUE = 1; private static final Map<String, String[]> boxClasses = new HashMap<String, String[]>(); static { boxClasses.put("java/lang/Boolean", new String[] { "booleanValue()Z", "(Z)V" }); boxClasses.put("java/lang/Character", new String[] { "charValue()C", "(C)V" }); boxClasses.put("java/lang/Byte", new String[] { "byteValue()B", "(B)V" }); boxClasses.put("java.lang/Short", new String[] { "shortValue()S", "(S)V" }); boxClasses.put("java/lang/Integer", new String[] { "intValue()I", "(I)V" }); boxClasses.put("java/lang/Long", new String[] { "longValue()J", "(J)V" }); boxClasses.put("java/lang/Float", new String[] { "floatValue()F", "(F)V" }); boxClasses.put("java/lang/Double", new String[] { "doubleValue()D", "(D)V" }); } private BugReporter bugReporter; private int state; private String boxClass; public NeedlessAutoboxing(BugReporter bugReporter) { this.bugReporter = bugReporter; } public Object clone() throws CloneNotSupportedException { return super.clone(); } public void visitMethod(Method obj) { state = SEEN_NOTHING; } public void sawOpcode(int seen) { switch (state) { case SEEN_NOTHING: if (seen == INVOKEVIRTUAL) { boxClass = getClassConstantOperand(); String[] boxSigs = boxClasses.get(boxClass); if (boxSigs != null) { String methodName = getNameConstantOperand(); String methodSig = getSigConstantOperand(); if (boxSigs[0].equals(methodName + methodSig)) { state = SEEN_VALUE; } } } break; case SEEN_VALUE: if (seen == INVOKESPECIAL) { if (boxClass.equals(getClassConstantOperand())) { String methodName = getNameConstantOperand(); String boxSig = boxClasses.get(boxClass)[1]; if ("<init>".equals(methodName)) { String methodSig = getSigConstantOperand(); if (boxSig.equals(methodSig)) { bugReporter.reportBug(new BugInstance(this, "NAB_NEEDLESS_AUTOBOXING", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this)); } } } } state = SEEN_NOTHING; break; } } } |
From: Dave B. <dbr...@us...> - 2005-12-03 03:33:32
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11646/etc Modified Files: findbugs.xml messages.xml Log Message: initial checkin, NAB detector Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- messages.xml 1 Dec 2005 05:28:42 -0000 1.33 +++ messages.xml 3 Dec 2005 03:33:24 -0000 1.34 @@ -283,6 +283,27 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessAutoboxing"> + <Details> + <![CDATA[ + <p> Looks for methods that pass a primitive wrapper class object, to the + same classes Constructor. Patterns found are: + <ul> + <li>new Boolean(Boolean)</li> + <li>new Byte(Byte)</li> + <li>new Character(Character)</li> + <li>new Short(Short)</li> + <li>new Integer(Integer)</li> + <li>new Long(Long)</li> + <li>new Float(Float)</li> + <li>new Double(Double)</li> + </ul> + </p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -544,7 +565,20 @@ ]]> </Details> </BugPattern> - + + <BugPattern type="NAB_NEEDLESS_AUTOBOXING"> + <ShortDescription>method passes primitive wrapper to same primitive wrapper constructor</ShortDescription> + <LongDescription>method {1} passes primitive wrapper to same primitive wrapper constructor</LongDescription> + <Details> + <![CDATA[ + <p>This method passes a wrapped primitive object to the same class's constructor. + Since wrapper classes are immutable, you can just use the original object, rather + than constructing a new one. This code works because of an abuse of autoboxing. + </p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -568,4 +602,5 @@ <BugCode abbrev="AFBR">Abnormal Finally Block Return</BugCode> <BugCode abbrev="SMII">Static Method Instance Invocation</BugCode> <BugCode abbrev="STS">Spurious Thread States</BugCode> + <BugCode abbrev="NAB">Needless Autoboxing</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.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- findbugs.xml 1 Dec 2005 05:30:15 -0000 1.40 +++ findbugs.xml 3 Dec 2005 03:33:24 -0000 1.41 @@ -97,6 +97,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SpuriousThreadStates" speed="fast" reports="STS_SPURIOUS_THREAD_STATES" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessAutoboxing" + speed="fast" + reports="NAB_NEEDLESS_AUTOBOXING" /> <!-- BugPattern --> @@ -121,5 +125,5 @@ <BugPattern abbrev="AFBR" type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" category="CORRECTNESS" /> <BugPattern abbrev="SMII" type="SMII_STATIC_METHOD_INSTANCE_INVOCATION" category="STYLE" /> <BugPattern abbrev="STS" type="STS_SPURIOUS_THREAD_STATES" category="MT_CORRECTNESS" experimental="true" /> - + <BugPattern abbrev="NAB" type="NAB_NEEDLESS_AUTOBOXING" category="PERFORMANCE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-12-03 03:33:31
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11646/samples Added Files: NAB_Sample.java Log Message: initial checkin, NAB detector --- NEW FILE: NAB_Sample.java --- public class NAB_Sample { public void test() { Boolean bo = new Boolean(false); Boolean bbo = new Boolean(bo); Byte b = new Byte((byte)0); Byte bb = new Byte(b); Character c = new Character('a'); Character cc = new Character(c); Short s = new Short((short) 0); Short ss = new Short(s); Integer i = new Integer(0); Integer ii = new Integer(i); Long l = new Long(0); Long ll = new Long(l); Float f = new Float(0.0f); Float ff = new Float(f); Double d = new Double(0.0); Double dd = new Double(d); } } |
From: Dave B. <dbr...@us...> - 2005-12-01 05:34:57
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13842/htdocs Modified Files: index.html Log Message: doc STS Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- index.html 1 Dec 2005 04:08:50 -0000 1.33 +++ index.html 1 Dec 2005 05:34:47 -0000 1.34 @@ -44,6 +44,21 @@ <a href="http://www.sourceforge.net/projects/fb-contrib">Project Page</a> <hr/> + <img id="cvs_image" src="flip1.gif" onClick="toggleBlock('cvs', 'cvs_image');" align="top"/> + Detectors added in CVS<br/> + <div id="cvs" style="display:none;"> + Note: these detectors are still in testing + <ul> + <li><b>Spurious Thread States</b><br/> + Finds methods that call wait, notify or notifyAll on an instance of a + java.lang.Thread. Since the internal workings of the threads is to synchronize on the + thread itself, introducing client calls will confuse the thread state of the object + in question, and will cause spurious thread state changes, either waking threads up + when not intended, or removing the the thread from the runnable state.</li> + </ul> + </div> + + <hr/> <img id="v1_6_0_image" src="flip2.gif" onClick="toggleBlock('v1_6_0', 'v1_6_0_image');" align="top"/> Detectors added in v1.6.0<br/> <div id="v1_6_0" style="display:block;"> |
From: Dave B. <dbr...@us...> - 2005-12-01 05:30:26
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12956/etc Modified Files: findbugs.xml Log Message: make STS experimental - for now Index: findbugs.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/findbugs.xml,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- findbugs.xml 1 Dec 2005 05:28:42 -0000 1.39 +++ findbugs.xml 1 Dec 2005 05:30:15 -0000 1.40 @@ -120,6 +120,6 @@ <BugPattern abbrev="CAO" type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" category="CORRECTNESS" /> <BugPattern abbrev="AFBR" type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" category="CORRECTNESS" /> <BugPattern abbrev="SMII" type="SMII_STATIC_METHOD_INSTANCE_INVOCATION" category="STYLE" /> - <BugPattern abbrev="STS" type="STS_SPURIOUS_THREAD_STATES" category="MT_CORRECTNESS" /> + <BugPattern abbrev="STS" type="STS_SPURIOUS_THREAD_STATES" category="MT_CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-12-01 05:28:55
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12646/src/com/mebigfatguy/fbcontrib/detect Added Files: SpuriousThreadStates.java Log Message: initial checkin - new STS detector --- NEW FILE: SpuriousThreadStates.java --- package com.mebigfatguy.fbcontrib.detect; 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; public class SpuriousThreadStates extends BytecodeScanningDetector implements Constants, StatelessDetector { private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); public SpuriousThreadStates(BugReporter bugReporter) { this.bugReporter = bugReporter; } public Object clone() throws CloneNotSupportedException { return super.clone(); } public void visitMethod(Method obj) { stack.resetForMethodEntry(this); super.visitMethod(obj); } public void sawOpcode(int seen) { OpcodeStack.Item itm = null; try { if (seen == INVOKEVIRTUAL) { String className = getClassConstantOperand(); if ("java/lang/Object".equals(className)) { String methodName = getNameConstantOperand(); String signature = getSigConstantOperand(); if (("wait".equals(methodName) || "notify".equals(methodName) || "notifyAll".equals(methodName)) && "()V".equals(signature)) { if (stack.getStackDepth() > 0) itm = stack.getStackItem(0); } else if ("wait".equals(methodName) && "(L)V".equals(signature)) { if (stack.getStackDepth() > 1) itm = stack.getStackItem(1); } else if ("wait".equals(methodName) && "(LI)V".equals(signature)) { if (stack.getStackDepth() > 2) itm = stack.getStackItem(2); } if (itm != null) { JavaClass cls = itm.getJavaClass(); boolean found = false; if ("java.lang.Thread".equals(cls.getClassName())) found = true; else { JavaClass[] supers = cls.getSuperClasses(); for (JavaClass jc : supers) { if ("java.lang.Thread".equals(jc.getClassName())) { found = true; break; } } } if (found) { bugReporter.reportBug(new BugInstance( this, "STS_SPURIOUS_THREAD_STATES", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this)); } } } } } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); } finally { stack.sawOpcode(this, seen); } } } |
From: Dave B. <dbr...@us...> - 2005-12-01 05:28:55
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12646/etc Modified Files: findbugs.xml messages.xml Log Message: initial checkin - new STS detector Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- messages.xml 16 Nov 2005 05:46:24 -0000 1.32 +++ messages.xml 1 Dec 2005 05:28:42 -0000 1.33 @@ -269,6 +269,20 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.SpuriousThreadStates"> + <Details> + <![CDATA[ + <p> Looks for methods that call wait, notify or notifyAll on an instance of a + java.lang.Thread. Since the internal workings of the threads is to synchronize on the + thread itself, introducing client calls will confuse the thread state of the object + in question, and will cause spurious thread state changes, either waking threads up + when not intended, or removing the the thread from the runnable state.</p> + </p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -517,6 +531,20 @@ </Details> </BugPattern> + <BugPattern type="STS_SPURIOUS_THREAD_STATES"> + <ShortDescription>method calls wait, notify or notifyAll on a Thread instance</ShortDescription> + <LongDescription>method {1} calls wait, notify or notifyAll on a Thread instance</LongDescription> + <Details> + <![CDATA[ + <p>This method invokes the methods wait, notify or notifyAll on a Thread instance. + Doing so will confuse the internal thread state behaviour causing spurious thread + wakeups/sleeps because the internal mechanism also uses the thread instance for it's + notifications. + </p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -539,5 +567,5 @@ <BugCode abbrev="CAO">Confusing Autoboxed Overloading</BugCode> <BugCode abbrev="AFBR">Abnormal Finally Block Return</BugCode> <BugCode abbrev="SMII">Static Method Instance Invocation</BugCode> - + <BugCode abbrev="STS">Spurious Thread States</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.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- findbugs.xml 1 Dec 2005 03:29:27 -0000 1.38 +++ findbugs.xml 1 Dec 2005 05:28:42 -0000 1.39 @@ -93,6 +93,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.StaticMethodInstanceInvocation" speed="fast" reports="SMII_STATIC_METHOD_INSTANCE_INVOCATION" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.SpuriousThreadStates" + speed="fast" + reports="STS_SPURIOUS_THREAD_STATES" /> <!-- BugPattern --> @@ -116,5 +120,6 @@ <BugPattern abbrev="CAO" type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" category="CORRECTNESS" /> <BugPattern abbrev="AFBR" type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" category="CORRECTNESS" /> <BugPattern abbrev="SMII" type="SMII_STATIC_METHOD_INSTANCE_INVOCATION" category="STYLE" /> + <BugPattern abbrev="STS" type="STS_SPURIOUS_THREAD_STATES" category="MT_CORRECTNESS" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-12-01 05:28:55
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12646/samples Added Files: STS_Sample.java Log Message: initial checkin - new STS detector --- NEW FILE: STS_Sample.java --- import java.util.Date; public class STS_Sample { public static void main(String[] args) throws InterruptedException { // creating the calculator instance, to pass it to the Reader threads Calculator calculator = new Calculator(); // starting the Reader threads(s) new Reader(calculator).start(); new Reader(calculator).start(); new Reader(calculator).start(); // starting the calculator thread System.out.println(new Date() + ": I will start now a delaty time of" + " 2 seconds before starting the calculator thread"); Thread.sleep(2000); System.out.println(new Date() + ": I just finished the 2 seconds delay " + " and I will start the calculator thread"); calculator.start(); } static class Reader extends Thread { Calculator c; public Reader(Calculator calc) { c = calc; } public void run() { synchronized(c) { try { System.out.println(new Date() + ": Waiting for calculation..."); c.wait(); System.out.println(new Date() + ": I am just after the wait()"); } catch(InterruptedException e) {} System.out.println(new Date() + ": Total is: " + c.total); } } } static class Calculator extends Thread { int total; public void run() { synchronized(this) { try { for(int i=0; i<100; i++) { total += 1; } Thread.sleep(1000); notify(); } catch(InterruptedException e) { e.printStackTrace(); } } } } } |
From: Dave B. <dbr...@us...> - 2005-12-01 04:09:00
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30678/htdocs Modified Files: index.html Log Message: precache the flip images Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- index.html 1 Dec 2005 04:06:23 -0000 1.32 +++ index.html 1 Dec 2005 04:08:50 -0000 1.33 @@ -3,6 +3,12 @@ <meta name="keywords" content="findbugs,plugin,detector,bug,static,jar"/> <title>fb-contrib™: A FindBugs™ auxiliary detector plugin</title> <script language="javascript"> + +var flip1 = new Image; +flip1.src = "flip1.gif"; +var flip2 = new Image; +flip2.src = "flip2.gif"; + function toggleBlock(divId, imgId) { var el = document.getElementById(divId); @@ -10,20 +16,16 @@ { el.style.display="none"; el = document.getElementById(imgId); - el.src="flip1.gif"; + el.src=flip1.src; } else { el.style.display="block"; el = document.getElementById(imgId); - el.src="flip2.gif"; + el.src=flip2.src; } } -var im = new Image; -im.src = "flip1.gif"; -im.src = "flip2.gif"; - </script> </head> <body background> |
From: Dave B. <dbr...@us...> - 2005-12-01 04:06:31
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29955/htdocs Modified Files: index.html Log Message: fix the control Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- index.html 1 Dec 2005 03:29:27 -0000 1.31 +++ index.html 1 Dec 2005 04:06:23 -0000 1.32 @@ -44,7 +44,7 @@ <hr/> <img id="v1_6_0_image" src="flip2.gif" onClick="toggleBlock('v1_6_0', 'v1_6_0_image');" align="top"/> Detectors added in v1.6.0<br/> - <div id="cvs" style="display:block;"> + <div id="v1_6_0" style="display:block;"> <ul> <li><b>Static Method Instance Invocation</b><br/> Finds methods that make static method calls using an instance reference. |
From: Dave B. <dbr...@us...> - 2005-12-01 04:02:11
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28255 Modified Files: build.xml Log Message: get ready for new dev on version 1.7 Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- build.xml 1 Dec 2005 03:29:26 -0000 1.17 +++ build.xml 1 Dec 2005 04:01:55 -0000 1.18 @@ -17,7 +17,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="1.6.0"/> + <property name="fb-contrib.version" value="1.7.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |
From: Dave B. <dbr...@us...> - 2005-12-01 03:29:41
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23100/htdocs Modified Files: index.html Log Message: get ready for the 1.6.0 release Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- index.html 22 Nov 2005 03:27:14 -0000 1.30 +++ index.html 1 Dec 2005 03:29:27 -0000 1.31 @@ -42,10 +42,9 @@ <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');" align="top"/> - Detectors added in CVS<br/> + <img id="v1_6_0_image" src="flip2.gif" onClick="toggleBlock('v1_6_0', 'v1_6_0_image');" align="top"/> + Detectors added in v1.6.0<br/> <div id="cvs" style="display:block;"> - Note: these detectors are still in testing <ul> <li><b>Static Method Instance Invocation</b><br/> Finds methods that make static method calls using an instance reference. |
From: Dave B. <dbr...@us...> - 2005-12-01 03:29:37
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23100 Modified Files: build.xml Log Message: get ready for the 1.6.0 release Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- build.xml 5 Nov 2005 02:42:04 -0000 1.16 +++ build.xml 1 Dec 2005 03:29:26 -0000 1.17 @@ -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.6.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |
From: Dave B. <dbr...@us...> - 2005-12-01 03:29:37
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23100/etc Modified Files: findbugs.xml Log Message: get ready for the 1.6.0 release Index: findbugs.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/findbugs.xml,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- findbugs.xml 16 Nov 2005 05:46:24 -0000 1.37 +++ findbugs.xml 1 Dec 2005 03:29:27 -0000 1.38 @@ -112,9 +112,9 @@ <BugPattern abbrev="ACEM" type="ACEM_ABSTRACT_CLASS_EMPTY_METHODS" category="STYLE" /> <BugPattern abbrev="MAC" type="MAC_MANUAL_ARRAY_COPY" category="PERFORMANCE" /> <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" /> - <BugPattern abbrev="SMII" type="SMII_STATIC_METHOD_INSTANCE_INVOCATION" category="STYLE" experimental="true" /> + <BugPattern abbrev="NCMU" type="NCMU_NON_COLLECTION_METHOD_USE" category="STYLE" /> + <BugPattern abbrev="CAO" type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" category="CORRECTNESS" /> + <BugPattern abbrev="AFBR" type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" category="CORRECTNESS" /> + <BugPattern abbrev="SMII" type="SMII_STATIC_METHOD_INSTANCE_INVOCATION" category="STYLE" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-12-01 03:11:18
|
Update of /cvsroot/fb-contrib/fb-contrib/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20113/lib Modified Files: findbugs.jar Log Message: update to findbugs 0.9.4 Index: findbugs.jar =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/lib/findbugs.jar,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 Binary files /tmp/cvsNZqD5G and /tmp/cvsSKmaDM differ |
From: Dave B. <dbr...@us...> - 2005-11-22 03:51:12
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12534/src/com/mebigfatguy/fbcontrib/detect Modified Files: AbnormalFinallyBlockReturn.java Log Message: organize imports Index: AbnormalFinallyBlockReturn.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- AbnormalFinallyBlockReturn.java 16 Nov 2005 07:08:59 -0000 1.4 +++ AbnormalFinallyBlockReturn.java 22 Nov 2005 03:51:05 -0000 1.5 @@ -21,7 +21,6 @@ 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; @@ -30,7 +29,6 @@ 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; |
From: Dave B. <dbr...@us...> - 2005-11-22 03:48:21
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12097/src/com/mebigfatguy/fbcontrib Modified Files: FBContrib.java Log Message: add trademarks Index: FBContrib.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- FBContrib.java 1 Oct 2005 07:22:44 -0000 1.3 +++ FBContrib.java 22 Nov 2005 03:48:14 -0000 1.4 @@ -23,7 +23,7 @@ public class FBContrib { public static void main(final String[] args) { - JOptionPane.showMessageDialog( null, "To use fb-contrib, copy this jar file into your local FindBugs plugin directory, and use FindBugs as usual."); + JOptionPane.showMessageDialog( null, "To use fb-contrib, copy this jar file into your local FindBugs plugin directory, and use FindBugs as usual.\n\nfb-contrib is a trademark of MeBigFatGuy.com\nFindBugs is a trademark of the University of Maryland"); System.exit(0); } } |
From: Dave B. <dbr...@us...> - 2005-11-22 03:27:28
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9049/htdocs Modified Files: index.html Log Message: add trademarks Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- index.html 17 Nov 2005 05:37:46 -0000 1.29 +++ index.html 22 Nov 2005 03:27:14 -0000 1.30 @@ -1,7 +1,7 @@ <html> <head> <meta name="keywords" content="findbugs,plugin,detector,bug,static,jar"/> -<title>fb-contrib: A FindBugs auxiliary detector plugin</title> +<title>fb-contrib™: A FindBugs™ auxiliary detector plugin</title> <script language="javascript"> function toggleBlock(divId, imgId) { @@ -31,11 +31,11 @@ </div> <div style="position:absolute;top:20;left:20;z-index:2;"> - <h1>fb-contrib: A FindBugs auxiliary detector plugin</h1> + <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 + <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> @@ -157,6 +157,12 @@ counting number of unique branches in the method</li> </ul> </div> + <span align="bottom"> + <p align="right"> + fb-contrib is a trademark of MeBigFatGuy.com<br/> + FindBugs is a trademark of University of Maryland<br/> + </p> + </span> </div> </body> </html> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-11-17 05:37:54
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5375/htdocs Modified Files: index.html Log Message: doc new detector Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- index.html 10 Nov 2005 07:32:26 -0000 1.28 +++ index.html 17 Nov 2005 05:37:46 -0000 1.29 @@ -47,6 +47,10 @@ <div id="cvs" style="display:block;"> Note: these detectors are still in testing <ul> + <li><b>Static Method Instance Invocation</b><br/> + Finds methods that make static method calls using an instance reference. + For documentation purposes, it is better to call the method using the class name. + This may represent a change in definition that should be noticed.</li> <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 |
From: Dave B. <dbr...@us...> - 2005-11-17 05:33:23
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4719/samples Modified Files: SMII_Sample.java Log Message: more tests Index: SMII_Sample.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/samples/SMII_Sample.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SMII_Sample.java 16 Nov 2005 05:46:24 -0000 1.1 +++ SMII_Sample.java 17 Nov 2005 05:33:13 -0000 1.2 @@ -19,4 +19,14 @@ { smii.static_one("foo".toUpperCase()); } + + public SMII_Sample getSMI() + { + return new SMII_Sample(); + } + + public void test_chaining() + { + new SMII_Sample().getSMI().static_one("hello"); + } } \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-11-17 05:23:22
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3178/src/com/mebigfatguy/fbcontrib/detect Modified Files: StaticMethodInstanceInvocation.java Log Message: baseing SMII on aload/pop pattern is small minded, so drop the aload requirement. Now check types to see if static method is defined. False positives still possible, perhaps need to check sourceline annotations to make sure the pop is on the same line as the INVOKESTATIC. Index: StaticMethodInstanceInvocation.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- StaticMethodInstanceInvocation.java 16 Nov 2005 06:48:47 -0000 1.2 +++ StaticMethodInstanceInvocation.java 17 Nov 2005 05:23:15 -0000 1.3 @@ -18,6 +18,12 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.Type; @@ -27,14 +33,9 @@ import edu.umd.cs.findbugs.OpcodeStack; public class StaticMethodInstanceInvocation extends BytecodeScanningDetector { - private static final int SEEN_NOTHING = 0; - private static final int SEEN_ALOAD = 1; - private static final int SEEN_POP = 2; - private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); - private int state; - private int popDepth; + private List<PopInfo> popStack = new ArrayList<PopInfo>(); public StaticMethodInstanceInvocation(BugReporter bugReporter) { this.bugReporter = bugReporter; @@ -47,63 +48,97 @@ @Override public void visitMethod(Method obj) { - state = SEEN_NOTHING; stack.resetForMethodEntry(this); + popStack.clear(); super.visitMethod(obj); } @Override public void sawOpcode(int seen) { try { - switch (state) { - case SEEN_NOTHING: - if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) - state = SEEN_ALOAD; - break; - - case SEEN_ALOAD: - if (seen == POP) { - state = SEEN_POP; - popDepth = stack.getStackDepth()-1; - } - else - state = SEEN_NOTHING; - break; - - case SEEN_POP: - if (stack.getStackDepth() < popDepth) - state = SEEN_NOTHING; - else if (seen == INVOKESTATIC) { - String sig = getSigConstantOperand(); - Type[] args = Type.getArgumentTypes(getSigConstantOperand()); - if (args.length == (stack.getStackDepth() - popDepth)) { + int sDepth = stack.getStackDepth(); + Iterator<PopInfo> it = popStack.iterator(); + + while (it.hasNext()) { + if (sDepth < it.next().popDepth) + it.remove(); + } + + if ((seen == INVOKESTATIC) && (popStack.size() > 0)) { + PopInfo pInfo = popStack.get(0); + Type[] args = Type.getArgumentTypes(getSigConstantOperand()); + if ((args.length > 0) || (pInfo.popPC == (getPC() - 1))) { + if (args.length == (stack.getStackDepth() - pInfo.popDepth)) { + if (classDefinesStaticMethod(pInfo.popSignature.substring(1, pInfo.popSignature.length() - 1))) { bugReporter.reportBug(new BugInstance(this, "SMII_STATIC_METHOD_INSTANCE_INVOCATION", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this)); - state = SEEN_NOTHING; - } else { - Type result = Type.getReturnType(sig); - if ("V".equals(result.getSignature())) - state = SEEN_NOTHING; + popStack.clear(); } - } else if ((seen == ASTORE) - || ((seen >= ASTORE_0) && (seen <= ASTORE_3)) - || (seen == PUTFIELD) - || (seen == ATHROW) - || (seen == GOTO)) { - state = SEEN_NOTHING; - } else if ((seen == INVOKESPECIAL) - || (seen == INVOKEINTERFACE) - || (seen == INVOKEVIRTUAL)) { - Type result = Type.getReturnType(getSigConstantOperand()); - if ("V".equals(result.getSignature())) - state = SEEN_NOTHING; - } - break; + } + } } + + + if ((seen == ASTORE) + || ((seen >= ASTORE_0) && (seen <= ASTORE_3)) + || (seen == PUTFIELD) + || (seen == ATHROW) + || (seen == GOTO)) { + popStack.clear(); + } else if ((seen == INVOKESPECIAL) + || (seen == INVOKEINTERFACE) + || (seen == INVOKEVIRTUAL) + || (seen == INVOKESTATIC)) { + Type result = Type.getReturnType(getSigConstantOperand()); + if ("V".equals(result.getSignature())) + popStack.clear(); + } + + if (seen == POP) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + String popSig = itm.getSignature(); + if (popSig.charAt(0) == 'L') + popStack.add(new PopInfo(getPC(), popSig, sDepth - 1)); + } + } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + popStack.clear(); } finally { stack.sawOpcode(this, seen); } } + + boolean classDefinesStaticMethod(String popSignature) throws ClassNotFoundException { + popSignature = popSignature.replace('/', '.'); + if ("java.lang.Object".equals(popSignature)) + return false; + + JavaClass cls = Repository.lookupClass(popSignature); + Method[] methods = cls.getMethods(); + for (Method m : methods) { + if (m.isStatic()) { + if (m.getName().equals(getNameConstantOperand()) + && m.getSignature().equals(getSigConstantOperand())) + return true; + } + } + + return classDefinesStaticMethod(cls.getSuperclassName()); + } + + static class PopInfo { + int popPC; + String popSignature; + int popDepth; + + public PopInfo(int pc, String signature, int depth) { + popPC = pc; + popSignature = signature; + popDepth = depth; + } + } } |
From: Dave B. <dbr...@us...> - 2005-11-16 07:09:07
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2509/src/com/mebigfatguy/fbcontrib/detect Modified Files: AbnormalFinallyBlockReturn.java AbstractClassEmptyMethods.java ConfusingAutoboxedOverloading.java FloatingPointLoops.java ManualArrayCopy.java NonCollectionMethodUse.java Log Message: pretend i'm actually doing something Index: NonCollectionMethodUse.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonCollectionMethodUse.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- NonCollectionMethodUse.java 1 Nov 2005 05:41:14 -0000 1.1 +++ NonCollectionMethodUse.java 16 Nov 2005 07:08:59 -0000 1.2 @@ -47,10 +47,12 @@ this.bugReporter = bugReporter; } + @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } + @Override public void sawOpcode(int seen) { if (seen == INVOKEVIRTUAL) { String className = getClassConstantOperand(); Index: AbnormalFinallyBlockReturn.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- AbnormalFinallyBlockReturn.java 10 Nov 2005 01:53:49 -0000 1.3 +++ AbnormalFinallyBlockReturn.java 16 Nov 2005 07:08:59 -0000 1.4 @@ -43,16 +43,19 @@ this.bugReporter = bugReporter; } + @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } - public void visitClassContext(ClassContext classContext) { + @Override + public void visitClassContext(ClassContext classContext) { majorVersion = classContext.getJavaClass().getMajor(); if (majorVersion >= MAJOR_1_4) super.visitClassContext(classContext); } + @Override public void visitCode(Code obj) { fbInfo.clear(); loadedReg = -1; @@ -71,7 +74,8 @@ super.visitCode(obj); } - public void sawOpcode(int seen) { + @Override + public void sawOpcode(int seen) { if (fbInfo.size() == 0) return; Index: AbstractClassEmptyMethods.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- AbstractClassEmptyMethods.java 23 Oct 2005 04:59:15 -0000 1.1 +++ AbstractClassEmptyMethods.java 16 Nov 2005 07:08:59 -0000 1.2 @@ -55,21 +55,25 @@ this.bugReporter = bugReporter; } + @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } + @Override public void visitClassContext(ClassContext classContext) { JavaClass cls = classContext.getJavaClass(); if (cls.isAbstract()) super.visitClassContext(classContext); } + @Override public void visitMethod(Method obj) { methodName = obj.getName(); state = SEEN_NOTHING; } + @Override public void visitCode(Code obj) { if ("<init>".equals(methodName) || "<clinit>".equals(methodName)) return; @@ -77,6 +81,7 @@ super.visitCode(obj); } + @Override public void sawOpcode(int seen) { try { switch (state) { Index: ConfusingAutoboxedOverloading.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ConfusingAutoboxedOverloading.java 3 Nov 2005 05:19:08 -0000 1.2 +++ ConfusingAutoboxedOverloading.java 16 Nov 2005 07:08:59 -0000 1.3 @@ -29,7 +29,6 @@ import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; -import edu.umd.cs.findbugs.ClassAnnotation; import edu.umd.cs.findbugs.Detector; import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; @@ -38,7 +37,6 @@ public class ConfusingAutoboxedOverloading extends PreorderVisitor implements Detector, StatelessDetector { private static final int JDK15_MAJOR = 49; - private static final int JDK15_MINOR = 0; private static final Set<String> primitiveSigs = new HashSet<String>(); static { @@ -53,6 +51,7 @@ this.bugReporter = bugReporter; } + @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } @@ -154,7 +153,6 @@ return false; } - public void report() { - + public void report() { } } Index: ManualArrayCopy.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ManualArrayCopy.java 26 Oct 2005 04:08:13 -0000 1.1 +++ ManualArrayCopy.java 16 Nov 2005 07:08:59 -0000 1.2 @@ -42,15 +42,18 @@ this.bugReporter = bugReporter; } + @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } + @Override public void visitCode(Code obj) { state = SEEN_NOTHING; super.visitCode(obj); } + @Override public void sawOpcode(int seen) { switch (state) { case SEEN_NOTHING: Index: FloatingPointLoops.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- FloatingPointLoops.java 7 Nov 2005 02:51:49 -0000 1.5 +++ FloatingPointLoops.java 16 Nov 2005 07:08:59 -0000 1.6 @@ -44,14 +44,17 @@ this.bugReporter = bugReporter; } + @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } + @Override public void visitMethod(Method obj) { forLoops.clear(); } + @Override public void sawOpcode(int seen) { if (forLoops.size() > 0) { Iterator<FloatForLoop> ffl = forLoops.iterator(); |
From: Dave B. <dbr...@us...> - 2005-11-16 06:48:54
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31391/src/com/mebigfatguy/fbcontrib/detect Modified Files: StaticMethodInstanceInvocation.java Log Message: make sure the stack doesn't shrink below when the pop was called. Index: StaticMethodInstanceInvocation.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- StaticMethodInstanceInvocation.java 16 Nov 2005 05:46:24 -0000 1.1 +++ StaticMethodInstanceInvocation.java 16 Nov 2005 06:48:47 -0000 1.2 @@ -34,6 +34,7 @@ private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); private int state; + private int popDepth; public StaticMethodInstanceInvocation(BugReporter bugReporter) { this.bugReporter = bugReporter; @@ -61,17 +62,21 @@ break; case SEEN_ALOAD: - if (seen == POP) + if (seen == POP) { state = SEEN_POP; + popDepth = stack.getStackDepth()-1; + } else state = SEEN_NOTHING; break; case SEEN_POP: - if (seen == INVOKESTATIC) { + if (stack.getStackDepth() < popDepth) + state = SEEN_NOTHING; + else if (seen == INVOKESTATIC) { String sig = getSigConstantOperand(); Type[] args = Type.getArgumentTypes(getSigConstantOperand()); - if (args.length <= stack.getStackDepth()) { + if (args.length == (stack.getStackDepth() - popDepth)) { bugReporter.reportBug(new BugInstance(this, "SMII_STATIC_METHOD_INSTANCE_INVOCATION", NORMAL_PRIORITY) .addClass(this) .addMethod(this) |
From: Dave B. <dbr...@us...> - 2005-11-16 05:46:37
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22422/etc Modified Files: findbugs.xml messages.xml Log Message: new SMII detector, intial checkin Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- messages.xml 8 Nov 2005 05:18:10 -0000 1.31 +++ messages.xml 16 Nov 2005 05:46:24 -0000 1.32 @@ -251,10 +251,24 @@ <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. + </p> + <p>It is a fast detector</p> ]]> </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.StaticMethodInstanceInvocation"> + <Details> + <![CDATA[ + <p> Looks for methods that make static method calls using an instance reference. + For documentation purposes, it is better to call the method using the class name. + This may represent a change in definition that should be noticed. + </p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -489,6 +503,20 @@ </Details> </BugPattern> + <BugPattern type="SMII_STATIC_METHOD_INSTANCE_INVOCATION"> + <ShortDescription>method calls static method on instance reference</ShortDescription> + <LongDescription>method {1} calls static method on instance reference</LongDescription> + <Details> + <![CDATA[ + <p>This method makes a static method call on an instance reference. For + reading comprehension of the code is better to call the method on the class, + rather than an instance. Perhaps this method's static nature has changed since + this code was written, and should be revisited. + </p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -510,5 +538,6 @@ <BugCode abbrev="NCMU">Non Collection Method Use</BugCode> <BugCode abbrev="CAO">Confusing Autoboxed Overloading</BugCode> <BugCode abbrev="AFBR">Abnormal Finally Block Return</BugCode> + <BugCode abbrev="SMII">Static Method Instance Invocation</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.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- findbugs.xml 8 Nov 2005 05:18:10 -0000 1.36 +++ findbugs.xml 16 Nov 2005 05:46:24 -0000 1.37 @@ -90,6 +90,10 @@ speed="fast" reports="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.StaticMethodInstanceInvocation" + speed="fast" + reports="SMII_STATIC_METHOD_INSTANCE_INVOCATION" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -111,5 +115,6 @@ <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" /> + <BugPattern abbrev="SMII" type="SMII_STATIC_METHOD_INSTANCE_INVOCATION" category="STYLE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-11-16 05:46:37
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22422/src/com/mebigfatguy/fbcontrib/detect Added Files: StaticMethodInstanceInvocation.java Log Message: new SMII detector, intial checkin --- NEW FILE: StaticMethodInstanceInvocation.java --- /* * 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 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; public class StaticMethodInstanceInvocation extends BytecodeScanningDetector { private static final int SEEN_NOTHING = 0; private static final int SEEN_ALOAD = 1; private static final int SEEN_POP = 2; private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); private int state; public StaticMethodInstanceInvocation(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } @Override public void visitMethod(Method obj) { state = SEEN_NOTHING; stack.resetForMethodEntry(this); super.visitMethod(obj); } @Override public void sawOpcode(int seen) { try { switch (state) { case SEEN_NOTHING: if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) state = SEEN_ALOAD; break; case SEEN_ALOAD: if (seen == POP) state = SEEN_POP; else state = SEEN_NOTHING; break; case SEEN_POP: if (seen == INVOKESTATIC) { String sig = getSigConstantOperand(); Type[] args = Type.getArgumentTypes(getSigConstantOperand()); if (args.length <= stack.getStackDepth()) { bugReporter.reportBug(new BugInstance(this, "SMII_STATIC_METHOD_INSTANCE_INVOCATION", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this)); state = SEEN_NOTHING; } else { Type result = Type.getReturnType(sig); if ("V".equals(result.getSignature())) state = SEEN_NOTHING; } } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3)) || (seen == PUTFIELD) || (seen == ATHROW) || (seen == GOTO)) { state = SEEN_NOTHING; } else if ((seen == INVOKESPECIAL) || (seen == INVOKEINTERFACE) || (seen == INVOKEVIRTUAL)) { Type result = Type.getReturnType(getSigConstantOperand()); if ("V".equals(result.getSignature())) state = SEEN_NOTHING; } break; } } finally { stack.sawOpcode(this, seen); } } } |