fb-contrib-commit Mailing List for fb-contrib (Page 49)
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-09-10 03:54:57
|
Revision: 640 http://svn.sourceforge.net/fb-contrib/?rev=640&view=rev Author: dbrosius Date: 2006-09-09 20:54:51 -0700 (Sat, 09 Sep 2006) Log Message: ----------- misc fixes suggested by fb-contrib Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2006-09-10 01:51:12 UTC (rev 639) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2006-09-10 03:54:51 UTC (rev 640) @@ -347,7 +347,7 @@ * @return the package of the class */ private String getPackageName(final String className) { - int dotPos = className.lastIndexOf("."); + int dotPos = className.lastIndexOf('.'); if (dotPos < 0) return ""; return className.substring(0, dotPos); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-09-10 01:51:12 UTC (rev 639) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-09-10 03:54:51 UTC (rev 640) @@ -85,7 +85,7 @@ JavaClass cls = classContext.getJavaClass(); Field[] fields = cls.getFields(); for (Field f : fields) { - if ((!f.isStatic() && f.getName().indexOf("$") < 0) && f.isPrivate()) { + 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)); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-09-10 01:51:12 UTC (rev 639) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-09-10 03:54:51 UTC (rev 640) @@ -189,8 +189,9 @@ String fieldInfo = fields.keySet().iterator().next(); - String fieldName = fieldInfo.substring(0, fieldInfo.indexOf(":")); - String fieldType = fieldInfo.substring(fieldInfo.indexOf(":")+1); + int colonPos = fieldInfo.indexOf(':'); + String fieldName = fieldInfo.substring(0, colonPos); + String fieldType = fieldInfo.substring(colonPos+1); if (!attType.equals(fieldType)) continue; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-10 01:51:20
|
Revision: 639 http://svn.sourceforge.net/fb-contrib/?rev=639&view=rev Author: dbrosius Date: 2006-09-09 18:51:12 -0700 (Sat, 09 Sep 2006) Log Message: ----------- better message Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-09-10 00:41:26 UTC (rev 638) +++ trunk/fb-contrib/etc/messages.xml 2006-09-10 01:51:12 UTC (rev 639) @@ -1479,7 +1479,9 @@ because this class does not take the responsibility of writing these fields out either using Serializable's writeObject method, or Externalizable's writeExternal method. Therefore when this class is read from a stream, the superclass fields - will only be initialized to the values specified in it's default constructor.</p> + will only be initialized to the values specified in it's default constructor. + If possible, change the superclass to implement Serializable, or implement + Serializable or Externalizable methods in the child class.</p> ]]> </Details> </BugPattern> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-10 00:41:38
|
Revision: 638 http://svn.sourceforge.net/fb-contrib/?rev=638&view=rev Author: dbrosius Date: 2006-09-09 17:41:26 -0700 (Sat, 09 Sep 2006) Log Message: ----------- initial checkin - PIS detector Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml Added Paths: ----------- trunk/fb-contrib/samples/PIS_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-09-08 23:18:40 UTC (rev 637) +++ trunk/fb-contrib/etc/findbugs.xml 2006-09-10 00:41:26 UTC (rev 638) @@ -246,6 +246,9 @@ speed="fast" reports="URV_UNRELATED_RETURN_VALUES,URV_CHANGE_RETURN_TYPE,URV_INHERITED_METHOD_WITH_RELATED_TYPES" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleIncompleteSerialization" + speed="fast" + reports="PIS_POSSIBLE_INCOMPLETE_SERIALIZATION" /> <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -309,4 +312,5 @@ <BugPattern abbrev="URV" type="URV_UNRELATED_RETURN_VALUES" category="STYLE" experimental="true" /> <BugPattern abbrev="URV" type="URV_CHANGE_RETURN_TYPE" category="STYLE" experimental="true" /> <BugPattern abbrev="URV" type="URV_INHERITED_METHOD_WITH_RELATED_TYPES" category="STYLE" experimental="true" /> + <BugPattern abbrev="PIS" type="PIS_POSSIBLE_INCOMPLETE_SERIALIZATION" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-09-08 23:18:40 UTC (rev 637) +++ trunk/fb-contrib/etc/messages.xml 2006-09-10 00:41:26 UTC (rev 638) @@ -664,6 +664,17 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleIncompleteSerialization"> + <Details> + <![CDATA[ + <p>looks for classes that don't handle serialization of parent class member fields + when the class in question is serializable but is derived from a non serializable + classes.</p> + <p>It is a fast detector.</p> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -1458,6 +1469,21 @@ </Details> </BugPattern> + <BugPattern type="PIS_POSSIBLE_INCOMPLETE_SERIALIZATION"> + <ShortDescription>Class doesn't serialize superclass fields</ShortDescription> + <LongDescription>Class {0} doesn't serialize superclass fields</LongDescription> + <Details> + <![CDATA[ + <p>This method implements Serializable but is derived from a + class that does not. The super class has fields that are not serialized + because this class does not take the responsibility of writing these fields out + either using Serializable's writeObject method, or Externalizable's writeExternal + method. Therefore when this class is read from a stream, the superclass fields + will only be initialized to the values specified in it's default constructor.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -1514,4 +1540,5 @@ <BugCode abbrev="UCPM">Use Character Parameterized Method</BugCode> <BugCode abbrev="TR">Tail Recursion</BugCode> <BugCode abbrev="URV">Unrelated Return Values</BugCode> + <BugCode abbrev="PIS">Possible Incomplete Serialization</BugCode> </MessageCollection> \ No newline at end of file Added: trunk/fb-contrib/samples/PIS_Sample.java =================================================================== --- trunk/fb-contrib/samples/PIS_Sample.java (rev 0) +++ trunk/fb-contrib/samples/PIS_Sample.java 2006-09-10 00:41:26 UTC (rev 638) @@ -0,0 +1,60 @@ +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +public class PIS_Sample +{ + public static void main(String[] args) + { + try + { + B b = new B(); + b.a = 100; + b.b = 100; + D d = new D(); + d.a = 100; + d.b = 100; + d.c = 100; + d.d = 100; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(b); + oos.writeObject(d); + oos.flush(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + ObjectInputStream ois = new ObjectInputStream(bais); + B b2 = (B)ois.readObject(); + D d2 = (D)ois.readObject(); + if ((b.a == b2.a) && (b.b == b2.b)) + System.out.println("Equal!"); + if ((d.a == d2.a) && (d.b == d2.b) && (d.c == d2.c) && (d.d == d2.d)) + System.out.println("Equal!"); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public static class A + { + public int a = 0; + } + + public static class B extends A implements Serializable + { + public int b = 1; + } + + public static class C extends B + { + public int c = 2; + } + + public static class D extends C + { + public int d = 3; + } +} Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java 2006-09-10 00:41:26 UTC (rev 638) @@ -0,0 +1,131 @@ +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2006 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.detect; + +import org.apache.bcel.classfile.Field; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.Detector; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * looks for classes that don't handle serialization of parent class member fields + * when the class in question is serializable but is derived from non serializable classes. + */ +public class PossibleIncompleteSerialization implements Detector +{ + private BugReporter bugReporter; + + /** + * constructs a PIS detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ + public PossibleIncompleteSerialization(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * implements the visitor to look for classes that are serializable, and are derived + * from non serializable classes and don't either implement methods in Externalizable + * or Serializable to save parent class fields. + * + * @param classContext the context object of the currently parsed class + */ + public void visitClassContext(ClassContext classContext) { + try { + JavaClass cls = classContext.getJavaClass(); + if (isSerializable(cls)) { + JavaClass superCls = cls.getSuperClass(); + if (!isSerializable(superCls)) { + if (hasSerializableFields(superCls)) { + if (!hasSerializingMethods(cls)) { + bugReporter.reportBug(new BugInstance(this, "PIS_POSSIBLE_INCOMPLETE_SERIALIZATION", NORMAL_PRIORITY) + .addClass(cls)); + } + } + } + + } + } catch (ClassNotFoundException cnfe) { + + } finally { + + } + + } + + /** + * returns if the class implements Serializable or Externalizable + * + * @return if the class implements Serializable or Externalizable + */ + private boolean isSerializable(JavaClass cls) throws ClassNotFoundException { + JavaClass[] infs = cls.getAllInterfaces(); + for (JavaClass inf : infs) { + String clsName = inf.getClassName(); + if ("java.io.Serializable".equals(clsName) + || "java.io.Externalizable".equals(clsName)) + return true; + } + return false; + } + + /** + * looks for fields that are candidates for serialization + * + * @arg class the class to look for fields + * @return if their is a field that looks like it should be serialized + */ + private boolean hasSerializableFields(JavaClass cls) { + Field[] fields = cls.getFields(); + for (Field f : fields) { + if (!f.isStatic() && !f.isTransient() && !f.isSynthetic()) + return true; + } + return false; + } + + /** + * looks to see if this class implements method described by Serializable or Externalizable + * + * @arg cls the class to examine for serializing methods + * @return whether the class handles it's own serializing/externalizing + */ + private boolean hasSerializingMethods(JavaClass cls) { + Method[] methods = cls.getMethods(); + for (Method m : methods) { + if (!m.isStatic()) { + String methodName = m.getName(); + String methodSig = m.getSignature(); + if ("writeObject".equals(methodName) + && "(Ljava/io/ObjectOutputStream;)V".equals(methodSig)) + return true; + if ("writeExternal".equals(methodName) + && "(Ljava/io/ObjectOutput;)V".equals(methodSig)) + return true; + } + } + return false; + } + public void report() { + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-08 23:18:49
|
Revision: 637 http://svn.sourceforge.net/fb-contrib/?rev=637&view=rev Author: dbrosius Date: 2006-09-08 16:18:40 -0700 (Fri, 08 Sep 2006) Log Message: ----------- if a localvariable table exists, and exception variable cannot be found in the table, then the catch block is empty, so ignore. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-09-07 22:24:54 UTC (rev 636) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-09-08 23:18:40 UTC (rev 637) @@ -183,7 +183,8 @@ try { CatchInfo catchInfo = it.next(); if (pc == catchInfo.getStart()) { - updateExceptionRegister(catchInfo, seen, pc); + if (!updateExceptionRegister(catchInfo, seen, pc)) + it.remove(); break; } else if (pc > catchInfo.getFinish()) { it.remove(); @@ -268,7 +269,18 @@ } } - private void updateExceptionRegister(CatchInfo ci, int seen, int pc) { + /** + * looks to update the catchinfo block with the register used for the + * exception variable. If their is a local variable table, but the local + * variable can't be found return false, signifying an empty catch block. + * + * @param ci the catchinfo record for the catch starting at this pc + * @param seen the opcode of the currently visited instruction + * @param pc the current pc + * + * @return whether the catch block is empty + */ + private boolean updateExceptionRegister(CatchInfo ci, int seen, int pc) { if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { int reg = RegisterUtils.getAStoreReg(this, seen); ci.setReg(reg); @@ -281,10 +293,20 @@ if (finish < ci.getFinish()) ci.setFinish(finish); } + else + return false; } } + return true; } + /** + * add a catch block info record for the catch block that is guessed to be + * in the range of start to finish + * + * @param start the handler pc + * @param finish the guessed end of the catch block + */ private void addCatchBlock(int start, int finish) { CatchInfo ci = new CatchInfo(start, finish); catchInfos.add(ci); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-07 22:25:00
|
Revision: 636 http://svn.sourceforge.net/fb-contrib/?rev=636&view=rev Author: dbrosius Date: 2006-09-07 15:24:54 -0700 (Thu, 07 Sep 2006) Log Message: ----------- reduce false positives in LEST by, not looking at finally blocks, and tossing previous catch blocks when pc = handlerpc. This removes some reports due to nested exceptions in catch blocks, but better than too liberal. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-09-04 21:36:43 UTC (rev 635) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-09-07 22:24:54 UTC (rev 636) @@ -163,14 +163,19 @@ int pc = getPC(); for (CodeException ex : exceptions) { if (pc == ex.getEndPC()) { - if ((seen >= IRETURN) && (seen <= RETURN)) - addCatchBlock(ex.getHandlerPC(), Integer.MAX_VALUE); - else if ((seen == GOTO) || (seen == GOTO_W)) - addCatchBlock(ex.getHandlerPC(), this.getBranchTarget()); - else - addCatchBlock(ex.getHandlerPC(), Integer.MAX_VALUE); + if (ex.getCatchType() != 0) + { + if ((seen >= IRETURN) && (seen <= RETURN)) + addCatchBlock(ex.getHandlerPC(), Integer.MAX_VALUE); + else if ((seen == GOTO) || (seen == GOTO_W)) + addCatchBlock(ex.getHandlerPC(), this.getBranchTarget()); + else + addCatchBlock(ex.getHandlerPC(), Integer.MAX_VALUE); + } return; - } + } else if (pc == ex.getHandlerPC()) { + removePreviousHandlers(pc); + } } Iterator<CatchInfo> it = catchInfos.iterator(); @@ -178,21 +183,8 @@ try { CatchInfo catchInfo = it.next(); if (pc == catchInfo.getStart()) { - if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { - int reg = RegisterUtils.getAStoreReg(this, seen); - catchInfo.setReg(reg); - exReg.put(Integer14.valueOf(reg), Boolean.TRUE); - LocalVariableTable lvt = getMethod().getLocalVariableTable(); - if (lvt != null) { - LocalVariable lv = lvt.getLocalVariable(reg, pc+2); - if (lv != null) { - int finish = lv.getStartPC() + lv.getLength(); - if (finish < catchInfo.getFinish()) - catchInfo.setFinish(finish); - } - } - break; - } + updateExceptionRegister(catchInfo, seen, pc); + break; } else if (pc > catchInfo.getFinish()) { it.remove(); break; @@ -265,6 +257,34 @@ } } + private void removePreviousHandlers(int pc) + { + //This unnecessarily squashes some nested catch blocks, but better than false positives + Iterator<CatchInfo> it = catchInfos.iterator(); + while (it.hasNext()) { + CatchInfo ci = it.next(); + if (ci.getStart() < pc) + it.remove(); + } + } + + private void updateExceptionRegister(CatchInfo ci, int seen, int pc) { + if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { + int reg = RegisterUtils.getAStoreReg(this, seen); + ci.setReg(reg); + exReg.put(Integer14.valueOf(reg), Boolean.TRUE); + LocalVariableTable lvt = getMethod().getLocalVariableTable(); + if (lvt != null) { + LocalVariable lv = lvt.getLocalVariable(reg, pc+2); + if (lv != null) { + int finish = lv.getStartPC() + lv.getLength(); + if (finish < ci.getFinish()) + ci.setFinish(finish); + } + } + } + } + private void addCatchBlock(int start, int finish) { CatchInfo ci = new CatchInfo(start, finish); catchInfos.add(ci); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-04 21:36:47
|
Revision: 635 http://svn.sourceforge.net/fb-contrib/?rev=635&view=rev Author: dbrosius Date: 2006-09-04 14:36:43 -0700 (Mon, 04 Sep 2006) Log Message: ----------- expand svn by default now Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-09-04 21:34:15 UTC (rev 634) +++ trunk/fb-contrib/htdocs/index.html 2006-09-04 21:36:43 UTC (rev 635) @@ -46,9 +46,9 @@ <a href="javadoc/index.html">JavaDoc</a> <hr/> - <img id="svn_image" src="flip1.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> + <img id="svn_image" src="flip2.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> Detectors added in svn<br/> - <div id="svn" style="display:none;"> + <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 @@ -68,10 +68,10 @@ </ul> </div> <hr/> - <img id="v2_8_0_image" src="flip2.gif" onClick="toggleBlock('v2_8_0', 'v2_8_0_image');" align="top"/> + <img id="v2_8_0_image" src="flip1.gif" onClick="toggleBlock('v2_8_0', 'v2_8_0_image');" align="top"/> Detectors added in v2.8.0<br/> Note: This version of fb-contrib requires FindBugs v1.0.0<br/> - <div id="v2_8_0" style="display:block;"> + <div id="v2_8_0" style="display:none;"> <ul> <li><b>[NMCS] Needless Member Collection Synchronization</b><br/> Looks for private collection members, either static or instance, that are only initialized in This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-04 21:34:21
|
Revision: 634 http://svn.sourceforge.net/fb-contrib/?rev=634&view=rev Author: dbrosius Date: 2006-09-04 14:34:15 -0700 (Mon, 04 Sep 2006) Log Message: ----------- document URV Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-09-04 05:57:35 UTC (rev 633) +++ trunk/fb-contrib/htdocs/index.html 2006-09-04 21:34:15 UTC (rev 634) @@ -62,6 +62,10 @@ Looks for methods that pass single character string constants as parameters to methods that alternatively have an overridden method that accepts a character instead. It is easier for the method to handle a single character than a String.</li> + <li><b>[URV] Unrelated Return Values</b><br/> + Looks for methods that return Object, and who's code body returns two or more + different types of objects that are unrelated (other than by Object).</li> + </ul> </div> <hr/> <img id="v2_8_0_image" src="flip2.gif" onClick="toggleBlock('v2_8_0', 'v2_8_0_image');" align="top"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-04 05:57:44
|
Revision: 633 http://svn.sourceforge.net/fb-contrib/?rev=633&view=rev Author: dbrosius Date: 2006-09-03 22:57:35 -0700 (Sun, 03 Sep 2006) Log Message: ----------- don't record null return values Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 05:32:59 UTC (rev 632) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 05:57:35 UTC (rev 633) @@ -137,7 +137,8 @@ if (seen == ARETURN) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); - returnTypes.put(itm.getJavaClass(), Integer14.valueOf(getPC())); + if (!itm.isNull()) + returnTypes.put(itm.getJavaClass(), Integer14.valueOf(getPC())); } } } catch (ClassNotFoundException cnfe) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-04 05:33:08
|
Revision: 632 http://svn.sourceforge.net/fb-contrib/?rev=632&view=rev Author: dbrosius Date: 2006-09-03 22:32:59 -0700 (Sun, 03 Sep 2006) Log Message: ----------- if java.lang.Object is one of the actual return types, then lower the priority. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 05:19:30 UTC (rev 631) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 05:32:59 UTC (rev 632) @@ -88,19 +88,27 @@ returnTypes.clear(); super.visitCode(obj); if (returnTypes.size() > 1) { + int priority = NORMAL_PRIORITY; + for (JavaClass cls : returnTypes.keySet()) { + if ((cls != null) && "java.lang.Object".equals(cls.getClassName())) { + priority = LOW_PRIORITY; + break; + } + } + JavaClass cls = findCommonType(returnTypes.keySet()); BugInstance bug = null; if ((cls != null) && !isInherited) { - bug = new BugInstance(this, "URV_CHANGE_RETURN_TYPE", NORMAL_PRIORITY) + bug = new BugInstance(this, "URV_CHANGE_RETURN_TYPE", priority) .addClass(this) .addMethod(this); bug.addString(cls.getClassName()); } else if (!isInherited) { - bug = new BugInstance(this, "URV_UNRELATED_RETURN_VALUES", NORMAL_PRIORITY) + bug = new BugInstance(this, "URV_UNRELATED_RETURN_VALUES", priority) .addClass(this) .addMethod(this); } else { - bug = new BugInstance(this, "URV_INHERITED_METHOD_WITH_RELATED_TYPES", NORMAL_PRIORITY) + bug = new BugInstance(this, "URV_INHERITED_METHOD_WITH_RELATED_TYPES", priority) .addClass(this) .addMethod(this); if (cls != null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-04 05:19:34
|
Revision: 631 http://svn.sourceforge.net/fb-contrib/?rev=631&view=rev Author: dbrosius Date: 2006-09-03 22:19:30 -0700 (Sun, 03 Sep 2006) Log Message: ----------- safer code for inherited methods Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 05:18:44 UTC (rev 630) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 05:19:30 UTC (rev 631) @@ -102,8 +102,9 @@ } else { bug = new BugInstance(this, "URV_INHERITED_METHOD_WITH_RELATED_TYPES", NORMAL_PRIORITY) .addClass(this) - .addMethod(this); - bug.addString(cls.getClassName()); + .addMethod(this); + if (cls != null) + bug.addString(cls.getClassName()); } if (bug != null) { for (Integer pc : returnTypes.values()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-04 05:18:48
|
Revision: 630 http://svn.sourceforge.net/fb-contrib/?rev=630&view=rev Author: dbrosius Date: 2006-09-03 22:18:44 -0700 (Sun, 03 Sep 2006) Log Message: ----------- more info for inherited methods Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 04:54:14 UTC (rev 629) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 05:18:44 UTC (rev 630) @@ -103,6 +103,7 @@ bug = new BugInstance(this, "URV_INHERITED_METHOD_WITH_RELATED_TYPES", NORMAL_PRIORITY) .addClass(this) .addMethod(this); + bug.addString(cls.getClassName()); } if (bug != null) { for (Integer pc : returnTypes.values()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-04 04:54:27
|
Revision: 629 http://svn.sourceforge.net/fb-contrib/?rev=629&view=rev Author: dbrosius Date: 2006-09-03 21:54:14 -0700 (Sun, 03 Sep 2006) Log Message: ----------- add another URV bug pattern to be more clear Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-09-04 04:29:23 UTC (rev 628) +++ trunk/fb-contrib/etc/findbugs.xml 2006-09-04 04:54:14 UTC (rev 629) @@ -244,7 +244,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedReturnValues" speed="fast" - reports="URV_UNRELATED_RETURN_VALUES,URV_CHANGE_RETURN_TYPE" /> + reports="URV_UNRELATED_RETURN_VALUES,URV_CHANGE_RETURN_TYPE,URV_INHERITED_METHOD_WITH_RELATED_TYPES" /> <!-- BugPattern --> @@ -308,5 +308,5 @@ <BugPattern abbrev="TR" type="TR_TAIL_RECURSION" category="PERFORMANCE" experimental="true" /> <BugPattern abbrev="URV" type="URV_UNRELATED_RETURN_VALUES" category="STYLE" experimental="true" /> <BugPattern abbrev="URV" type="URV_CHANGE_RETURN_TYPE" category="STYLE" experimental="true" /> - + <BugPattern abbrev="URV" type="URV_INHERITED_METHOD_WITH_RELATED_TYPES" 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-09-04 04:29:23 UTC (rev 628) +++ trunk/fb-contrib/etc/messages.xml 2006-09-04 04:54:14 UTC (rev 629) @@ -1422,20 +1422,19 @@ </BugPattern> <BugPattern type="URV_UNRELATED_RETURN_VALUES"> - <ShortDescription>Derived method returns different types of unrelated Objects</ShortDescription> - <LongDescription>Derived method {1} returns different types of unrelated Objects</LongDescription> + <ShortDescription>Method returns different types of unrelated Objects</ShortDescription> + <LongDescription>Method {1} returns different types of unrelated Objects</LongDescription> <Details> <![CDATA[ - <p>This method, which is derived from a superclass, or interface, returns two or - more unrelated types of objects. This will be very confusing to the code that must - call it.</p> + <p>This method returns two or more unrelated types of objects (Related only through java.lang.Object). + This will be very confusing to the code that must call it.</p> ]]> </Details> </BugPattern> <BugPattern type="URV_CHANGE_RETURN_TYPE"> - <ShortDescription>Method returns different types of unrelated Objects</ShortDescription> - <LongDescription>Method {1} returns different types of unrelated Objects</LongDescription> + <ShortDescription>Method returns more specific type of object than declared</ShortDescription> + <LongDescription>Method {1} returns more specific type of object than declared</LongDescription> <Details> <![CDATA[ <p>This method is defined to return a java.lang.Object. However, the return types @@ -1445,6 +1444,20 @@ ]]> </Details> </BugPattern> + + <BugPattern type="URV_INHERITED_METHOD_WITH_RELATED_TYPES"> + <ShortDescription>Inherited method returns more specific type of object than declared</ShortDescription> + <LongDescription>Inherited method {1} returns more specific type of object than declared</LongDescription> + <Details> + <![CDATA[ + <p>This inherited method is defined to return a java.lang.Object. However, the return types returned + from this method can be defined by a more specific class or interface. If possible consider changing the + return type in the inheritance hierarchy of this method, otherwise the caller of this method will be brittle + in handling of the return type.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 04:29:23 UTC (rev 628) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 04:54:14 UTC (rev 629) @@ -95,10 +95,14 @@ .addClass(this) .addMethod(this); bug.addString(cls.getClassName()); - } else { + } else if (!isInherited) { bug = new BugInstance(this, "URV_UNRELATED_RETURN_VALUES", NORMAL_PRIORITY) .addClass(this) .addMethod(this); + } else { + bug = new BugInstance(this, "URV_INHERITED_METHOD_WITH_RELATED_TYPES", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this); } if (bug != null) { for (Integer pc : returnTypes.values()) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2006-09-04 04:29:23 UTC (rev 628) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2006-09-04 04:54:14 UTC (rev 629) @@ -31,7 +31,7 @@ JavaClass[] supers = cls.getSuperClasses(); for (int i = 0; i < supers.length; i++) { - if (supers[i].getClassName().equals("java/lang/Object")) { + if (supers[i].getClassName().equals("java.lang.Object")) { supers[i] = null; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-04 04:29:27
|
Revision: 628 http://svn.sourceforge.net/fb-contrib/?rev=628&view=rev Author: dbrosius Date: 2006-09-03 21:29:23 -0700 (Sun, 03 Sep 2006) Log Message: ----------- fix array return value handling Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 04:08:09 UTC (rev 627) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 04:29:23 UTC (rev 628) @@ -90,15 +90,15 @@ if (returnTypes.size() > 1) { JavaClass cls = findCommonType(returnTypes.keySet()); BugInstance bug = null; - if ((cls == null) || isInherited) { - bug = new BugInstance(this, "URV_UNRELATED_RETURN_VALUES", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this); - } else if (!isInherited) { + if ((cls != null) && !isInherited) { bug = new BugInstance(this, "URV_CHANGE_RETURN_TYPE", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this); + .addClass(this) + .addMethod(this); bug.addString(cls.getClassName()); + } else { + bug = new BugInstance(this, "URV_UNRELATED_RETURN_VALUES", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this); } if (bug != null) { for (Integer pc : returnTypes.values()) { @@ -144,6 +144,9 @@ classes.remove("java/lang/Object"); boolean populate = true; for (JavaClass cls : classes) { + if (cls == null) { //array + return null; + } JavaClass[] infs = cls.getAllInterfaces(); JavaClass[] supers = cls.getSuperClasses(); if (populate) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-04 04:08:24
|
Revision: 627 http://svn.sourceforge.net/fb-contrib/?rev=627&view=rev Author: dbrosius Date: 2006-09-03 21:08:09 -0700 (Sun, 03 Sep 2006) Log Message: ----------- initial checkin, new URV detector Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml Added Paths: ----------- trunk/fb-contrib/samples/URV_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-09-04 03:08:46 UTC (rev 626) +++ trunk/fb-contrib/etc/findbugs.xml 2006-09-04 04:08:09 UTC (rev 627) @@ -242,6 +242,10 @@ speed="fast" reports="TR_TAIL_RECURSION" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedReturnValues" + speed="fast" + reports="URV_UNRELATED_RETURN_VALUES,URV_CHANGE_RETURN_TYPE" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -302,4 +306,7 @@ <BugPattern abbrev="LEST" type="LEST_LOST_EXCEPTION_STACK_TRACE" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="UCPM" type="UCPM_USE_CHARACTER_PARAMETERIZED_METHOD" category="PERFORMANCE" experimental="true" /> <BugPattern abbrev="TR" type="TR_TAIL_RECURSION" category="PERFORMANCE" experimental="true" /> + <BugPattern abbrev="URV" type="URV_UNRELATED_RETURN_VALUES" category="STYLE" experimental="true" /> + <BugPattern abbrev="URV" type="URV_CHANGE_RETURN_TYPE" 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-09-04 03:08:46 UTC (rev 626) +++ trunk/fb-contrib/etc/messages.xml 2006-09-04 04:08:09 UTC (rev 627) @@ -652,7 +652,18 @@ ]]> </Details> </Detector> - + + <Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedReturnValues"> + <Details> + <![CDATA[ + <p>looks for methods that are defined to return Object, and return different types of + objects based on different code paths. If this method is not based on a interface or + superclass, it is suggested to change the return type to a type that would accomodate + all kinds of return types.</p> + <p>It is a fast detector.</p> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -1405,11 +1416,35 @@ <![CDATA[ <p>This method recursively calls itself as the last statement of the method (Tail Recursion). This method can be easily refactored into a simple loop, which - will make it more performant, and reduce the stack size requirements. + will make it more performant, and reduce the stack size requirements.</p> ]]> </Details> </BugPattern> + <BugPattern type="URV_UNRELATED_RETURN_VALUES"> + <ShortDescription>Derived method returns different types of unrelated Objects</ShortDescription> + <LongDescription>Derived method {1} returns different types of unrelated Objects</LongDescription> + <Details> + <![CDATA[ + <p>This method, which is derived from a superclass, or interface, returns two or + more unrelated types of objects. This will be very confusing to the code that must + call it.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="URV_CHANGE_RETURN_TYPE"> + <ShortDescription>Method returns different types of unrelated Objects</ShortDescription> + <LongDescription>Method {1} returns different types of unrelated Objects</LongDescription> + <Details> + <![CDATA[ + <p>This method is defined to return a java.lang.Object. However, the return types + returned from this method can be defined by a more specific class or interface. Since this + method is not derived from a superclass or interface, it would be more clear to + change the return type of this method.</p> + ]]> + </Details> + </BugPattern> <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -1465,4 +1500,5 @@ <BugCode abbrev="LEST">Lost Exception Stack Trace</BugCode> <BugCode abbrev="UCPM">Use Character Parameterized Method</BugCode> <BugCode abbrev="TR">Tail Recursion</BugCode> + <BugCode abbrev="URV">Unrelated Return Values</BugCode> </MessageCollection> \ No newline at end of file Added: trunk/fb-contrib/samples/URV_Sample.java =================================================================== --- trunk/fb-contrib/samples/URV_Sample.java (rev 0) +++ trunk/fb-contrib/samples/URV_Sample.java 2006-09-04 04:08:09 UTC (rev 627) @@ -0,0 +1,37 @@ +import java.util.HashSet; +import java.util.TreeSet; + +public class URV_Sample extends URV_Super +{ + public Object getASet(boolean b) + { + if (b) + return new HashSet(); + else + return new TreeSet(); + } + + public Object getInfo(boolean b) + { + if (b) + return new String[4]; + else + return ""; + } + + public Object getInheritedInfo(boolean b) + { + if (b) + return new Integer(1); + else + return new Float(1.0); + } +} + +class URV_Super +{ + public Object getInheritedInfo(boolean b) + { + return null; + } +} Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 04:08:09 UTC (rev 627) @@ -0,0 +1,171 @@ +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2006 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.detect; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; + +import com.mebigfatguy.fbcontrib.utils.Integer14; +import com.mebigfatguy.fbcontrib.utils.SignatureUtils; + +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.ba.ClassContext; + +/** + * looks for methods that return Object, and who's code body returns two or more + * different types of objects that are unrelated (other than by Object). + */ +public class UnrelatedReturnValues extends BytecodeScanningDetector +{ + private BugReporter bugReporter; + private OpcodeStack stack; + private JavaClass currentClass; + private Map<JavaClass, Integer> returnTypes; + private boolean isInherited; + + /** + * constructs a URV detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ + public UnrelatedReturnValues(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + public void visitClassContext(ClassContext classContext) { + try { + currentClass = classContext.getJavaClass(); + stack = new OpcodeStack(); + returnTypes = new HashMap<JavaClass, Integer>(); + super.visitClassContext(classContext); + } + finally { + currentClass = null; + stack = null; + returnTypes = null; + } + } + /** + * implements the visitor to see if the method returns Object, and if the method + * is defined in a superclass, or interface. + * + * @param obj the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + try { + Method m = getMethod(); + String methodName = m.getName(); + String signature = m.getSignature(); + if (signature.endsWith(")Ljava/lang/Object;")) { + isInherited = SignatureUtils.isInheritedMethod(currentClass, methodName, signature); + stack.resetForMethodEntry(this); + returnTypes.clear(); + super.visitCode(obj); + if (returnTypes.size() > 1) { + JavaClass cls = findCommonType(returnTypes.keySet()); + BugInstance bug = null; + if ((cls == null) || isInherited) { + bug = new BugInstance(this, "URV_UNRELATED_RETURN_VALUES", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this); + } else if (!isInherited) { + bug = new BugInstance(this, "URV_CHANGE_RETURN_TYPE", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this); + bug.addString(cls.getClassName()); + } + if (bug != null) { + for (Integer pc : returnTypes.values()) { + bug.addSourceLine(this, pc.intValue()); + } + bugReporter.reportBug(bug); + } + } + } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + } + } + + /** + * implements the visitor to find return values where the types of objects returned from the + * method are related only by object. + */ + public void sawOpcode(int seen) { + try { + stack.mergeJumps(this); + if (seen == ARETURN) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + returnTypes.put(itm.getJavaClass(), Integer14.valueOf(getPC())); + } + } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + } finally { + stack.sawOpcode(this, seen); + } + } + + /** + * looks for a common superclass or interface for all the passed in types + * + * @param types the set of classes to look for a common super class or interface + * @return the type that is the common interface or superclass (not Object, tho). + */ + public JavaClass findCommonType(Set<JavaClass> classes) throws ClassNotFoundException { + Set<JavaClass> possibleCommonTypes = new HashSet<JavaClass>(); + classes.remove("java/lang/Object"); + boolean populate = true; + for (JavaClass cls : classes) { + JavaClass[] infs = cls.getAllInterfaces(); + JavaClass[] supers = cls.getSuperClasses(); + if (populate) { + possibleCommonTypes.addAll(Arrays.asList(infs)); + possibleCommonTypes.addAll(Arrays.asList(supers)); + possibleCommonTypes.remove("java/lang/Object"); + populate = false; + } else { + Set<JavaClass> retain = new HashSet<JavaClass>(); + retain.addAll(Arrays.asList(infs)); + retain.addAll(Arrays.asList(supers)); + possibleCommonTypes.retainAll(retain); + } + } + + if (possibleCommonTypes.size() == 0) + return null; + + for (JavaClass cls : possibleCommonTypes) { + if (cls.isInterface()) + return cls; + } + return possibleCommonTypes.iterator().next(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-04 03:08:51
|
Revision: 626 http://svn.sourceforge.net/fb-contrib/?rev=626&view=rev Author: dbrosius Date: 2006-09-03 20:08:46 -0700 (Sun, 03 Sep 2006) Log Message: ----------- collection of methods to help with method signatures. Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2006-09-04 03:08:46 UTC (rev 626) @@ -0,0 +1,57 @@ +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2006 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.utils; + +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; + +public class SignatureUtils { + + public static boolean isInheritedMethod(JavaClass cls, String methodName, String signature) throws ClassNotFoundException { + JavaClass[] infs = cls.getAllInterfaces(); + if (findInheritedMethod(infs, methodName, signature) != null) { + return true; + } + + JavaClass[] supers = cls.getSuperClasses(); + for (int i = 0; i < supers.length; i++) { + if (supers[i].getClassName().equals("java/lang/Object")) { + supers[i] = null; + } + } + return findInheritedMethod(supers, methodName, signature) != null; + } + + private static JavaClass findInheritedMethod(JavaClass[] classes, String methodName, String signature) { + for (JavaClass cls : classes) { + if (cls != null) { + Method[] methods = cls.getMethods(); + for (Method m : methods) { + if (!m.isPrivate()) { + if (m.getName().equals(methodName)) { + if (m.getSignature().equals(signature)) + return cls; + } + } + } + } + } + return null; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-09-03 20:51:03
|
Revision: 625 http://svn.sourceforge.net/fb-contrib/?rev=625&view=rev Author: dbrosius Date: 2006-09-03 13:50:45 -0700 (Sun, 03 Sep 2006) Log Message: ----------- filter out tricky false positives due to trinaries in ISB Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2006-08-27 00:47:59 UTC (rev 624) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2006-09-03 20:50:45 UTC (rev 625) @@ -99,18 +99,22 @@ || "java/lang/StringBuilder".equals(calledClass)) && "append".equals(getNameConstantOperand()) && getSigConstantOperand().startsWith("(Ljava/lang/String;)")) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item itm = stack.getStackItem(0); - Object cons = itm.getConstant(); - if ((cons instanceof String) && (itm.getRegisterNumber() < 0)) { - if (((String)cons).length() == 0) { - bugReporter.reportBug( - new BugInstance(this, "ISB_EMPTY_STRING_APPENDING", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } + if (stack.getStackDepth() > 1) { + OpcodeStack.Item sbItm = stack.getStackItem(1); + if ((sbItm != null) && (sbItm.getUserValue() == null)) + { + OpcodeStack.Item itm = stack.getStackItem(0); + Object cons = itm.getConstant(); + if ((cons instanceof String) && (itm.getRegisterNumber() < 0)) { + if (((String)cons).length() == 0) { + bugReporter.reportBug( + new BugInstance(this, "ISB_EMPTY_STRING_APPENDING", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-27 00:48:06
|
Revision: 624 Author: dbrosius Date: 2006-08-26 17:47:59 -0700 (Sat, 26 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=624&view=rev Log Message: ----------- fix some false positives Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-08-22 05:30:19 UTC (rev 623) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-08-27 00:47:59 UTC (rev 624) @@ -195,7 +195,7 @@ OpcodeStack.Item item = stack.getStackItem(1); FieldAnnotation fa = item.getField(); if (fa != null) - fieldLabels.remove(fa.getFieldName()); + fieldLabels.remove(fa); else { int reg = item.getRegisterNumber(); if (reg >= 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-22 05:30:24
|
Revision: 623 Author: dbrosius Date: 2006-08-21 22:30:19 -0700 (Mon, 21 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=623&view=rev Log Message: ----------- Fix Date Compare's SEEN_NOTHING state handling Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java 2006-08-21 02:47:24 UTC (rev 622) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java 2006-08-22 05:30:19 UTC (rev 623) @@ -90,11 +90,10 @@ public void sawOpcode(int seen) { switch (state) { case SEEN_NOTHING: - if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) + if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { register1_1 = RegisterUtils.getALoadReg(this, seen); - - if (register1_1 > -1) state = SEEN_LOAD1_1; + } break; case SEEN_LOAD1_1: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-21 02:47:30
|
Revision: 622 Author: dbrosius Date: 2006-08-20 19:47:24 -0700 (Sun, 20 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=622&view=rev Log Message: ----------- Remove some false positives due to a DOM node being loaded, and method called on it, leaving an entry in the nodeCreations map. Now remove entries when a method is called on it, as the DOM api, never leaves this on the stack. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java 2006-08-20 00:41:27 UTC (rev 621) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java 2006-08-21 02:47:24 UTC (rev 622) @@ -27,6 +27,7 @@ import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.Integer14; +import com.mebigfatguy.fbcontrib.utils.RegisterUtils; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -141,11 +142,7 @@ } } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && seen <= ASTORE_3)) { Integer pc = findDOMNodeCreationPoint(0); - int reg; - if (seen == ASTORE) - reg = getRegisterOperand(); - else - reg = seen - ASTORE_0; + int reg = RegisterUtils.getAStoreReg(this, seen); if (pc != null) nodeStores.put(Integer14.valueOf(reg), pc); else @@ -154,11 +151,7 @@ //Stores to member variables are assumed ok findDOMNodeCreationPoint(0); } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { - int reg; - if (seen == ALOAD) - reg = getRegisterOperand(); - else - reg = seen - ALOAD_0; + int reg = RegisterUtils.getALoadReg(this, seen); itemPC = nodeStores.get(Integer14.valueOf(reg)); if (itemPC != null) sawCreate = true; @@ -187,6 +180,9 @@ nodeStores.remove(Integer14.valueOf(reg)); } } + if ((seen != INVOKESTATIC) && (stack.getStackDepth() > argCount)) { + nodeCreations.remove(stack.getStackItem(argCount)); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-20 00:41:37
|
Revision: 621 Author: dbrosius Date: 2006-08-19 17:41:27 -0700 (Sat, 19 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=621&view=rev Log Message: ----------- equalsIgnoreCase takes a String not an Object Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java 2006-08-20 00:15:45 UTC (rev 620) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java 2006-08-20 00:41:27 UTC (rev 621) @@ -86,7 +86,7 @@ if (("equals".equals(calledMethodName) && "(Ljava/lang/Object;)Z".equals(calledMethodSig)) || ("compareTo".equals(calledMethodName) && "(Ljava/lang/String;)I".equals(calledMethodSig)) - || ("equalsIgnoreCase".equals(calledMethodName) && "(Ljava/lang/Object;)Z".equals(calledMethodSig))) { + || ("equalsIgnoreCase".equals(calledMethodName) && "(Ljava/lang/String;)Z".equals(calledMethodSig))) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-20 00:15:59
|
Revision: 620 Author: dbrosius Date: 2006-08-19 17:15:45 -0700 (Sat, 19 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=620&view=rev Log Message: ----------- add equalsIgnoreCase to LSC Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java 2006-08-18 03:59:33 UTC (rev 619) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java 2006-08-20 00:15:45 UTC (rev 620) @@ -85,7 +85,9 @@ String calledMethodSig = getSigConstantOperand(); if (("equals".equals(calledMethodName) && "(Ljava/lang/Object;)Z".equals(calledMethodSig)) - || ("compareTo".equals(calledMethodName) && "(Ljava/lang/String;)I".equals(calledMethodSig))) { + || ("compareTo".equals(calledMethodName) && "(Ljava/lang/String;)I".equals(calledMethodSig)) + || ("equalsIgnoreCase".equals(calledMethodName) && "(Ljava/lang/Object;)Z".equals(calledMethodSig))) { + if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); Object constant = itm.getConstant(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-18 03:59:44
|
Revision: 619 Author: dbrosius Date: 2006-08-17 20:59:33 -0700 (Thu, 17 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=619&view=rev Log Message: ----------- Fix [ 1540989 ] UEC does not see EnumSet by checking real type, not static type Modified Paths: -------------- trunk/fb-contrib/samples/UEC_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java Modified: trunk/fb-contrib/samples/UEC_Sample.java =================================================================== --- trunk/fb-contrib/samples/UEC_Sample.java 2006-08-16 04:21:25 UTC (rev 618) +++ trunk/fb-contrib/samples/UEC_Sample.java 2006-08-18 03:59:33 UTC (rev 619) @@ -9,6 +9,7 @@ public class UEC_Sample { public enum Suite { Spades, Hearts, Clubs, Diamonds }; + public enum FalsePositive { A, B, C }; private Set<Suite> wildSuites = new HashSet<Suite>(); private EnumSet<Suite> eWildSuites = EnumSet.noneOf(Suite.class); @@ -40,4 +41,11 @@ return hand; } + + public void uecFP() + { + Set<FalsePositive> testSet = EnumSet.of(FalsePositive.A); + + testSet.add(FalsePositive.B); + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java 2006-08-16 04:21:25 UTC (rev 618) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java 2006-08-18 03:59:33 UTC (rev 619) @@ -95,11 +95,11 @@ if (("java/util/Map".equals(clsName)) && ("put".equals(methodName)) && ("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;".equals(signature))) { - bug = isEnum(1) && alreadyReported(2); + bug = isEnum(1) && !isEnumCollection(1) && alreadyReported(2); } else if (("java/util/Set".equals(clsName)) && ("add".equals(methodName)) && ("(Ljava/lang/Object;)Z".equals(signature))) { - bug = isEnum(0) && alreadyReported(1); + bug = isEnum(0) && !isEnumCollection(1) && alreadyReported(1); } if (bug) { @@ -135,6 +135,22 @@ } /** + * returns whether the item at the stackpos location is an instance of an EnumSet or EnumMap + * + * @param stackPos the posotion on the opstack to check + * + * @return whether the class is an EnumSet or EnumMap + */ + private boolean isEnumCollection(int stackPos) { + if (stack.getStackDepth() <= stackPos) + return false; + + OpcodeStack.Item item = stack.getStackItem(stackPos); + String realClass = item.getSignature(); + return "Ljava/util/EnumSet;".equals(realClass) || "Ljava/util/EnumMap;".equals(realClass); + } + + /** * returns whether the collection has already been reported on * * @param stackPos the position on the opstack to check This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-16 04:21:30
|
Revision: 618 Author: dbrosius Date: 2006-08-15 21:21:25 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=618&view=rev Log Message: ----------- the last statement of a try block doesn't have to be a return, or a goto, if there is a finally block. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-15 03:15:39 UTC (rev 617) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-16 04:21:25 UTC (rev 618) @@ -163,10 +163,12 @@ int pc = getPC(); for (CodeException ex : exceptions) { if (pc == ex.getEndPC()) { - if ((seen >= IRETURN) && (seen <= RETURN)) { + if ((seen >= IRETURN) && (seen <= RETURN)) addCatchBlock(ex.getHandlerPC(), Integer.MAX_VALUE); - } else if ((seen == GOTO) || (seen == GOTO_W)) + else if ((seen == GOTO) || (seen == GOTO_W)) addCatchBlock(ex.getHandlerPC(), this.getBranchTarget()); + else + addCatchBlock(ex.getHandlerPC(), Integer.MAX_VALUE); return; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-15 03:15:43
|
Revision: 617 Author: dbrosius Date: 2006-08-14 20:15:39 -0700 (Mon, 14 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=617&view=rev Log Message: ----------- look for catch variable range end, by looking at pc+2 when entering the catch block to account for ASTORE 5, like operations, not just ASTORE_3. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-14 22:37:05 UTC (rev 616) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-15 03:15:39 UTC (rev 617) @@ -182,7 +182,7 @@ exReg.put(Integer14.valueOf(reg), Boolean.TRUE); LocalVariableTable lvt = getMethod().getLocalVariableTable(); if (lvt != null) { - LocalVariable lv = lvt.getLocalVariable(reg, pc+1); + LocalVariable lv = lvt.getLocalVariable(reg, pc+2); if (lv != null) { int finish = lv.getStartPC() + lv.getLength(); if (finish < catchInfo.getFinish()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-14 22:37:12
|
Revision: 616 Author: dbrosius Date: 2006-08-14 15:37:05 -0700 (Mon, 14 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=616&view=rev Log Message: ----------- javac doesn't consider the exception's original astore to be part of the variable's scope, so when looking for the variable finish, use pc + 1. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-14 05:07:07 UTC (rev 615) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-14 22:37:05 UTC (rev 616) @@ -182,7 +182,7 @@ exReg.put(Integer14.valueOf(reg), Boolean.TRUE); LocalVariableTable lvt = getMethod().getLocalVariableTable(); if (lvt != null) { - LocalVariable lv = lvt.getLocalVariable(reg, pc); + LocalVariable lv = lvt.getLocalVariable(reg, pc+1); if (lv != null) { int finish = lv.getStartPC() + lv.getLength(); if (finish < catchInfo.getFinish()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |