fb-contrib-commit Mailing List for fb-contrib (Page 41)
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...> - 2007-02-06 05:16:30
|
Revision: 841 http://svn.sourceforge.net/fb-contrib/?rev=841&view=rev Author: dbrosius Date: 2007-02-05 21:16:30 -0800 (Mon, 05 Feb 2007) Log Message: ----------- when loading a collection from a field, keep track of what register the instance who's field is loaded is, to differentiate fields with same name, but different instances. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-02-06 03:50:33 UTC (rev 840) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-02-06 05:16:30 UTC (rev 841) @@ -280,7 +280,9 @@ else { XField field = itm.getXField(); if (field != null) { - groupElement = field.getName(); + int regLoad = itm.getFieldLoadedFromRegister(); + if (regLoad >= 0) + groupElement = field.getName() + "[" + regLoad + "]"; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-06 03:50:33
|
Revision: 840 http://svn.sourceforge.net/fb-contrib/?rev=840&view=rev Author: dbrosius Date: 2007-02-05 19:50:33 -0800 (Mon, 05 Feb 2007) Log Message: ----------- add DWI_MODIFYING_WHILE_ITERATING bug pattern to DWI Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/DWI_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2007-02-05 13:36:18 UTC (rev 839) +++ trunk/fb-contrib/etc/findbugs.xml 2007-02-06 03:50:33 UTC (rev 840) @@ -269,7 +269,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.DeletingWhileIterating" speed="fast" - reports="DWI_DELETING_WHILE_ITERATING" /> + reports="DWI_DELETING_WHILE_ITERATING,DWI_MODIFYING_WHILE_ITERATING" /> <Detector class="com.mebigfatguy.fbcontrib.detect.UseSplit" speed="fast" @@ -350,19 +350,20 @@ <BugPattern abbrev="URV" type="URV_CHANGE_RETURN_TYPE" category="STYLE" /> <BugPattern abbrev="URV" type="URV_INHERITED_METHOD_WITH_RELATED_TYPES" category="STYLE" /> <BugPattern abbrev="PIS" type="PIS_POSSIBLE_INCOMPLETE_SERIALIZATION" category="CORRECTNESS" /> - <BugPattern abbrev="SCRV" type="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="SPP" type="SPP_NEGATIVE_BITSET_ITEM" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="SPP" type="SPP_INTERN_ON_CONSTANT" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="SPP" type="SPP_NO_CHAR_SB_CTOR" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="SPP" type="SPP_USE_MATH_CONSTANT" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="SPP" type="SPP_STUTTERED_ASSIGNMENT" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="SPP" type="SPP_USE_ISNAN" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="SPP" type="SPP_USE_BIGDECIMAL_STRING_CTOR" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="SPP" type="SPP_STRINGBUFFER_WITH_EMPTY_STRING" category="PERFORMANCE" experimental="true" /> - <BugPattern abbrev="SPP" type="SPP_EQUALS_ON_ENUM" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" experimental="true" /> - <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR" category="STYLE" experimental="true" /> - <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="USS" type="USS_USE_STRING_SPLIT" category="STYLE" experimental="true" /> + <BugPattern abbrev="SCRV" type="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_NEGATIVE_BITSET_ITEM" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_INTERN_ON_CONSTANT" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_NO_CHAR_SB_CTOR" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_USE_MATH_CONSTANT" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_STUTTERED_ASSIGNMENT" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_USE_ISNAN" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_USE_BIGDECIMAL_STRING_CTOR" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_STRINGBUFFER_WITH_EMPTY_STRING" category="PERFORMANCE" /> + <BugPattern abbrev="SPP" type="SPP_EQUALS_ON_ENUM" category="CORRECTNESS" /> + <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" /> + <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR" category="STYLE" /> + <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" /> + <BugPattern abbrev="DWI" type="DWI_MODIFYING_WHILE_ITERATING" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="USS" type="USS_USE_STRING_SPLIT" category="STYLE" /> <BugPattern abbrev="SJVU" type="SJVU_SUSPICIOUS_JDK_VERSION_USE" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2007-02-05 13:36:18 UTC (rev 839) +++ trunk/fb-contrib/etc/messages.xml 2007-02-06 03:50:33 UTC (rev 840) @@ -1778,13 +1778,26 @@ <![CDATA[ <p>This method removes items from a collection using the remove method of the collection, while at the same time iterating across the collection. Doing this will invalidate the iterator, and further - user of it, will cause ConcurrentModificationExceptions to be thrown. To avoid this, the remove + use of it, will cause ConcurrentModificationExceptions to be thrown. To avoid this, the remove method of the iterator should be used. </p> ]]> </Details> </BugPattern> + <BugPattern type="DWI_MODIFYING_WHILE_ITERATING"> + <ShortDescription>Method modifies collection element while iterating</ShortDescription> + <LongDescription>Method {1} modifies collection element while iterating</LongDescription> + <Details> + <![CDATA[ + <p>This method modifies the contents of a collection using the collection api methods, while + at the same time iterating across the collection. Doing this will invalidate the iterator, and further + use of it, will cause ConcurrentModificationExceptions to be thrown. + </p> + ]]> + </Details> + </BugPattern> + <BugPattern type="USS_USE_STRING_SPLIT"> <ShortDescription>Method builds String array using String Tokenizing</ShortDescription> <LongDescription>Method {1} builds String array using String Tokenizing</LongDescription> Modified: trunk/fb-contrib/samples/DWI_Sample.java =================================================================== --- trunk/fb-contrib/samples/DWI_Sample.java 2007-02-05 13:36:18 UTC (rev 839) +++ trunk/fb-contrib/samples/DWI_Sample.java 2007-02-06 03:50:33 UTC (rev 840) @@ -1,3 +1,4 @@ +import java.util.Collection; import java.util.Iterator; import java.util.Set; @@ -13,4 +14,12 @@ bagOInts.remove(i); } } + + public void addIf(Set<String> s, Collection<String> c) { + for (String ss : s) + { + if (ss.equals("addem")) + s.addAll(c); + } + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-02-05 13:36:18 UTC (rev 839) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-02-06 03:50:33 UTC (rev 840) @@ -64,6 +64,18 @@ collectionMethods.add("keySet()Ljava/lang/Set;"); collectionMethods.add("values()Ljava/lang/Collection;"); } + private static final Set<String> modifyingMethods = new HashSet<String>(); + static { + modifyingMethods.add("add(Ljava/lang/Object;)Z"); + modifyingMethods.add("addAll(Ljava/util/Collection;)Z"); + modifyingMethods.add("addAll(ILjava/util/Collection;)Z"); + modifyingMethods.add("clear()V"); + modifyingMethods.add("remove(I)Ljava/lang/Object;"); + modifyingMethods.add("removeAll(Ljava/util/Collection;)Z"); + modifyingMethods.add("retainAll(Ljava/util/Collection;)Z"); + modifyingMethods.add("set(ILjava/lang/Object;)Ljava/lang/Object;"); + + } private BugReporter bugReporter; private OpcodeStack stack; @@ -164,6 +176,24 @@ } } } + } else if (modifyingMethods.contains(methodInfo)) { + if (stack.getStackDepth() > 1) { + OpcodeStack.Item itm = stack.getStackItem(1); + int id = findCollectionGroup(itm, true); + if (id >= 0) { + Integer it = groupToIterator.get(Integer14.valueOf(id)); + Loop loop = loops.get(it); + if (loop != null) { + int pc = getPC(); + if (loop.hasPC(pc)) { + bugReporter.reportBug(new BugInstance(this, "DWI_MODIFYING_WHILE_ITERATING", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } + } } } else if ("java/util/Iterator".equals(className) && "hasNext()Z".equals(methodInfo)) { if (stack.getStackDepth() > 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-05 13:36:25
|
Revision: 839 http://svn.sourceforge.net/fb-contrib/?rev=839&view=rev Author: dbrosius Date: 2007-02-05 05:36:18 -0800 (Mon, 05 Feb 2007) Log Message: ----------- made a copy Added Paths: ----------- tags/v3_2_2/ Copied: tags/v3_2_2 (from rev 838, trunk/fb-contrib) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-05 13:27:19
|
Revision: 838 http://svn.sourceforge.net/fb-contrib/?rev=838&view=rev Author: dbrosius Date: 2007-02-05 05:27:13 -0800 (Mon, 05 Feb 2007) Log Message: ----------- get ready for 3.2.2 Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2007-02-04 07:45:50 UTC (rev 837) +++ trunk/fb-contrib/build.xml 2007-02-05 13:27:13 UTC (rev 838) @@ -20,7 +20,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="3.2.1"/> + <property name="fb-contrib.version" value="3.2.2"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2007-02-04 07:45:50 UTC (rev 837) +++ trunk/fb-contrib/etc/findbugs.xml 2007-02-05 13:27:13 UTC (rev 838) @@ -277,7 +277,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousJDKVersionUse" speed="slow" - reports="SJVU_SUSPICIOUS_JDK_VERSION_USE" /> + reports="SJVU_SUSPICIOUS_JDK_VERSION_USE" + hidden="true" + disabled="true" /> <!-- BugPattern --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-04 07:45:50
|
Revision: 837 http://svn.sourceforge.net/fb-contrib/?rev=837&view=rev Author: dbrosius Date: 2007-02-03 23:45:50 -0800 (Sat, 03 Feb 2007) Log Message: ----------- better message Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-04 07:23:47 UTC (rev 836) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-04 07:45:50 UTC (rev 837) @@ -58,6 +58,15 @@ verRegEx.put(Integer14.valueOf(Constants.MAJOR_1_5), "(jdk|j2?re)1.5"); verRegEx.put(Integer14.valueOf(50), "(jdk|j2?re)1.6"); } + private static final Map<Integer, String> versionStrings = new HashMap<Integer, String>(); + static { + versionStrings.put(Integer14.valueOf(Constants.MAJOR_1_1), "JDK 1.1"); + versionStrings.put(Integer14.valueOf(Constants.MAJOR_1_2), "JDK 1.2"); + versionStrings.put(Integer14.valueOf(Constants.MAJOR_1_3), "JDK 1.3"); + versionStrings.put(Integer14.valueOf(Constants.MAJOR_1_4), "JDK 1.4"); + versionStrings.put(Integer14.valueOf(Constants.MAJOR_1_5), "JDK 1.5"); + versionStrings.put(Integer14.valueOf(50), "JDK 1.6"); + } private static final Pattern jarPattern = Pattern.compile("jar:file:/*([^!]*)"); private static final String SJVU_JDKHOME = "fb-contrib.sjvu.jdkhome"; @@ -90,7 +99,12 @@ jdkZip = new ZipFile(rtJar); super.visitClassContext(classContext); } else { - ClassNotFoundException cnfe = new ClassNotFoundException("The JDK rt.jar for class version " + clsMajorVersion + " was not found. The system property 'fb-contrib.sjvu.jdkhome' can be used to specify the location."); + String version = versionStrings.get(clsMajorVersion); + ClassNotFoundException cnfe; + if (version != null) + cnfe = new ClassNotFoundException("The " + version + " rt.jar was not found. This file is needed for finding invalid methods with the SuspiciousJDKVersionUse detector. The system property 'fb-contrib.sjvu.jdkhome' can be used to specify the location of the appropriate JDK."); + else + cnfe = new ClassNotFoundException("The JDK's rt.jar for classes with class version " + clsMajorVersion + " was not found. This file is needed for finding invalid methods with the SuspiciousJDKVersionUse detector. The system property 'fb-contrib.sjvu.jdkhome' can be used to specify the location of the appropriate JDK."); cnfe.fillInStackTrace(); bugReporter.reportMissingClass(cnfe); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-04 07:23:47
|
Revision: 836 http://svn.sourceforge.net/fb-contrib/?rev=836&view=rev Author: dbrosius Date: 2007-02-03 23:23:47 -0800 (Sat, 03 Feb 2007) Log Message: ----------- kruft cleanup Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-04 03:29:45 UTC (rev 835) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-04 07:23:47 UTC (rev 836) @@ -112,7 +112,6 @@ public void sawOpcode(int seen) { String clsName = null; - InputStream is = null; try { if ((seen == INVOKEVIRTUAL) //Interfaces are more difficult, ignore for now @@ -142,13 +141,6 @@ } } catch (Exception e) { // Hmm what to do - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException ioe) { - } - } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-04 03:29:45
|
Revision: 835 http://svn.sourceforge.net/fb-contrib/?rev=835&view=rev Author: dbrosius Date: 2007-02-03 19:29:45 -0800 (Sat, 03 Feb 2007) Log Message: ----------- add check for pattern new BoxedPrimitive(BoxedPrimitive.parseBoxedPrimitive("1")) Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2007-02-04 03:20:48 UTC (rev 834) +++ trunk/fb-contrib/etc/findbugs.xml 2007-02-04 03:29:45 UTC (rev 835) @@ -115,7 +115,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessAutoboxing" speed="fast" - reports="NAB_NEEDLESS_AUTOBOXING_CTOR,NAB_NEEDLESS_AUTOBOXING_VALUEOF,NAB_NEEDLESS_BOXING_PARSE,NAB_NEEDLESS_BOXING_VALUEOF" /> + reports="NAB_NEEDLESS_AUTOBOXING_CTOR,NAB_NEEDLESS_BOXING_STRING_CTOR,NAB_NEEDLESS_AUTOBOXING_VALUEOF,NAB_NEEDLESS_BOXING_PARSE,NAB_NEEDLESS_BOXING_VALUEOF" /> <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryStoreBeforeReturn" speed="fast" @@ -305,6 +305,7 @@ <BugPattern abbrev="SMII" type="SMII_STATIC_METHOD_INSTANCE_INVOCATION" category="STYLE" /> <BugPattern abbrev="STS" type="STS_SPURIOUS_THREAD_STATES" category="MT_CORRECTNESS" /> <BugPattern abbrev="NAB" type="NAB_NEEDLESS_AUTOBOXING_CTOR" category="PERFORMANCE" /> + <BugPattern abbrev="NAB" type="NAB_NEEDLESS_BOXING_STRING_CTOR" category="PERFORMANCE" /> <BugPattern abbrev="NAB" type="NAB_NEEDLESS_AUTOBOXING_VALUEOF" category="PERFORMANCE" /> <BugPattern abbrev="NAB" type="NAB_NEEDLESS_BOXING_PARSE" category="PERFORMANCE" /> <BugPattern abbrev="NAB" type="NAB_NEEDLESS_BOXING_VALUEOF" category="PERFORMANCE" /> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2007-02-04 03:20:48 UTC (rev 834) +++ trunk/fb-contrib/etc/messages.xml 2007-02-04 03:29:45 UTC (rev 835) @@ -1043,6 +1043,18 @@ ]]> </Details> </BugPattern> + + <BugPattern type="NAB_NEEDLESS_BOXING_STRING_CTOR"> + <ShortDescription>method passes parsed string to primitive wrapper constructor</ShortDescription> + <LongDescription>method {1} passes parsed string to primitive wrapper constructor</LongDescription> + <Details> + <![CDATA[ + <p>This method passes a primitive value retrieved from a BoxedPrimitive.parseBoxedPrimitive("1") call to + the same class's constructor. It is simpler to just pass the string to the BoxedPrimitives constructor. + </p> + ]]> + </Details> + </BugPattern> <BugPattern type="NAB_NEEDLESS_AUTOBOXING_VALUEOF"> <ShortDescription>method passes primitive wrapper to Wrapper class valueOf method</ShortDescription> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-02-04 03:20:48 UTC (rev 834) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-02-04 03:29:45 UTC (rev 835) @@ -167,6 +167,13 @@ .addSourceLine(this)); } } + } else if (seen == INVOKESPECIAL) { + if ("<init>".equals(getNameConstantOperand()) && (boxClass.equals(getClassConstantOperand()))) { + bugReporter.reportBug(new BugInstance(this, "NAB_NEEDLESS_BOXING_STRING_CTOR", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } } state = SEEN_NOTHING; break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-04 03:20:47
|
Revision: 834 http://svn.sourceforge.net/fb-contrib/?rev=834&view=rev Author: dbrosius Date: 2007-02-03 19:20:48 -0800 (Sat, 03 Feb 2007) Log Message: ----------- more tests to find Modified Paths: -------------- trunk/fb-contrib/samples/NAB_Sample.java Modified: trunk/fb-contrib/samples/NAB_Sample.java =================================================================== --- trunk/fb-contrib/samples/NAB_Sample.java 2007-02-04 03:19:07 UTC (rev 833) +++ trunk/fb-contrib/samples/NAB_Sample.java 2007-02-04 03:20:48 UTC (rev 834) @@ -55,11 +55,18 @@ public void testExtraneousParse() { Boolean bo = Boolean.valueOf(Boolean.parseBoolean("test")); + bo = new Boolean(Boolean.parseBoolean("test")); Byte b = Byte.valueOf(Byte.parseByte("1")); + b = new Byte(Byte.parseByte("1")); Short s = Short.valueOf(Short.parseShort("1")); + s = new Short(Short.parseShort("1")); Integer i = Integer.valueOf(Integer.parseInt("1")); + i = new Integer(Integer.parseInt("1")); Long l = Long.valueOf(Long.parseLong("1")); + l = new Long(Long.parseLong("1")); Float f = Float.valueOf(Float.parseFloat("1")); + f = new Float(Float.parseFloat("1")); Double d = Double.valueOf(Double.parseDouble("1")); + d = new Double(Double.parseDouble("1")); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-04 03:19:08
|
Revision: 833 http://svn.sourceforge.net/fb-contrib/?rev=833&view=rev Author: dbrosius Date: 2007-02-03 19:19:07 -0800 (Sat, 03 Feb 2007) Log Message: ----------- add check for pattern Boxed.valueOf(Boxed.parseBoxed("1")) Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2007-02-04 02:45:07 UTC (rev 832) +++ trunk/fb-contrib/etc/findbugs.xml 2007-02-04 03:19:07 UTC (rev 833) @@ -115,7 +115,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessAutoboxing" speed="fast" - reports="NAB_NEEDLESS_AUTOBOXING_CTOR,NAB_NEEDLESS_AUTOBOXING_VALUEOF,NAB_NEEDLESS_AUTOBOXING_PARSE" /> + reports="NAB_NEEDLESS_AUTOBOXING_CTOR,NAB_NEEDLESS_AUTOBOXING_VALUEOF,NAB_NEEDLESS_BOXING_PARSE,NAB_NEEDLESS_BOXING_VALUEOF" /> <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryStoreBeforeReturn" speed="fast" @@ -306,7 +306,8 @@ <BugPattern abbrev="STS" type="STS_SPURIOUS_THREAD_STATES" category="MT_CORRECTNESS" /> <BugPattern abbrev="NAB" type="NAB_NEEDLESS_AUTOBOXING_CTOR" category="PERFORMANCE" /> <BugPattern abbrev="NAB" type="NAB_NEEDLESS_AUTOBOXING_VALUEOF" category="PERFORMANCE" /> - <BugPattern abbrev="NAB" type="NAB_NEEDLESS_AUTOBOXING_PARSE" category="PERFORMANCE" /> + <BugPattern abbrev="NAB" type="NAB_NEEDLESS_BOXING_PARSE" category="PERFORMANCE" /> + <BugPattern abbrev="NAB" type="NAB_NEEDLESS_BOXING_VALUEOF" category="PERFORMANCE" /> <BugPattern abbrev="USBR" type="USBR_UNNECESSARY_STORE_BEFORE_RETURN" category="STYLE" /> <BugPattern abbrev="COM" type="COM_COPIED_OVERRIDDEN_METHOD" category="STYLE" /> <BugPattern abbrev="ABC" type="ABC_ARRAY_BASED_COLLECTIONS" category="CORRECTNESS" /> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2007-02-04 02:45:07 UTC (rev 832) +++ trunk/fb-contrib/etc/messages.xml 2007-02-04 03:19:07 UTC (rev 833) @@ -1057,9 +1057,9 @@ </Details> </BugPattern> - <BugPattern type="NAB_NEEDLESS_AUTOBOXING_PARSE"> - <ShortDescription>method converts String to primitive using excessive autoboxing</ShortDescription> - <LongDescription>method {1} converts String to primitive using excessive autoboxing</LongDescription> + <BugPattern type="NAB_NEEDLESS_BOXING_PARSE"> + <ShortDescription>method converts String to primitive using excessive boxing</ShortDescription> + <LongDescription>method {1} converts String to primitive using excessive boxing</LongDescription> <Details> <![CDATA[ <p>This method passes a String to a wrapped primitive object's valueOf method, which in turn calls @@ -1070,6 +1070,19 @@ </Details> </BugPattern> + <BugPattern type="NAB_NEEDLESS_BOXING_VALUEOF"> + <ShortDescription>method converts String to boxed primitive using excessive boxing</ShortDescription> + <LongDescription>method {1} converts String to boxed primitive using excessive boxing</LongDescription> + <Details> + <![CDATA[ + <p>This method passes a String to a wrapped primitive object's parse method, which in turn calls + the valueOf() method to convert to a boxed primitive. When it is desired to convert from a String + to a boxed primitive object, it is simpler to use the BoxedPrimitive.valueOf(myString) + method. </p> + ]]> + </Details> + </BugPattern> + <BugPattern type="USBR_UNNECESSARY_STORE_BEFORE_RETURN"> <ShortDescription>method stores return result in local before immediately returning it</ShortDescription> <LongDescription>method {1} stores return result in local before immediately returning it</LongDescription> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-02-04 02:45:07 UTC (rev 832) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-02-04 03:19:07 UTC (rev 833) @@ -36,19 +36,31 @@ private static final int SEEN_NOTHING = 0; private static final int SEEN_VALUE = 1; private static final int SEEN_VALUEOF = 2; + private static final int SEEN_PARSE = 3; private static final Map<String, String[]> boxClasses = new HashMap<String, String[]>(); static { boxClasses.put("java/lang/Boolean", new String[] { "booleanValue()Z", "(Z)V", "(Z)Ljava/lang/Boolean;" }); boxClasses.put("java/lang/Character", new String[] { "charValue()C", "(C)V", "(C)Ljava/lang/Character;" }); boxClasses.put("java/lang/Byte", new String[] { "byteValue()B", "(B)V", "(B)Ljava/lang/Byte;" }); - boxClasses.put("java.lang/Short", new String[] { "shortValue()S", "(S)V", "(S)Ljava/lang/Short;" }); + boxClasses.put("java/lang/Short", new String[] { "shortValue()S", "(S)V", "(S)Ljava/lang/Short;" }); boxClasses.put("java/lang/Integer", new String[] { "intValue()I", "(I)V", "(I)Ljava/lang/Integer;" }); boxClasses.put("java/lang/Long", new String[] { "longValue()J", "(J)V", "(J)Ljava/lang/Long;" }); boxClasses.put("java/lang/Float", new String[] { "floatValue()F", "(F)V", "(F)Ljava/lang/Float;" }); boxClasses.put("java/lang/Double", new String[] { "doubleValue()D", "(D)V", "(D)Ljava/lang/Double;" }); } + private static final Map<String, String> parseClasses = new HashMap<String, String>(); + static { + parseClasses.put("java/lang/Boolean", "parseBoolean(Ljava/lang/String;)Z"); + parseClasses.put("java/lang/Byte", "parseByte(Ljava/lang/String;)B"); + parseClasses.put("java/lang/Short", "parseShort(Ljava/lang/String;)S"); + parseClasses.put("java/lang/Integer", "parseInt(Ljava/lang/String;)I"); + parseClasses.put("java/lang/Long", "parseLong(Ljava/lang/String;)J"); + parseClasses.put("java/lang/Float", "parseFloat(Ljava/lang/String;)F"); + parseClasses.put("java/lang/Double", "parseDouble(Ljava/lang/String;)D"); + } + private BugReporter bugReporter; private int state; private String boxClass; @@ -75,12 +87,10 @@ boxClass = getClassConstantOperand(); String[] boxSigs = boxClasses.get(boxClass); if (boxSigs != null) { - String methodName = getNameConstantOperand(); - String methodSig = getSigConstantOperand(); - if (boxSigs[0].equals(methodName + methodSig)) { + String methodInfo = getNameConstantOperand() + getSigConstantOperand(); + if (boxSigs[0].equals(methodInfo)) { state = SEEN_VALUE; } - } } else if (seen == INVOKESTATIC) { boxClass = getClassConstantOperand(); @@ -88,6 +98,15 @@ if ("valueOf".equals(getNameConstantOperand()) && getSigConstantOperand().startsWith("(Ljava/lang/String;)")) { state = SEEN_VALUEOF; } + else { + String parseSig = parseClasses.get(boxClass); + if (parseSig != null) { + String methodInfo = getNameConstantOperand() + getSigConstantOperand(); + if (parseSig.equals(methodInfo)) { + state = SEEN_PARSE; + } + } + } } } break; @@ -129,7 +148,7 @@ if (seen == INVOKEVIRTUAL) { String[] boxSigs = boxClasses.get(boxClass); if (boxSigs[0].equals(getNameConstantOperand() + getSigConstantOperand())) { - bugReporter.reportBug(new BugInstance(this, "NAB_NEEDLESS_AUTOBOXING_PARSE", NORMAL_PRIORITY) + bugReporter.reportBug(new BugInstance(this, "NAB_NEEDLESS_BOXING_PARSE", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this)); @@ -137,6 +156,21 @@ } state = SEEN_NOTHING; break; + + case SEEN_PARSE: + if (seen == INVOKESTATIC) { + if (boxClass.equals(getClassConstantOperand())) { + if ("valueOf".equals(getNameConstantOperand())) { + bugReporter.reportBug(new BugInstance(this, "NAB_NEEDLESS_BOXING_VALUEOF", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } + state = SEEN_NOTHING; + break; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-04 02:45:12
|
Revision: 832 http://svn.sourceforge.net/fb-contrib/?rev=832&view=rev Author: dbrosius Date: 2007-02-03 18:45:07 -0800 (Sat, 03 Feb 2007) Log Message: ----------- remove {1} from short description Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2007-02-04 02:42:56 UTC (rev 831) +++ trunk/fb-contrib/etc/messages.xml 2007-02-04 02:45:07 UTC (rev 832) @@ -1781,7 +1781,7 @@ </BugPattern> <BugPattern type="SJVU_SUSPICIOUS_JDK_VERSION_USE"> - <ShortDescription>method {1} uses rt.jar class or method that does not exist</ShortDescription> + <ShortDescription>method uses rt.jar class or method that does not exist</ShortDescription> <LongDescription>method {1} uses rt.jar class or method that does not exist for the version the class is compiled for</LongDescription> <Details> <![CDATA[ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-04 02:42:58
|
Revision: 831 http://svn.sourceforge.net/fb-contrib/?rev=831&view=rev Author: dbrosius Date: 2007-02-03 18:42:56 -0800 (Sat, 03 Feb 2007) Log Message: ----------- add more tests to find Modified Paths: -------------- trunk/fb-contrib/samples/NAB_Sample.java Modified: trunk/fb-contrib/samples/NAB_Sample.java =================================================================== --- trunk/fb-contrib/samples/NAB_Sample.java 2007-02-02 08:22:17 UTC (rev 830) +++ trunk/fb-contrib/samples/NAB_Sample.java 2007-02-04 02:42:56 UTC (rev 831) @@ -51,4 +51,15 @@ float f = Float.valueOf(data).floatValue(); double d = Double.valueOf(data).doubleValue(); } + + public void testExtraneousParse() + { + Boolean bo = Boolean.valueOf(Boolean.parseBoolean("test")); + Byte b = Byte.valueOf(Byte.parseByte("1")); + Short s = Short.valueOf(Short.parseShort("1")); + Integer i = Integer.valueOf(Integer.parseInt("1")); + Long l = Long.valueOf(Long.parseLong("1")); + Float f = Float.valueOf(Float.parseFloat("1")); + Double d = Double.valueOf(Double.parseDouble("1")); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 08:22:19
|
Revision: 830 http://svn.sourceforge.net/fb-contrib/?rev=830&view=rev Author: dbrosius Date: 2007-02-02 00:22:17 -0800 (Fri, 02 Feb 2007) Log Message: ----------- SCII now doesn't complain about clone.. Not sure if this is the right thing to do. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java 2007-02-02 08:11:00 UTC (rev 829) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java 2007-02-02 08:22:17 UTC (rev 830) @@ -110,7 +110,7 @@ for (Method m : cls.getMethods()) { String methodName = m.getName(); - if (!"<init>".equals(methodName) && !"<clinit>".equals(methodName)) { + if (!"<init>".equals(methodName) && !"<clinit>".equals(methodName) && (!"clone".equals(methodName))) { methods.add(methodName + ":" + m.getSignature()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 08:11:02
|
Revision: 829 http://svn.sourceforge.net/fb-contrib/?rev=829&view=rev Author: dbrosius Date: 2007-02-02 00:11:00 -0800 (Fri, 02 Feb 2007) Log Message: ----------- hmm, twas wrong. can look at abstract classes, but for some reason method calls on abstract classes where the method is actually defined in an interface are still seen as INVOKEVIRTUAL, not INVOKEINTERFACE. So handle this. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 07:37:53 UTC (rev 828) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 08:11:00 UTC (rev 829) @@ -35,6 +35,7 @@ import java.util.zip.ZipFile; import org.apache.bcel.Constants; +import org.apache.bcel.Repository; import org.apache.bcel.classfile.ClassParser; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; @@ -80,9 +81,6 @@ public void visitClassContext(ClassContext classContext) { try { cls = classContext.getJavaClass(); - if (cls.isAbstract()) - return; - clsMajorVersion = Integer14.valueOf(cls.getMajor()); File rtJar = getRTJarFile(); if (rtJar == null) @@ -123,6 +121,10 @@ clsName = getClassConstantOperand(); if ((clsName.startsWith("java/")) || (clsName.startsWith("javax/"))) { + Method m = findCalledMethod(); + if (m == null) + return; + Map<String, Set<String>> validMethods = validMethodsByVersion.get(clsMajorVersion); if (validMethods == null) { validMethods = new HashMap<String, Set<String>>(); @@ -150,6 +152,25 @@ } } + private Method findCalledMethod() { + try { + JavaClass cls = Repository.lookupClass(getClassConstantOperand()); + Method[] methods = cls.getMethods(); + String calledMethod = getNameConstantOperand(); + String calledSignature = getSigConstantOperand(); + for (Method m : methods) { + if (m.getName().equals(calledMethod) && m.getSignature().equals(calledSignature)) { + return m; + } + } + + return null; + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + return null; + } + } + private boolean isValid(Map<String, Set<String>> validMethods, String clsName) throws IOException, ClassNotFoundException { InputStream is = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 07:37:53
|
Revision: 828 http://svn.sourceforge.net/fb-contrib/?rev=828&view=rev Author: dbrosius Date: 2007-02-01 23:37:53 -0800 (Thu, 01 Feb 2007) Log Message: ----------- don't check abstract classes Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:47:45 UTC (rev 827) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 07:37:53 UTC (rev 828) @@ -80,6 +80,9 @@ public void visitClassContext(ClassContext classContext) { try { cls = classContext.getJavaClass(); + if (cls.isAbstract()) + return; + clsMajorVersion = Integer14.valueOf(cls.getMajor()); File rtJar = getRTJarFile(); if (rtJar == null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 05:47:49
|
Revision: 827 http://svn.sourceforge.net/fb-contrib/?rev=827&view=rev Author: dbrosius Date: 2007-02-01 21:47:45 -0800 (Thu, 01 Feb 2007) Log Message: ----------- oi Modified Paths: -------------- trunk/fb-contrib/samples/OCP_Sample.java Modified: trunk/fb-contrib/samples/OCP_Sample.java =================================================================== --- trunk/fb-contrib/samples/OCP_Sample.java 2007-02-02 05:45:55 UTC (rev 826) +++ trunk/fb-contrib/samples/OCP_Sample.java 2007-02-02 05:47:45 UTC (rev 827) @@ -2,7 +2,6 @@ import java.awt.event.ActionListener; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.HashSet; import java.util.Iterator; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 05:45:55
|
Revision: 826 http://svn.sourceforge.net/fb-contrib/?rev=826&view=rev Author: dbrosius Date: 2007-02-01 21:45:55 -0800 (Thu, 01 Feb 2007) Log Message: ----------- remove unused vars Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:37:54 UTC (rev 825) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:45:55 UTC (rev 826) @@ -81,7 +81,7 @@ try { cls = classContext.getJavaClass(); clsMajorVersion = Integer14.valueOf(cls.getMajor()); - File rtJar = getRTJarFile(cls); + File rtJar = getRTJarFile(); if (rtJar == null) rtJar = getRTJarFromProperty(); @@ -206,7 +206,7 @@ } } - private File getRTJarFile(JavaClass cls){ + private File getRTJarFile(){ String versionStr = verRegEx.get(clsMajorVersion); if (versionStr == null) return null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 05:37:54
|
Revision: 825 http://svn.sourceforge.net/fb-contrib/?rev=825&view=rev Author: dbrosius Date: 2007-02-01 21:37:54 -0800 (Thu, 01 Feb 2007) Log Message: ----------- document SJVU Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2007-02-02 05:32:37 UTC (rev 824) +++ trunk/fb-contrib/htdocs/index.html 2007-02-02 05:37:54 UTC (rev 825) @@ -47,6 +47,17 @@ <img src="vbar.gif" height="12"/> <a href="bugdescriptions.html">Bug Descriptions</a> + <hr/> + <img id="svn_image" src="flip1.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> + Detectors add in svn<br/> + <div id="svn" style="display:none;"> + <ul> + <li><b>[SJVU] Suspicious JDK Version Use</b><br/> + Looks for calls to classes and methods that do not exist in the JDK for which this class is + compiled. This can happen if you specify the -source and -target options of the javac compiler, and + specify a target that is less than the jdk version of the javac compiler.</li> + </ul> + </div> <hr/> <img id="v3_2_0_image" src="flip2.gif" onClick="toggleBlock('v3_2_0', 'v3_2_0_image');" align="top"/> Detectors added in v3.2.0<br/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 05:32:38
|
Revision: 824 http://svn.sourceforge.net/fb-contrib/?rev=824&view=rev Author: dbrosius Date: 2007-02-01 21:32:37 -0800 (Thu, 01 Feb 2007) Log Message: ----------- add short/long description Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2007-02-02 05:31:01 UTC (rev 823) +++ trunk/fb-contrib/etc/messages.xml 2007-02-02 05:32:37 UTC (rev 824) @@ -1781,8 +1781,8 @@ </BugPattern> <BugPattern type="SJVU_SUSPICIOUS_JDK_VERSION_USE"> - <ShortDescription></ShortDescription> - <LongDescription></LongDescription> + <ShortDescription>method {1} uses rt.jar class or method that does not exist</ShortDescription> + <LongDescription>method {1} uses rt.jar class or method that does not exist for the version the class is compiled for</LongDescription> <Details> <![CDATA[ <p>This method calls a method that does not exist, on a class that does not exist in the jdk that This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 05:31:03
|
Revision: 823 http://svn.sourceforge.net/fb-contrib/?rev=823&view=rev Author: dbrosius Date: 2007-02-01 21:31:01 -0800 (Thu, 01 Feb 2007) Log Message: ----------- report when the old jdk home can't be found Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:26:19 UTC (rev 822) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:31:01 UTC (rev 823) @@ -88,6 +88,10 @@ if (rtJar != null) { jdkZip = new ZipFile(rtJar); super.visitClassContext(classContext); + } else { + ClassNotFoundException cnfe = new ClassNotFoundException("The JDK rt.jar for class version " + clsMajorVersion + " was not found. The system property 'fb-contrib.sjvu.jdkhome' can be used to specify the location."); + cnfe.fillInStackTrace(); + bugReporter.reportMissingClass(cnfe); } } catch (Exception ze) { // Hmm what to do? This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 05:26:21
|
Revision: 822 http://svn.sourceforge.net/fb-contrib/?rev=822&view=rev Author: dbrosius Date: 2007-02-01 21:26:19 -0800 (Thu, 01 Feb 2007) Log Message: ----------- allow for specifying the old jdk home thru system property Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:20:10 UTC (rev 821) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:26:19 UTC (rev 822) @@ -58,6 +58,7 @@ verRegEx.put(Integer14.valueOf(50), "(jdk|j2?re)1.6"); } private static final Pattern jarPattern = Pattern.compile("jar:file:/*([^!]*)"); + private static final String SJVU_JDKHOME = "fb-contrib.sjvu.jdkhome"; private Map<String, File> versionPaths; private Map<Integer, Map<String, Set<String>>> validMethodsByVersion; @@ -81,6 +82,9 @@ cls = classContext.getJavaClass(); clsMajorVersion = Integer14.valueOf(cls.getMajor()); File rtJar = getRTJarFile(cls); + if (rtJar == null) + rtJar = getRTJarFromProperty(); + if (rtJar != null) { jdkZip = new ZipFile(rtJar); super.visitClassContext(classContext); @@ -255,4 +259,19 @@ return null; } + + private File getRTJarFromProperty() { + String jdkHome = System.getProperty(SJVU_JDKHOME); + if (jdkHome == null) + return null; + + File rtJar = new File(jdkHome, "lib/rt.jar"); + if (rtJar.exists()) + return rtJar; + rtJar = new File(jdkHome, "jre/lib/rt.jar"); + if (rtJar.exists()) + return rtJar; + + return null; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 05:20:11
|
Revision: 821 http://svn.sourceforge.net/fb-contrib/?rev=821&view=rev Author: dbrosius Date: 2007-02-01 21:20:10 -0800 (Thu, 01 Feb 2007) Log Message: ----------- Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:18:10 UTC (rev 820) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:20:10 UTC (rev 821) @@ -185,6 +185,8 @@ else return isValid(validMethods, superNames.get(clsName)); } + + return true; } finally { if (is != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 05:18:11
|
Revision: 820 http://svn.sourceforge.net/fb-contrib/?rev=820&view=rev Author: dbrosius Date: 2007-02-01 21:18:10 -0800 (Thu, 01 Feb 2007) Log Message: ----------- guard against npes Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:15:46 UTC (rev 819) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:18:10 UTC (rev 820) @@ -176,13 +176,15 @@ } } - String wantedMethod = getNameConstantOperand() + getSigConstantOperand(); - if (methodInfos.contains(wantedMethod)) - return true; - else if ("java/lang/Object".equals(clsName)) - return false; - else - return isValid(validMethods, superNames.get(clsName)); + if (methodInfos != null) { + String wantedMethod = getNameConstantOperand() + getSigConstantOperand(); + if (methodInfos.contains(wantedMethod)) + return true; + else if ("java/lang/Object".equals(clsName)) + return false; + else + return isValid(validMethods, superNames.get(clsName)); + } } finally { if (is != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 05:15:46
|
Revision: 819 http://svn.sourceforge.net/fb-contrib/?rev=819&view=rev Author: dbrosius Date: 2007-02-01 21:15:46 -0800 (Thu, 01 Feb 2007) Log Message: ----------- guard against npes Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:14:33 UTC (rev 818) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:15:46 UTC (rev 819) @@ -231,19 +231,21 @@ } } - File[] possibleJdks = jdksRoot.listFiles(); - for (File possibleJdk : possibleJdks) { - Pattern verPat = Pattern.compile(versionStr); - Matcher m = verPat.matcher(possibleJdk.getName()); - if (m.find()) { - File wantedRtJar = new File(possibleJdk, "lib/rt.jar"); - if (!wantedRtJar.exists()) { - wantedRtJar = new File(possibleJdk, "jre/lib/rt.jar"); - if (!wantedRtJar.exists()) - return null; + if (jdksRoot != null) { + File[] possibleJdks = jdksRoot.listFiles(); + for (File possibleJdk : possibleJdks) { + Pattern verPat = Pattern.compile(versionStr); + Matcher m = verPat.matcher(possibleJdk.getName()); + if (m.find()) { + File wantedRtJar = new File(possibleJdk, "lib/rt.jar"); + if (!wantedRtJar.exists()) { + wantedRtJar = new File(possibleJdk, "jre/lib/rt.jar"); + if (!wantedRtJar.exists()) + return null; + } + versionPaths.put(versionStr, wantedRtJar); + return wantedRtJar; } - versionPaths.put(versionStr, wantedRtJar); - return wantedRtJar; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 05:14:32
|
Revision: 818 http://svn.sourceforge.net/fb-contrib/?rev=818&view=rev Author: dbrosius Date: 2007-02-01 21:14:33 -0800 (Thu, 01 Feb 2007) Log Message: ----------- add info for SJVU bug pattern/detector Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2007-02-02 05:06:53 UTC (rev 817) +++ trunk/fb-contrib/etc/messages.xml 2007-02-02 05:14:33 UTC (rev 818) @@ -685,6 +685,7 @@ <p>looks for class that implement Comparator or Comparable, and whose compare or compareTo methods return constant values only, but that don't represent the three possible choice (a negative number, 0, and a positive number).</p> + <p>It is a fast detector.</p> ]]> </Details> </Detector> @@ -693,6 +694,7 @@ <Details> <![CDATA[ <p>looks for a potpourri of small problems that do not fit into a common pattern.</p> + <p>It is a fast detector.</p> ]]> </Details> </Detector> @@ -703,6 +705,7 @@ <p><b>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</b> Looks for assignments to variables in a scope larger than it's use. As long as the evaluation of the assignment does not have side effects, the assignment can be moved into the inner scope where it is used.</p> + <p>It is a fast detector.</p> ]]> </Details> </Detector> @@ -713,6 +716,7 @@ <p>looks for classes that implement interfaces by relying on methods being implemented in superclasses, even tho the superclass knows nothing about the interface being implemented by the child.</p> + <p>It is a fast detector.</p> ]]> </Details> </Detector> @@ -724,6 +728,7 @@ of the collection at the same time that the collection is being iterated on. If this occurs the iterator will become invalid and throw a ConcurrentModificationException. Instead, the remove should be called on the iterator itself.</p> + <p>It is a fast detector.</p> ]]> </Details> </Detector> @@ -734,6 +739,7 @@ <p>looks for code that builds an array by using a StringTokenizer to break up a string and place individual elements into an array. It is simpler to use String.split instead.</p> + <p>It is a fast detector.</p> ]]> </Details> </Detector> @@ -741,6 +747,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousJDKVersionUse"> <Details> <![CDATA[ + <p>looks for calls to classes and methods that do not exist in the JDK for which this class is + compiled. This can happen if you specify the -source and -target options of the javac compiler, and + specify a target that is less than the jdk version of the javac compiler.</p> + <p>It is a slow detector.</p> ]]> </Details> </Detector> @@ -1775,6 +1785,9 @@ <LongDescription></LongDescription> <Details> <![CDATA[ + <p>This method calls a method that does not exist, on a class that does not exist in the jdk that + this class has been compiled for. This can happen if you compile the class specifying the -source and + -target options, and use a version that is before the version of the compiler's JDK.</p> ]]> </Details> </BugPattern> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-02 05:06:55
|
Revision: 817 http://svn.sourceforge.net/fb-contrib/?rev=817&view=rev Author: dbrosius Date: 2007-02-01 21:06:53 -0800 (Thu, 01 Feb 2007) Log Message: ----------- starting to work Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/samples/SJVU_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2007-02-01 09:38:22 UTC (rev 816) +++ trunk/fb-contrib/build.xml 2007-02-02 05:06:53 UTC (rev 817) @@ -81,6 +81,17 @@ <classpath refid="fb-contrib.classpath"/> <classpath refid="fb-contrib.samples.classpath"/> </javac> + <delete file="${samples.dir}/SJVU_Sample.class"/> + <javac srcdir="${samples.dir}" + destdir="${samples.dir}" + source="1.4" + target="1.4" + deprecation="${javac.deprecation}" + debug="${javac.debug}"> + <include name="SJVU_Sample.java"/> + <classpath refid="fb-contrib.classpath"/> + <classpath refid="fb-contrib.samples.classpath"/> + </javac> </target> <target name="jar" depends="compile" description="produces the fb-contrib jar file"> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2007-02-01 09:38:22 UTC (rev 816) +++ trunk/fb-contrib/etc/findbugs.xml 2007-02-02 05:06:53 UTC (rev 817) @@ -277,9 +277,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousJDKVersionUse" speed="slow" - reports="SJVU_SUSPICIOUS_JDK_VERSION_USE" - hidden="true" - disabled="true" /> + reports="SJVU_SUSPICIOUS_JDK_VERSION_USE" /> <!-- BugPattern --> Modified: trunk/fb-contrib/samples/SJVU_Sample.java =================================================================== --- trunk/fb-contrib/samples/SJVU_Sample.java 2007-02-01 09:38:22 UTC (rev 816) +++ trunk/fb-contrib/samples/SJVU_Sample.java 2007-02-02 05:06:53 UTC (rev 817) @@ -4,5 +4,9 @@ public void test14using15(int i) { Integer ii = Integer.valueOf(i); + StringBuilder sb = new StringBuilder(); + sb.append(ii.intValue()); } + + } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-01 09:38:22 UTC (rev 816) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2007-02-02 05:06:53 UTC (rev 817) @@ -18,12 +18,12 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.io.BufferedInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.net.MalformedURLException; +import java.io.UnsupportedEncodingException; import java.net.URL; -import java.net.URLClassLoader; import java.net.URLDecoder; import java.util.HashMap; import java.util.HashSet; @@ -31,6 +31,8 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; import org.apache.bcel.Constants; import org.apache.bcel.classfile.ClassParser; @@ -61,8 +63,8 @@ private Map<Integer, Map<String, Set<String>>> validMethodsByVersion; private Map<String, String> superNames; private File jdksRoot = null; - JavaClass cls; - private URLClassLoader jdkLoader; + private ZipFile jdkZip; + private JavaClass cls; private Integer clsMajorVersion; private BugReporter bugReporter; @@ -80,14 +82,20 @@ clsMajorVersion = Integer14.valueOf(cls.getMajor()); File rtJar = getRTJarFile(cls); if (rtJar != null) { - jdkLoader = new URLClassLoader(new URL[] {rtJar.toURL()}); + jdkZip = new ZipFile(rtJar); super.visitClassContext(classContext); } - } catch (MalformedURLException mue) { - //Hmm, what to do + } catch (Exception ze) { + // Hmm what to do? } finally { cls = null; - jdkLoader = null; + clsMajorVersion = null; + try { + if (jdkZip != null) + jdkZip.close(); + } catch (IOException ioe) { + } + jdkZip = null; } } @@ -98,8 +106,7 @@ InputStream is = null; try { - if ((seen == INVOKEVIRTUAL) - || (seen == INVOKEINTERFACE) + if ((seen == INVOKEVIRTUAL) //Interfaces are more difficult, ignore for now || (seen == INVOKESTATIC) || (seen == INVOKESPECIAL)) { clsName = getClassConstantOperand(); @@ -115,7 +122,8 @@ bugReporter.reportBug(new BugInstance(this, "SJVU_SUSPICIOUS_JDK_VERSION_USE", HIGH_PRIORITY) .addClass(this) .addMethod(this) - .addSourceLine(this)); + .addSourceLine(this) + .addCalledMethod(this)); } } } @@ -137,27 +145,35 @@ try { Set<String> methodInfos = validMethods.get(clsName); if (methodInfos == null) { - is = jdkLoader.getResourceAsStream(clsName + ".class"); - if (is != null) { - ClassParser parser = new ClassParser(is, clsName); - JavaClass calledClass = parser.parse(); - - superNames.put(clsName, calledClass.getSuperclassName().replace('.', '/')); - Method[] methods = calledClass.getMethods(); - - methodInfos = new HashSet<String>(); - validMethods.put(clsName, methodInfos); - - for (Method m : methods) { - if (!m.isPrivate()) + + ZipEntry ze = jdkZip.getEntry(clsName + ".class"); + if (ze != null) { + is = new BufferedInputStream(jdkZip.getInputStream(ze)); + if (is != null) { + ClassParser parser = new ClassParser(is, clsName); + JavaClass calledClass = parser.parse(); + + superNames.put(clsName, calledClass.getSuperclassName().replace('.', '/')); + Method[] methods = calledClass.getMethods(); + + methodInfos = new HashSet<String>(); + validMethods.put(clsName, methodInfos); + + for (Method m : methods) { methodInfos.add(m.getName() + m.getSignature()); + } + } - + else { + return true; + } + } else if (clsName.startsWith("java/")) { + bugReporter.reportBug(new BugInstance(this, "SJVU_SUSPICIOUS_JDK_VERSION_USE", HIGH_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this) + .addClass(clsName)); } - else { - return true; - } - } String wantedMethod = getNameConstantOperand() + getSigConstantOperand(); @@ -178,7 +194,7 @@ } } - private File getRTJarFile(JavaClass cls) { + private File getRTJarFile(JavaClass cls){ String versionStr = verRegEx.get(clsMajorVersion); if (versionStr == null) return null; @@ -205,7 +221,12 @@ if (jdksRoot.getParentFile() == null) return null; - jdksRoot = new File(URLDecoder.decode(jdksRoot.getParentFile().getPath())); + try { + String encoding = System.getProperty("file.encoding"); + jdksRoot = new File(URLDecoder.decode(jdksRoot.getParentFile().getPath(), encoding)); + } catch (UnsupportedEncodingException uee) { + return null; + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |