fb-contrib-commit Mailing List for fb-contrib (Page 58)
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: <dbr...@us...> - 2006-04-08 14:19:23
|
Revision: 415 Author: dbrosius Date: 2006-04-08 07:19:15 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=415&view=rev Log Message: ----------- prescreen for INVOKESTATIC opcodes Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java 2006-04-08 14:18:47 UTC (rev 414) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java 2006-04-08 14:19:15 UTC (rev 415) @@ -19,14 +19,19 @@ package com.mebigfatguy.fbcontrib.detect; import java.util.ArrayList; +import java.util.BitSet; import java.util.Iterator; import java.util.List; +import org.apache.bcel.Constants; import org.apache.bcel.Repository; +import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.Type; +import com.mebigfatguy.fbcontrib.utils.VersionTransition; + import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -61,15 +66,29 @@ } /** + * looks for methods that contain a INVOKESTATIC opcodes + * + * @param method the context object of the current method + * @return if the class uses synchronization + */ + public boolean prescreen(Method method) { + BitSet bytecodeSet = VersionTransition.getBytecodeSet(getClassContext(), method); + return (bytecodeSet != null) && (bytecodeSet.get(Constants.INVOKESTATIC)); + } + + /** * implement the visitor to reset the stack * * @param obj the context object of the currently parsed method */ @Override - public void visitMethod(Method obj) { - stack.resetForMethodEntry(this); - popStack.clear(); - super.visitMethod(obj); + public void visitCode(Code obj) { + Method m = getMethod(); + if (prescreen(m)) { + stack.resetForMethodEntry(this); + popStack.clear(); + super.visitCode(obj); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-08 14:18:52
|
Revision: 414 Author: dbrosius Date: 2006-04-08 07:18:47 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=414&view=rev Log Message: ----------- prescreen for GOTO or GOTO_W opcodes Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-04-08 14:10:32 UTC (rev 413) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-04-08 14:18:47 UTC (rev 414) @@ -18,12 +18,17 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.BitSet; import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Method; +import com.mebigfatguy.fbcontrib.utils.VersionTransition; + import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -77,24 +82,38 @@ } /** + * looks for methods that contain a GOTO or GOTO_W opcodes + * + * @param method the context object of the current method + * @return if the class uses synchronization + */ + public boolean prescreen(Method method) { + BitSet bytecodeSet = VersionTransition.getBytecodeSet(getClassContext(), method); + return (bytecodeSet != null) && (bytecodeSet.get(Constants.GOTO) || bytecodeSet.get(Constants.GOTO_W)); + } + + /** * overrides the visitor to reset the opcode stack * * @param obj the code object for the currently parsed Code */ @Override public void visitCode(final Code obj) { - sawListSize = false; - - stack.resetForMethodEntry(this); - state = SEEN_NOTHING; - stage = FIND_LOOP_STAGE; - super.visitCode(obj); - - if (sawListSize) { + Method m = getMethod(); + if (prescreen(m)) { + sawListSize = false; + stack.resetForMethodEntry(this); state = SEEN_NOTHING; - stage = FIND_BUG_STAGE; + stage = FIND_LOOP_STAGE; super.visitCode(obj); + + if (sawListSize) { + stack.resetForMethodEntry(this); + state = SEEN_NOTHING; + stage = FIND_BUG_STAGE; + super.visitCode(obj); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-08 14:10:37
|
Revision: 413 Author: dbrosius Date: 2006-04-08 07:10:32 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=413&view=rev Log Message: ----------- prescreen for MONITORENTER opcodes Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2006-04-08 14:10:00 UTC (rev 412) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2006-04-08 14:10:32 UTC (rev 413) @@ -18,15 +18,19 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.BitSet; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; +import com.mebigfatguy.fbcontrib.utils.VersionTransition; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -73,22 +77,36 @@ } /** + * looks for methods that contain a MONITORENTER opcodes + * + * @param method the context object of the current method + * @return if the class uses synchronization + */ + public boolean prescreen(Method method) { + BitSet bytecodeSet = VersionTransition.getBytecodeSet(getClassContext(), method); + return (bytecodeSet != null) && (bytecodeSet.get(Constants.MONITORENTER)); + } + + /** * implement the visitor to reset the sync count, the stack, and gather some information * * @param obj the context object for the currently parsed method */ @Override - public void visitMethod(Method obj) { - if (obj.isSynchronized()) - syncPC = 0; - else - syncPC = -1; - isStatic = obj.isStatic(); - unsafeAliases.clear(); - unsafeAliases.add(new Integer(0)); - branchInfo.clear(); - unsafeCallOccurred = false; - stack.resetForMethodEntry(this); + public void visitCode(Code obj) { + Method m = getMethod(); + if (prescreen(m)) { + if (m.isSynchronized()) + syncPC = 0; + else + syncPC = -1; + isStatic = m.isStatic(); + unsafeAliases.clear(); + unsafeAliases.add(new Integer(0)); + branchInfo.clear(); + unsafeCallOccurred = false; + stack.resetForMethodEntry(this); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-08 14:10:12
|
Revision: 412 Author: dbrosius Date: 2006-04-08 07:10:00 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=412&view=rev Log Message: ----------- javadoc Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java 2006-04-07 16:25:09 UTC (rev 411) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java 2006-04-08 14:10:00 UTC (rev 412) @@ -64,11 +64,21 @@ return super.clone(); } + /** + * implements the visitor to clear the forLoops set + * + * @param obj the context object for the currently parsed method + */ @Override public void visitMethod(Method obj) { forLoops.clear(); } + /** + * implements the visitor to find for loops using floating point indexes + * + * @param seen the opcode of the currently parsed instruction + */ @Override public void sawOpcode(int seen) { if (forLoops.size() > 0) { @@ -87,6 +97,9 @@ forLoops.add(new FloatForLoop(seen - DLOAD_0, getPC())); } + /** + * maintains the state of a previously found for loop + */ public class FloatForLoop { private int state; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-07 16:25:28
|
Revision: 411 Author: dbrosius Date: 2006-04-07 09:25:09 -0700 (Fri, 07 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=411&view=rev Log Message: ----------- update findbugs.jar Modified Paths: -------------- trunk/fb-contrib/lib/findbugs.jar Modified: trunk/fb-contrib/lib/findbugs.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-07 14:27:48
|
Revision: 410 Author: dbrosius Date: 2006-04-07 07:27:43 -0700 (Fri, 07 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=410&view=rev Log Message: ----------- prescreen for NEWARRAY or ANEWARRAY Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2006-04-07 13:58:31 UTC (rev 409) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2006-04-07 14:27:43 UTC (rev 410) @@ -18,13 +18,17 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.BitSet; import java.util.HashMap; import java.util.Map; +import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; +import com.mebigfatguy.fbcontrib.utils.VersionTransition; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -73,15 +77,28 @@ } /** + * looks for methods that contain a NEWARRAY or ANEWARRAY opcodes + * + * @param method the context object of the current method + * @return if the class uses synchronization + */ + public boolean prescreen(Method method) { + BitSet bytecodeSet = VersionTransition.getBytecodeSet(getClassContext(), method); + return (bytecodeSet != null) && (bytecodeSet.get(Constants.NEWARRAY) || bytecodeSet.get(Constants.ANEWARRAY)); + } + + /** * implements the visitor to reset the stack of opcodes * * @param obj the context object for the currently parsed code block */ @Override public void visitCode(Code obj) { - stack.resetForMethodEntry(this); - wrappers.clear(); - super.visitCode(obj); + if (prescreen(getMethod())) { + stack.resetForMethodEntry(this); + wrappers.clear(); + super.visitCode(obj); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-07 13:59:16
|
Revision: 409 Author: dbrosius Date: 2006-04-07 06:58:31 -0700 (Fri, 07 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=409&view=rev Log Message: ----------- preallocate bitset Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java 2006-04-07 13:57:31 UTC (rev 408) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java 2006-04-07 13:58:31 UTC (rev 409) @@ -28,7 +28,7 @@ gbs = ClassContext.class.getMethod("getBytecodeSet", new Class[] { Method.class }); return (BitSet)gbs.invoke(classContext, new Object[] { m }); } catch (Exception e) { - BitSet byteCodeSet = new BitSet(); + BitSet byteCodeSet = new BitSet(256); byteCodeSet.set(0, 255, true); return byteCodeSet; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-07 13:57:39
|
Revision: 408 Author: dbrosius Date: 2006-04-07 06:57:31 -0700 (Fri, 07 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=408&view=rev Log Message: ----------- if getting the bytecode set fails for some reason, return a set of all opcodes Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java 2006-04-07 13:53:12 UTC (rev 407) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java 2006-04-07 13:57:31 UTC (rev 408) @@ -28,7 +28,9 @@ gbs = ClassContext.class.getMethod("getBytecodeSet", new Class[] { Method.class }); return (BitSet)gbs.invoke(classContext, new Object[] { m }); } catch (Exception e) { - return new BitSet(); + BitSet byteCodeSet = new BitSet(); + byteCodeSet.set(0, 255, true); + return byteCodeSet; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-07 13:53:26
|
Revision: 407 Author: dbrosius Date: 2006-04-07 06:53:12 -0700 (Fri, 07 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=407&view=rev Log Message: ----------- Move version change control into a separate utility class Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-07 12:28:07 UTC (rev 406) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-07 13:53:12 UTC (rev 407) @@ -1,6 +1,5 @@ package com.mebigfatguy.fbcontrib.detect; -import java.lang.reflect.Member; import java.util.BitSet; import java.util.HashMap; import java.util.Map; @@ -11,13 +10,13 @@ import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; +import com.mebigfatguy.fbcontrib.utils.VersionTransition; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.StatelessDetector; -import edu.umd.cs.findbugs.ba.ClassContext; /** * looks for methods that synchronize on variables that are not owned by the @@ -51,17 +50,6 @@ return super.clone(); } - private static java.lang.reflect.Method gbs; - private static BitSet transition_getBytecodeSet(ClassContext classContext, Method m) { - try { - if (gbs == null) - gbs = ClassContext.class.getMethod("getBytecodeSet", new Class[] { Method.class }); - return (BitSet)gbs.invoke(classContext, new Object[] { m }); - } catch (Exception e) { - return new BitSet(); - } - } - /** * looks for methods that contain a MONITORENTER opcode * @@ -69,7 +57,7 @@ * @return if the class uses synchronization */ public boolean prescreen(Method method) { - BitSet bytecodeSet = transition_getBytecodeSet(getClassContext(), method); + BitSet bytecodeSet = VersionTransition.getBytecodeSet(getClassContext(), method); return bytecodeSet != null && (bytecodeSet.get(Constants.MONITORENTER)); } Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java 2006-04-07 13:53:12 UTC (rev 407) @@ -0,0 +1,34 @@ +package com.mebigfatguy.fbcontrib.utils; + +import java.util.BitSet; + +import org.apache.bcel.classfile.Method; + +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * supports different versions/changes to the FindBugs.jar file, by using reflection, etc + * to use different signatures. + */ +public class VersionTransition { + + private static java.lang.reflect.Method gbs; + + /** + * manages the change to ClassContext getBytecodeSet from member to static method + * + * @param classContext the context object for the current class + * @param m the method to get the bytecode set for + * @return the byte code set + */ + + public static BitSet getBytecodeSet(ClassContext classContext, Method m) { + try { + if (gbs == null) + gbs = ClassContext.class.getMethod("getBytecodeSet", new Class[] { Method.class }); + return (BitSet)gbs.invoke(classContext, new Object[] { m }); + } catch (Exception e) { + return new BitSet(); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-07 12:28:22
|
Revision: 406 Author: dbrosius Date: 2006-04-07 05:28:07 -0700 (Fri, 07 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=406&view=rev Log Message: ----------- allow to transition to the new getBytecodeSet by using reflection for now Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-07 02:01:50 UTC (rev 405) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-07 12:28:07 UTC (rev 406) @@ -1,5 +1,6 @@ package com.mebigfatguy.fbcontrib.detect; +import java.lang.reflect.Member; import java.util.BitSet; import java.util.HashMap; import java.util.Map; @@ -50,6 +51,17 @@ return super.clone(); } + private static java.lang.reflect.Method gbs; + private static BitSet transition_getBytecodeSet(ClassContext classContext, Method m) { + try { + if (gbs == null) + gbs = ClassContext.class.getMethod("getBytecodeSet", new Class[] { Method.class }); + return (BitSet)gbs.invoke(classContext, new Object[] { m }); + } catch (Exception e) { + return new BitSet(); + } + } + /** * looks for methods that contain a MONITORENTER opcode * @@ -57,7 +69,7 @@ * @return if the class uses synchronization */ public boolean prescreen(Method method) { - BitSet bytecodeSet = ClassContext.getBytecodeSet(method); + BitSet bytecodeSet = transition_getBytecodeSet(getClassContext(), method); return bytecodeSet != null && (bytecodeSet.get(Constants.MONITORENTER)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-07 02:01:58
|
Revision: 405 Author: dbrosius Date: 2006-04-06 19:01:50 -0700 (Thu, 06 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=405&view=rev Log Message: ----------- fix javadoc Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-04-07 01:54:57 UTC (rev 404) +++ trunk/fb-contrib/htdocs/index.html 2006-04-07 02:01:50 UTC (rev 405) @@ -62,6 +62,7 @@ locals.</li> <li><b>[NOS] Non Owned Synchronization</b><br> looks for methods that synchronize on variables that are not owned by the + current class. Doing this causes confusion when two classes use the same variable for their own synchronization purposes. For cleanest separation of interests, only synchronize on private fields of the class. Note that 'this' is not owned by the current class and synchronization on 'this' should be avoided as well.</li> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-07 01:54:57 UTC (rev 404) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-07 02:01:50 UTC (rev 405) @@ -20,6 +20,7 @@ /** * looks for methods that synchronize on variables that are not owned by the + * current class. Doing this causes confusion when two classes use the same variable * for their own synchronization purposes. For cleanest separation of interests, only * synchronize on private fields of the class. Note that 'this' is not owned by * the current class and synchronization on 'this' should be avoided as well. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-07 01:55:08
|
Revision: 404 Author: dbrosius Date: 2006-04-06 18:54:57 -0700 (Thu, 06 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=404&view=rev Log Message: ----------- add space Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-04-07 01:25:23 UTC (rev 403) +++ trunk/fb-contrib/htdocs/index.html 2006-04-07 01:54:57 UTC (rev 404) @@ -46,10 +46,11 @@ <a href="javadoc/index.html">JavaDoc</a> <hr/> - <img id="cvs_image" src="flip2.gif" onClick="toggleBlock('cvs', 'cvs_image');" align="top"/> - Detectors added in CVS<br/> + <img id="svn_image" src="flip2.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> + Detectors added in SVN<br/> Note: these detectors are still in testing<br/> - <div id="cvs" style="display:block;"> + Also note that the svn version of fb-contrib requires the cvs version of FindBugs.<br/> + <div id="svn" style="display:block;"> <ul> <li><b>[BSB] Bloated Synchronized Block</b><br/> Looks for methods that implement synchronized blocks that appear to contain some code at @@ -57,7 +58,13 @@ block should help multithreaded performance.</li> <li><b>[FCBL] Field could be Local</b><br/> Looks for classes that declare fields that are used in a locals-only fashion, specifically private fields - that are accessed first in each method with a store vs. a load. These fields can be declared as one or more locals.</li> + that are accessed first in each method with a store vs. a load. These fields can be declared as one or more + locals.</li> + <li><b>[NOS] Non Owned Synchronization</b><br> + looks for methods that synchronize on variables that are not owned by the + for their own synchronization purposes. For cleanest separation of interests, only + synchronize on private fields of the class. Note that 'this' is not owned by + the current class and synchronization on 'this' should be avoided as well.</li> </ul> </div> <hr/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-07 01:25:31
|
Revision: 403 Author: dbrosius Date: 2006-04-06 18:25:23 -0700 (Thu, 06 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=403&view=rev Log Message: ----------- better detection of when their is a possibility that a variable is owned, or at least may be owned. Modified Paths: -------------- trunk/fb-contrib/samples/NOS_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java Modified: trunk/fb-contrib/samples/NOS_Sample.java =================================================================== --- trunk/fb-contrib/samples/NOS_Sample.java 2006-04-06 14:26:33 UTC (rev 402) +++ trunk/fb-contrib/samples/NOS_Sample.java 2006-04-07 01:25:23 UTC (rev 403) @@ -1,8 +1,30 @@ +import java.util.Map; public class NOS_Sample { + private Object lock = new Object(); + public String test(Object o) { synchronized(o) { return o.toString(); } } + + public String test2(Object o) { + synchronized(this) { + return o.toString(); + } + } + + public String test3(Map m) { + String v = (String)m.get("boo"); + synchronized (v) { + return v.substring(0,1); + } + } + + public String test4(Object o) { + synchronized(lock) { + return o.toString(); + } + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-06 14:26:33 UTC (rev 402) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-07 01:25:23 UTC (rev 403) @@ -67,12 +67,15 @@ */ @Override public void visitCode(Code obj) { - if (prescreen(getMethod())) { + Method method = getMethod(); + if (prescreen(method)) { stack.resetForMethodEntry(this); regPriorities.clear(); - int[] parmRegs = RegisterUtils.getParameterRegisters(getMethod()); + int[] parmRegs = RegisterUtils.getParameterRegisters(method); for (int reg : parmRegs) regPriorities.put(new Integer(reg), NORMAL); + if (!method.isStatic()) + regPriorities.put(new Integer(0), LOW); super.visitCode(obj); } } @@ -122,16 +125,23 @@ break; case INVOKEVIRTUAL: - case INVOKEINTERFACE: - case INVOKESPECIAL: { + case INVOKEINTERFACE: { String sig = getSigConstantOperand(); Type t = Type.getReturnType(sig); if (t.getSignature().startsWith("L")) { int parmCnt = Type.getArgumentTypes(sig).length; if (stack.getStackDepth() >= parmCnt) { OpcodeStack.Item itm = stack.getStackItem(parmCnt); - if (itm.getRegisterNumber() != 0) - tosIsPriority = NORMAL; + Integer priority = (Integer)itm.getUserValue(); + if ((priority != null) && OWNED.equals(priority)) { + tosIsPriority = OWNED; + } else { + int reg = itm.getRegisterNumber(); + if (reg > 0) + tosIsPriority = regPriorities.get(new Integer(reg)); + else + tosIsPriority = OWNED; + } } } } @@ -140,8 +150,15 @@ case INVOKESTATIC: { String sig = getSigConstantOperand(); Type t = Type.getReturnType(sig); - if (t.getSignature().startsWith("L")) { - tosIsPriority = NORMAL; + if (t.getSignature().startsWith("L")) + tosIsPriority = OWNED; // can't be sure + } + break; + + case INVOKESPECIAL: { + String name = getNameConstantOperand(); + if ("<init>".equals(name)) { + tosIsPriority = OWNED; } } break; @@ -150,7 +167,7 @@ if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); Integer priority = (Integer)itm.getUserValue(); - if (priority != null) { + if ((priority != null) && (!priority.equals(OWNED))) { bugReporter.reportBug(new BugInstance(this, "NOS_NON_OWNED_SYNCHRONIZATION", priority.intValue()) .addClass(this) .addMethod(this) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-06 14:26:57
|
Revision: 402 Author: dbrosius Date: 2006-04-06 07:26:33 -0700 (Thu, 06 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=402&view=rev Log Message: ----------- no autoboxing Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-06 14:25:39 UTC (rev 401) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-06 14:26:33 UTC (rev 402) @@ -99,7 +99,7 @@ case ALOAD_3: { int reg = RegisterUtils.getALoadReg(this, seen); if (getMethod().isStatic() && (reg == 0)) - tosIsPriority = LOW_PRIORITY; + tosIsPriority = LOW; else { tosIsPriority = regPriorities.get(new Integer(reg)); if (tosIsPriority == null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-06 14:25:48
|
Revision: 401 Author: dbrosius Date: 2006-04-06 07:25:39 -0700 (Thu, 06 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=401&view=rev Log Message: ----------- Add aload/astore reg checking... starting to limp along, altho too many bugs found Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-06 14:19:34 UTC (rev 400) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-06 14:25:39 UTC (rev 401) @@ -92,7 +92,11 @@ tosIsPriority = OWNED; break; - case ALOAD: { + case ALOAD: + case ALOAD_0: + case ALOAD_1: + case ALOAD_2: + case ALOAD_3: { int reg = RegisterUtils.getALoadReg(this, seen); if (getMethod().isStatic() && (reg == 0)) tosIsPriority = LOW_PRIORITY; @@ -104,7 +108,11 @@ } break; - case ASTORE: { + case ASTORE: + case ASTORE_0: + case ASTORE_1: + case ASTORE_2: + case ASTORE_3: { if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); Integer priority = (Integer)item.getUserValue(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-06 14:19:55
|
Revision: 400 Author: dbrosius Date: 2006-04-06 07:19:34 -0700 (Thu, 06 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=400&view=rev Log Message: ----------- Initial check: new NOS detector - doesn't work at all at this point :) Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/lib/findbugs.jar Added Paths: ----------- trunk/fb-contrib/samples/NOS_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-04-04 21:36:11 UTC (rev 399) +++ trunk/fb-contrib/etc/findbugs.xml 2006-04-06 14:19:34 UTC (rev 400) @@ -175,6 +175,10 @@ speed="fast" reports="FCBL_FIELD_COULD_BE_LOCAL" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.NonOwnedSynchronization" + speed="fast" + reports="NOS_NON_OWNED_SYNCHRONIZATION" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -217,4 +221,5 @@ <BugPattern abbrev="PMB" type="PMB_POSSIBLE_MEMORY_BLOAT" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="LSYC" type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="FCBL" type="FCBL_FIELD_COULD_BE_LOCAL" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="NOS" type="NOS_NON_OWNED_SYNCHRONIZATION" category="STYLE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-04-04 21:36:11 UTC (rev 399) +++ trunk/fb-contrib/etc/messages.xml 2006-04-06 14:19:34 UTC (rev 400) @@ -504,6 +504,19 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.NonOwnedSynchronization"> + <Details> + <![CDATA[ + <p>looks for methods that synchronize on variables that are not owned by the + current class. Doing this causes confusion when two classes use the same variable + for their own synchronization purposes. For cleanest separation of interests, only + synchronize on private fields of the class. Note that 'this' is not owned by + the current class and synchronization on 'this' should be avoided as well.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -1030,6 +1043,20 @@ </Details> </BugPattern> + <BugPattern type="NOS_NON_OWNED_SYNCHRONIZATION"> + <ShortDescription>class uses non owned variables to synchronize on</ShortDescription> + <LongDescription>class {0} uses non owned variables to synchronize on</LongDescription> + <Details> + <![CDATA[ + <p>This method uses a synchronize block where the object that is being synchronized on, + is not owned by this current instance. This means that other instances may use this same + object for synchronization for its own purposes causing synchronization confusion. It is + always cleaner and safer to only synchronize on private fields of this class. Note that 'this' + is not owned by the current instance, but is owned by whomever assigns it to a field of its + class. Synchronizing on 'this' is also not a good idea.</p> + ]]> + </Details> + </BugPattern> <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -1072,4 +1099,5 @@ <BugCode abbrev="PMB">Possible Memory Bloat</BugCode> <BugCode abbrev="LSYC">Local Synchronized Collection</BugCode> <BugCode abbrev="FCBL">Field Could Be Local</BugCode> + <BugCode abbrev="NOS">Non Owned Synchronization</BugCode> </MessageCollection> \ No newline at end of file Modified: trunk/fb-contrib/lib/findbugs.jar =================================================================== (Binary files differ) Added: trunk/fb-contrib/samples/NOS_Sample.java =================================================================== --- trunk/fb-contrib/samples/NOS_Sample.java (rev 0) +++ trunk/fb-contrib/samples/NOS_Sample.java 2006-04-06 14:19:34 UTC (rev 400) @@ -0,0 +1,8 @@ + +public class NOS_Sample { + public String test(Object o) { + synchronized(o) { + return o.toString(); + } + } +} Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-06 14:19:34 UTC (rev 400) @@ -0,0 +1,165 @@ +package com.mebigfatguy.fbcontrib.detect; + +import java.util.BitSet; +import java.util.HashMap; +import java.util.Map; + +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; + +import com.mebigfatguy.fbcontrib.utils.RegisterUtils; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.StatelessDetector; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * looks for methods that synchronize on variables that are not owned by the + * for their own synchronization purposes. For cleanest separation of interests, only + * synchronize on private fields of the class. Note that 'this' is not owned by + * the current class and synchronization on 'this' should be avoided as well. + */ +public class NonOwnedSynchronization extends BytecodeScanningDetector implements StatelessDetector { + private static final Integer OWNED = Integer.MAX_VALUE; + private static final Integer LOW = new Integer(LOW_PRIORITY); + private static final Integer NORMAL = new Integer(NORMAL_PRIORITY); + private BugReporter bugReporter; + private OpcodeStack stack = new OpcodeStack(); + private Map<Integer, Integer> regPriorities = new HashMap<Integer, Integer>(); + + /** + * constructs a NOS detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ public NonOwnedSynchronization(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * clone this detector so that it can be a StatelessDetector + * + * @return a clone of this object + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * looks for methods that contain a MONITORENTER opcode + * + * @param method the context object of the current method + * @return if the class uses synchronization + */ + public boolean prescreen(Method method) { + BitSet bytecodeSet = ClassContext.getBytecodeSet(method); + return bytecodeSet != null && (bytecodeSet.get(Constants.MONITORENTER)); + } + + /** + * implements the visitor to reset the opcode stack + * + * @param obj the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + if (prescreen(getMethod())) { + stack.resetForMethodEntry(this); + regPriorities.clear(); + int[] parmRegs = RegisterUtils.getParameterRegisters(getMethod()); + for (int reg : parmRegs) + regPriorities.put(new Integer(reg), NORMAL); + super.visitCode(obj); + } + } + + /** + * implements the visitor to look for synchronization on non-owned objects + * + * @param seen the opcode of the currently parsed instruction + */ + public void sawOpcode(int seen) { + Integer tosIsPriority = null; + try { + stack.mergeJumps(this); + + switch (seen) { + case GETFIELD: + tosIsPriority = OWNED; + break; + + case ALOAD: { + int reg = RegisterUtils.getALoadReg(this, seen); + if (getMethod().isStatic() && (reg == 0)) + tosIsPriority = LOW_PRIORITY; + else { + tosIsPriority = regPriorities.get(new Integer(reg)); + if (tosIsPriority == null) + tosIsPriority = NORMAL; + } + } + break; + + case ASTORE: { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + Integer priority = (Integer)item.getUserValue(); + regPriorities.put(new Integer(RegisterUtils.getAStoreReg(this, seen)), priority); + } + } + break; + + case INVOKEVIRTUAL: + case INVOKEINTERFACE: + case INVOKESPECIAL: { + String sig = getSigConstantOperand(); + Type t = Type.getReturnType(sig); + if (t.getSignature().startsWith("L")) { + int parmCnt = Type.getArgumentTypes(sig).length; + if (stack.getStackDepth() >= parmCnt) { + OpcodeStack.Item itm = stack.getStackItem(parmCnt); + if (itm.getRegisterNumber() != 0) + tosIsPriority = NORMAL; + } + } + } + break; + + case INVOKESTATIC: { + String sig = getSigConstantOperand(); + Type t = Type.getReturnType(sig); + if (t.getSignature().startsWith("L")) { + tosIsPriority = NORMAL; + } + } + break; + + case MONITORENTER: { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + Integer priority = (Integer)itm.getUserValue(); + if (priority != null) { + bugReporter.reportBug(new BugInstance(this, "NOS_NON_OWNED_SYNCHRONIZATION", priority.intValue()) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } + break; + } + } finally { + stack.sawOpcode(this, seen); + if (tosIsPriority != null) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + itm.setUserValue(tosIsPriority); + } + } + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-04 21:36:20
|
Revision: 399 Author: dbrosius Date: 2006-04-04 14:36:11 -0700 (Tue, 04 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=399&view=rev Log Message: ----------- add finals Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-04 21:31:41 UTC (rev 398) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-04 21:36:11 UTC (rev 399) @@ -242,7 +242,7 @@ * creates a FieldInfo from an annotation, and assumes no source line information * @param fa the field annotation for this field */ - public FieldInfo(FieldAnnotation fa) { + public FieldInfo(final FieldAnnotation fa) { fieldAnnotation = fa; srcLineAnnotation = null; } @@ -251,7 +251,7 @@ * set the source line annotation of first use for this field * @param sla the source line annotation */ - public void setSrcLineAnnotation(SourceLineAnnotation sla) { + public void setSrcLineAnnotation(final SourceLineAnnotation sla) { if (srcLineAnnotation == null) srcLineAnnotation = sla; } @@ -286,7 +286,7 @@ * @param bb the basic block to parse * @param fields the fields to look for first use */ - public BlockState(BasicBlock bb, Set<String> fields) { + public BlockState(final BasicBlock bb, final Set<String> fields) { basicBlock = bb; uncheckedFields = new HashSet<String>(fields); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-04 21:31:46
|
Revision: 398 Author: dbrosius Date: 2006-04-04 14:31:41 -0700 (Tue, 04 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=398&view=rev Log Message: ----------- remove unused Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-04 15:22:32 UTC (rev 397) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-04 21:31:41 UTC (rev 398) @@ -93,7 +93,6 @@ localizableFields.clear(); clsContext = classContext; JavaClass cls = classContext.getJavaClass(); - boolean clsIsFinal = cls.isFinal(); Field[] fields = cls.getFields(); for (Field f : fields) { if ((!f.isStatic() && f.getName().indexOf("$") < 0) && f.isPrivate()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-04 15:22:38
|
Revision: 397 Author: dbrosius Date: 2006-04-04 08:22:32 -0700 (Tue, 04 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=397&view=rev Log Message: ----------- Fix for bug: [ 1462290 ] FCBL: infinite recursion? (stack overflow) Convert FCBL's algorithm from recursive to iterative, to avoid stack overflow problems. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-04 14:38:03 UTC (rev 396) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-04 15:22:32 UTC (rev 397) @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; import java.util.Map; import java.util.Set; @@ -184,65 +185,127 @@ * @param uncheckedFields the list of fields to look for */ private void checkBlock(BasicBlock bb, Set<String> uncheckedFields) { - visitedBlocks.set(bb.getId()); - InstructionIterator ii = bb.instructionIterator(); - while (ii.hasNext()) { - InstructionHandle ih = ii.next(); - Instruction ins = ih.getInstruction(); - if (ins instanceof FieldInstruction) { - FieldInstruction fi = (FieldInstruction) ins; - String fieldName = fi.getFieldName(cpg); - uncheckedFields.remove(fieldName); - - if (ins instanceof GETFIELD) { - localizableFields.remove(fieldName); - if (localizableFields.size() == 0) - return; - } else { - FieldInfo finfo = localizableFields.get(fieldName); - if (finfo != null) - finfo.setSrcLineAnnotation(SourceLineAnnotation.fromVisitedInstruction(clsContext, this, ih.getPosition())); - } - if (uncheckedFields.size() == 0) - return; - } - } + LinkedList<BlockState> toBeProcessed = new LinkedList<BlockState>(); + toBeProcessed.add(new BlockState(bb, uncheckedFields)); - if (uncheckedFields.size() > 0) { - Iterator<Edge> oei = cfg.outgoingEdgeIterator(bb); - while (oei.hasNext()) { - Edge e = oei.next(); - BasicBlock cb = e.getTarget(); - if (!visitedBlocks.get(cb.getId())) { - Set<String> subCheckedFields = new HashSet<String>(uncheckedFields); - checkBlock(cb, subCheckedFields); - if (localizableFields.size() == 0) + while (toBeProcessed.size() > 0) { + if (localizableFields.size() == 0) + return; + BlockState bState = toBeProcessed.removeFirst(); + bb = bState.getBasicBlock(); + uncheckedFields = bState.getUncheckedFields(); + + visitedBlocks.set(bb.getId()); + InstructionIterator ii = bb.instructionIterator(); + while (ii.hasNext()) { + InstructionHandle ih = ii.next(); + Instruction ins = ih.getInstruction(); + if (ins instanceof FieldInstruction) { + FieldInstruction fi = (FieldInstruction) ins; + String fieldName = fi.getFieldName(cpg); + uncheckedFields.remove(fieldName); + + if (ins instanceof GETFIELD) { + localizableFields.remove(fieldName); + if (localizableFields.size() == 0) + return; + } else { + FieldInfo finfo = localizableFields.get(fieldName); + if (finfo != null) + finfo.setSrcLineAnnotation(SourceLineAnnotation.fromVisitedInstruction(clsContext, this, ih.getPosition())); + } + if (uncheckedFields.size() == 0) return; + } + } + + if (uncheckedFields.size() > 0) { + Iterator<Edge> oei = cfg.outgoingEdgeIterator(bb); + while (oei.hasNext()) { + Edge e = oei.next(); + BasicBlock cb = e.getTarget(); + if (!visitedBlocks.get(cb.getId())) { + toBeProcessed.addLast(new BlockState(cb, uncheckedFields)); + } } } } } + /** + * holds information about a field and it's first usage + */ private static class FieldInfo { private FieldAnnotation fieldAnnotation; private SourceLineAnnotation srcLineAnnotation; + /** + * creates a FieldInfo from an annotation, and assumes no source line information + * @param fa the field annotation for this field + */ public FieldInfo(FieldAnnotation fa) { fieldAnnotation = fa; srcLineAnnotation = null; } + /** + * set the source line annotation of first use for this field + * @param sla the source line annotation + */ public void setSrcLineAnnotation(SourceLineAnnotation sla) { if (srcLineAnnotation == null) srcLineAnnotation = sla; } + /** + * get the field annotation for this field + * @return the field annotation + */ public FieldAnnotation getFieldAnnotation() { return fieldAnnotation; } + /** + * get the source line annotation for the first use of this field + * @return the source line annotation + */ public SourceLineAnnotation getSrcLineAnnotation() { return srcLineAnnotation; } } + + /** + * holds the parse state of the current basic block, and what fields are left to be checked + */ + private static class BlockState { + private BasicBlock basicBlock; + private Set<String> uncheckedFields; + + /** + * creates a BlockState consisting of the next basic block to parse, + * and what fields are to be checked + * @param bb the basic block to parse + * @param fields the fields to look for first use + */ + public BlockState(BasicBlock bb, Set<String> fields) { + basicBlock = bb; + uncheckedFields = new HashSet<String>(fields); + } + + /** + * get the basic block to parse + * @return the basic block + */ + public BasicBlock getBasicBlock() { + return basicBlock; + } + + /** + * get the unchecked fields to look for + * @return the unchecked fields + */ + public Set<String> getUncheckedFields() { + return uncheckedFields; + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-04 14:38:11
|
Revision: 396 Author: dbrosius Date: 2006-04-04 07:38:03 -0700 (Tue, 04 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=396&view=rev Log Message: ----------- Fix classpath's caused by move to svn Modified Paths: -------------- trunk/fb-contrib/.classpath Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2006-03-28 04:43:01 UTC (rev 395) +++ trunk/fb-contrib/.classpath 2006-04-04 14:38:03 UTC (rev 396) @@ -3,7 +3,7 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="samples"/> - <classpathentry sourcepath="O:/findbugs/src" kind="lib" path="O:/fb-contrib/lib/findbugs.jar"/> - <classpathentry sourcepath="O:/jakarta-bcel/trunk/src/java" kind="lib" path="O:/fb-contrib/lib/bcel.jar"/> + <classpathentry kind="lib" path="O:/fb-contrib/fb-contrib/lib/findbugs.jar"/> + <classpathentry kind="lib" path="O:/fb-contrib/fb-contrib/lib/bcel.jar"/> <classpathentry kind="output" path="classes"/> </classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Dave B. <dbr...@us...> - 2006-03-28 04:43:11
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27848/htdocs Modified Files: index.html Log Message: update FCBL info Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.77 retrieving revision 1.78 diff -u -d -r1.77 -r1.78 --- index.html 28 Mar 2006 02:22:19 -0000 1.77 +++ index.html 28 Mar 2006 04:43:01 -0000 1.78 @@ -57,8 +57,7 @@ block should help multithreaded performance.</li> <li><b>[FCBL] Field could be Local</b><br/> Looks for classes that declare fields that are used in a locals-only fashion, specifically private fields - or protected fields in final classes that are accessed first in each method with a store vs. a load. - These fields can be declared as one or more locals.</li> + that are accessed first in each method with a store vs. a load. These fields can be declared as one or more locals.</li> </ul> </div> <hr/> |
From: Dave B. <dbr...@us...> - 2006-03-28 04:42:10
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27594/src/com/mebigfatguy/fbcontrib/detect Modified Files: FieldCouldBeLocal.java Log Message: don't look at protected members Index: FieldCouldBeLocal.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- FieldCouldBeLocal.java 28 Mar 2006 02:38:53 -0000 1.5 +++ FieldCouldBeLocal.java 28 Mar 2006 04:42:07 -0000 1.6 @@ -49,8 +49,8 @@ import edu.umd.cs.findbugs.ba.BasicBlock.InstructionIterator; /** - * finds fields that are used in a locals only fashion, specifically private fields or protected fields - * in final classes that are accessed first in each method with a store vs. a load. + * finds fields that are used in a locals only fashion, specifically private fields + * that are accessed first in each method with a store vs. a load. */ public class FieldCouldBeLocal extends BytecodeScanningDetector implements StatelessDetector { @@ -95,7 +95,7 @@ boolean clsIsFinal = cls.isFinal(); Field[] fields = cls.getFields(); for (Field f : fields) { - if ((!f.isStatic() && f.getName().indexOf("$") < 0) && (f.isPrivate() || (clsIsFinal && f.isProtected()))) { + if ((!f.isStatic() && f.getName().indexOf("$") < 0) && f.isPrivate()) { FieldAnnotation fa = new FieldAnnotation(cls.getClassName(), f.getName(), f.getSignature(), false); localizableFields.put(f.getName(), new FieldInfo(fa)); } |
From: Dave B. <dbr...@us...> - 2006-03-28 04:42:10
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27594/etc Modified Files: messages.xml Log Message: don't look at protected members Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- messages.xml 27 Mar 2006 05:56:54 -0000 1.64 +++ messages.xml 28 Mar 2006 04:42:07 -0000 1.65 @@ -498,8 +498,8 @@ <Details> <![CDATA[ <p>looks for classes that define fields that are used in a locals only fashion, - specifically private fields or protected fields in final classes that are accessed - first in each method with a store vs. a load.</p> + specifically private fields that are accessed first in each method with a + store vs. a load.</p> <p>It is a fast detector</p> ]]> </Details> |
From: Dave B. <dbr...@us...> - 2006-03-28 02:38:57
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31169/src/com/mebigfatguy/fbcontrib/detect Modified Files: FieldCouldBeLocal.java Log Message: add SourceLineAnnotations for fields that are only accessed in ctors or static initializers Index: FieldCouldBeLocal.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FieldCouldBeLocal.java 28 Mar 2006 02:19:55 -0000 1.4 +++ FieldCouldBeLocal.java 28 Mar 2006 02:38:53 -0000 1.5 @@ -143,12 +143,35 @@ } /** - * implements the visitor to do nothing + * implements the visitor to pass through constructors and static initializers to the + * byte code scanning code. These methods are not reported, but are used to build + * SourceLineAnnotations for fields, if accessed. * * @param obj the context object of the currently parsed code attribute */ @Override public void visitCode(Code obj) { + String methodName = getMethodName(); + if ("<clinit".equals(methodName) || "<init>".equals(methodName)) + super.visitCode(obj); + } + + + /** + * implements the visitor to add SourceLineAnnotations for fields in constructors and static + * initializers. + * + * @param seen the opcode of the currently visited instruction + */ + public void sawOpcode(int seen) { + if ((seen == GETFIELD) || (seen == PUTFIELD)) { + String fieldName = getNameConstantOperand(); + FieldInfo fi = localizableFields.get(fieldName); + if (fi != null) { + SourceLineAnnotation sla = SourceLineAnnotation.fromVisitedInstruction(this); + fi.setSrcLineAnnotation(sla); + } + } } /** |
From: Dave B. <dbr...@us...> - 2006-03-28 02:23:43
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24185 Modified Files: build.xml Log Message: get ready for 2.6.0 dev Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- build.xml 14 Mar 2006 04:36:28 -0000 1.33 +++ build.xml 28 Mar 2006 02:23:38 -0000 1.34 @@ -18,7 +18,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="2.4.0"/> + <property name="fb-contrib.version" value="2.5.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |