fb-contrib-commit Mailing List for fb-contrib (Page 29)
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...> - 2009-03-15 04:28:52
|
Revision: 1141 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1141&view=rev Author: dbrosius Date: 2009-03-15 04:28:50 +0000 (Sun, 15 Mar 2009) Log Message: ----------- reduce fps 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 2009-03-09 04:09:21 UTC (rev 1140) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2009-03-15 04:28:50 UTC (rev 1141) @@ -108,11 +108,15 @@ */ public boolean prescreen(Code code, Method method) { if (method.isSynthetic()) - return false; + { + return false; + } CodeException[] ce = code.getExceptionTable(); if ((ce == null) || (ce.length == 0)) - return false; + { + return false; + } BitSet bytecodeSet = getClassContext().getBytecodeSet(method); return (bytecodeSet != null) && (bytecodeSet.get(Constants.ATHROW)); @@ -163,15 +167,18 @@ int pc = getPC(); for (CodeException ex : exceptions) { if (pc == ex.getEndPC()) { - if (ex.getCatchType() != 0) + if ((seen >= IRETURN) && (seen <= RETURN)) { - 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); + 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); + } } else if (pc == ex.getHandlerPC()) { removePreviousHandlers(pc); } @@ -183,7 +190,9 @@ CatchInfo catchInfo = it.next(); if (pc == catchInfo.getStart()) { if (!updateExceptionRegister(catchInfo, seen, pc)) + { it.remove(); + } break; } else if (pc > catchInfo.getFinish()) { it.remove(); @@ -213,7 +222,9 @@ OpcodeStack.Item itm = stack.getStackItem(1); int reg = itm.getRegisterNumber(); if (reg >= 0) - exReg.put(Integer14.valueOf(reg), Boolean.TRUE); + { + exReg.put(Integer14.valueOf(reg), Boolean.TRUE); + } markAsValid = true; // Fixes javac generated code } } @@ -224,7 +235,9 @@ } } else if ((seen == INVOKEINTERFACE) || (seen == INVOKESTATIC)) { if (isPossibleExBuilder(catchInfo.getRegister())) - markAsValid = true; + { + markAsValid = true; + } } else if (seen == ATHROW) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); @@ -253,7 +266,12 @@ } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { Boolean valid = exReg.get(Integer14.valueOf(RegisterUtils.getALoadReg(this, seen))); if (valid != null) - markAsValid = valid.booleanValue(); + { + markAsValid = valid.booleanValue(); + } + } else if ((seen >= IRETURN) && (seen <= RETURN)) { + removeIndeterminateHandlers(pc); + break; } } } catch (ClassNotFoundException cnfe) { @@ -292,7 +310,9 @@ for (int p = 0; p < numParms; p++) { OpcodeStack.Item item = stack.getStackItem(p); if (item.getRegisterNumber() == exReg) - return true; + { + return true; + } } } } @@ -317,10 +337,24 @@ while (it.hasNext()) { CatchInfo ci = it.next(); if (ci.getStart() < pc) + { it.remove(); + } } } + private void removeIndeterminateHandlers(int pc) + { + Iterator<CatchInfo> it = catchInfos.iterator(); + while (it.hasNext()) { + CatchInfo ci = it.next(); + if ((ci.getStart() < pc) && (ci.getFinish() == Integer.MAX_VALUE)) + { + it.remove(); + } + } + } + /** * looks to update the catchinfo block with the register used for the * exception variable. If their is a local variable table, but the local @@ -343,10 +377,14 @@ if (lv != null) { int finish = lv.getStartPC() + lv.getLength(); if (finish < ci.getFinish()) + { ci.setFinish(finish); + } } else + { return false; + } } } return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-09 04:09:27
|
Revision: 1140 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1140&view=rev Author: dbrosius Date: 2009-03-09 04:09:21 +0000 (Mon, 09 Mar 2009) Log Message: ----------- clear pop stack on if statements Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java 2009-03-07 22:49:48 UTC (rev 1139) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java 2009-03-09 04:09:21 UTC (rev 1140) @@ -42,7 +42,7 @@ * This may represent a change in definition that should be noticed. */ public class StaticMethodInstanceInvocation extends BytecodeScanningDetector { - private BugReporter bugReporter; + private final BugReporter bugReporter; private OpcodeStack stack; private List<PopInfo> popStack; @@ -106,7 +106,9 @@ while (it.hasNext()) { if (sDepth < it.next().popDepth) - it.remove(); + { + it.remove(); + } } if ((seen == INVOKESTATIC) && (popStack.size() > 0)) { @@ -134,7 +136,8 @@ || (seen == PUTFIELD) || (seen == ATHROW) || (seen == GOTO) - || (seen == GOTO_W)) { + || (seen == GOTO_W) + || (seen >= IFEQ) && (seen <= IF_ACMPNE)) { popStack.clear(); } else if ((seen == INVOKESPECIAL) || (seen == INVOKEINTERFACE) @@ -142,7 +145,9 @@ || (seen == INVOKESTATIC)) { Type result = Type.getReturnType(getSigConstantOperand()); if ("V".equals(result.getSignature())) - popStack.clear(); + { + popStack.clear(); + } } if (seen == POP) { @@ -150,7 +155,9 @@ OpcodeStack.Item itm = stack.getStackItem(0); String popSig = itm.getSignature(); if (popSig.charAt(0) == 'L') - popStack.add(new PopInfo(getPC(), popSig, sDepth - 1)); + { + popStack.add(new PopInfo(getPC(), popSig, sDepth - 1)); + } } } } catch (ClassNotFoundException cnfe) { @@ -164,7 +171,9 @@ boolean classDefinesStaticMethod(String popSignature) throws ClassNotFoundException { popSignature = popSignature.replace('/', '.'); if ("java.lang.Object".equals(popSignature) || "java.lang.Class".equals(popSignature)) - return false; + { + return false; + } JavaClass cls = Repository.lookupClass(popSignature); Method[] methods = cls.getMethods(); @@ -172,7 +181,9 @@ if (m.isStatic()) { if (m.getName().equals(getNameConstantOperand()) && m.getSignature().equals(getSigConstantOperand())) - return true; + { + return true; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-07 22:49:51
|
Revision: 1139 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1139&view=rev Author: dbrosius Date: 2009-03-07 22:49:48 +0000 (Sat, 07 Mar 2009) Log Message: ----------- guard against spurious npe Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-03-04 04:19:04 UTC (rev 1138) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-03-07 22:49:48 UTC (rev 1139) @@ -132,8 +132,12 @@ JavaClass superCls = exCls.getSuperClass(); do { exCls = superCls; - declaredCheckedExceptions.remove(exCls.getClassName()); - superCls = exCls.getSuperClass(); + if (exCls != null) { + declaredCheckedExceptions.remove(exCls.getClassName()); + superCls = exCls.getSuperClass(); + } else { + break; + } } while (!declaredCheckedExceptions.isEmpty() && !"java.lang.Exception".equals(exCls.getClassName()) && !"java.lang.Error".equals(exCls.getClassName())); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-04 04:19:05
|
Revision: 1138 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1138&view=rev Author: dbrosius Date: 2009-03-04 04:19:04 +0000 (Wed, 04 Mar 2009) Log Message: ----------- stop recursing at Error as well. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-03-04 04:05:25 UTC (rev 1137) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-03-04 04:19:04 UTC (rev 1138) @@ -134,7 +134,7 @@ exCls = superCls; declaredCheckedExceptions.remove(exCls.getClassName()); superCls = exCls.getSuperClass(); - } while (!declaredCheckedExceptions.isEmpty() && !"java.lang.Exception".equals(exCls.getClassName())); + } while (!declaredCheckedExceptions.isEmpty() && !"java.lang.Exception".equals(exCls.getClassName()) && !"java.lang.Error".equals(exCls.getClassName())); } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-04 04:05:27
|
Revision: 1137 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1137&view=rev Author: dbrosius Date: 2009-03-04 04:05:25 +0000 (Wed, 04 Mar 2009) Log Message: ----------- don't report throws from finally 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 2009-03-02 02:44:48 UTC (rev 1136) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2009-03-04 04:05:25 UTC (rev 1137) @@ -143,7 +143,7 @@ public CodeException[] collectExceptions(CodeException[] exceptions) { List<CodeException> filteredEx = new ArrayList<CodeException>(); for (CodeException ce : exceptions) { - if ((ce.getStartPC() < ce.getEndPC()) && (ce.getEndPC() <= ce.getHandlerPC())) { + if ((ce.getCatchType() != 0) && (ce.getStartPC() < ce.getEndPC()) && (ce.getEndPC() <= ce.getHandlerPC())) { filteredEx.add(ce); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-02 02:44:49
|
Revision: 1136 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1136&view=rev Author: dbrosius Date: 2009-03-02 02:44:48 +0000 (Mon, 02 Mar 2009) Log Message: ----------- more tests Modified Paths: -------------- trunk/fb-contrib/samples/BED_Sample.java Modified: trunk/fb-contrib/samples/BED_Sample.java =================================================================== --- trunk/fb-contrib/samples/BED_Sample.java 2009-03-01 19:43:07 UTC (rev 1135) +++ trunk/fb-contrib/samples/BED_Sample.java 2009-03-02 02:44:48 UTC (rev 1136) @@ -2,9 +2,14 @@ import java.io.IOException; import java.io.InputStream; import java.sql.SQLException; +import java.util.Hashtable; import java.util.zip.DataFormatException; +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import javax.naming.directory.InitialDirContext; + public class BED_Sample { public BED_Sample() throws IOException @@ -12,6 +17,13 @@ } + public BED_Sample(String name) throws NamingException + { + Hashtable<String, String> env = new Hashtable<String, String>(); + env.put("name", name); + DirContext context = new InitialDirContext(env); + } + private void badThrow() throws SQLException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 19:43:13
|
Revision: 1135 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1135&view=rev Author: dbrosius Date: 2009-03-01 19:43:07 +0000 (Sun, 01 Mar 2009) Log Message: ----------- document BED Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2009-03-01 19:33:47 UTC (rev 1134) +++ trunk/fb-contrib/htdocs/index.html 2009-03-01 19:43:07 UTC (rev 1135) @@ -48,6 +48,17 @@ <a href="bugdescriptions.html">Bug Descriptions</a> <hr/> + <img id="svn_image" src="flip1.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> + Detectors added in SVN<br/> + <div id="svn" style="display:none;"> + <ul> + <li><b>[BED] Bogus Exception Declaration</b><br/> + Looks for constructors, private methods or static methods that declare that they + throw specific checked exceptions, but that do not. This just causes callers of + these methods to do extra work to handle an exception that will never be thrown.</li> + </ul> + </div> + <hr/> <img id="v3_8_0_image" src="flip2.gif" onClick="toggleBlock('v3_8_0', 'v3_8_0_image');" align="top"/> Detectors added in v3.8.0<br/> <div id="v3_8_0" style="display:block;"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 19:33:50
|
Revision: 1134 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1134&view=rev Author: dbrosius Date: 2009-03-01 19:33:47 +0000 (Sun, 01 Mar 2009) Log Message: ----------- walk exception hierarchy when removing valid declares exceptions Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-03-01 19:10:31 UTC (rev 1133) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-03-01 19:33:47 UTC (rev 1134) @@ -66,6 +66,7 @@ */ @Override public void visitCode(Code obj) { + declaredCheckedExceptions.clear(); Method method = getMethod(); if (method.isStatic() || method.isPrivate() || "<init>".equals(method.getName())) { ExceptionTable et = method.getExceptionTable(); @@ -126,11 +127,16 @@ if (et != null) { String[] thrownExceptions = et.getExceptionNames(); for (String thrownException : thrownExceptions) { - declaredCheckedExceptions.remove(thrownException.replaceAll("/", ".")); + declaredCheckedExceptions.remove(thrownException); + JavaClass exCls = Repository.lookupClass(thrownException); + JavaClass superCls = exCls.getSuperClass(); + do { + exCls = superCls; + declaredCheckedExceptions.remove(exCls.getClassName()); + superCls = exCls.getSuperClass(); + } while (!declaredCheckedExceptions.isEmpty() && !"java.lang.Exception".equals(exCls.getClassName())); + } - if (thrownExceptions.length > 0) { - declaredCheckedExceptions.remove("java.lang.Exception"); - } } else { declaredCheckedExceptions.clear(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 19:10:34
|
Revision: 1133 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1133&view=rev Author: dbrosius Date: 2009-03-01 19:10:31 +0000 (Sun, 01 Mar 2009) Log Message: ----------- special handling for java.lang.Exception Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-03-01 19:06:24 UTC (rev 1132) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-03-01 19:10:31 UTC (rev 1133) @@ -128,6 +128,9 @@ for (String thrownException : thrownExceptions) { declaredCheckedExceptions.remove(thrownException.replaceAll("/", ".")); } + if (thrownExceptions.length > 0) { + declaredCheckedExceptions.remove("java.lang.Exception"); + } } else { declaredCheckedExceptions.clear(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 19:06:33
|
Revision: 1132 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1132&view=rev Author: dbrosius Date: 2009-03-01 19:06:24 +0000 (Sun, 01 Mar 2009) Log Message: ----------- more tests Modified Paths: -------------- trunk/fb-contrib/samples/BED_Sample.java Modified: trunk/fb-contrib/samples/BED_Sample.java =================================================================== --- trunk/fb-contrib/samples/BED_Sample.java 2009-03-01 09:32:06 UTC (rev 1131) +++ trunk/fb-contrib/samples/BED_Sample.java 2009-03-01 19:06:24 UTC (rev 1132) @@ -26,4 +26,9 @@ { InputStream is = new FileInputStream("c:\\temp.txt"); } + + public static void fp() throws Exception + { + InputStream is = new FileInputStream("c:\\temp.txt"); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 09:32:11
|
Revision: 1131 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1131&view=rev Author: dbrosius Date: 2009-03-01 09:32:06 +0000 (Sun, 01 Mar 2009) Log Message: ----------- unfortunately have to load the class for which a method is called to get it's exceptions Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-03-01 09:31:37 UTC (rev 1130) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-03-01 09:32:06 UTC (rev 1131) @@ -13,7 +13,6 @@ import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.ba.ClassContext; -import edu.umd.cs.findbugs.ba.XMethod; /** * looks for constructors, private methods or static methods that declare that they @@ -22,8 +21,18 @@ */ public class BogusExceptionDeclaration extends BytecodeScanningDetector { private static JavaClass runtimeExceptionClass; + private static final Set<String> safeClasses = new HashSet<String>(); static { try { + safeClasses.add("java/lang/Object"); + safeClasses.add("java/lang/String"); + safeClasses.add("java/lang/Integer"); + safeClasses.add("java/lang/Long"); + safeClasses.add("java/lang/Float"); + safeClasses.add("java/lang/Double"); + safeClasses.add("java/lang/Short"); + safeClasses.add("java/lang/Boolean"); + runtimeExceptionClass = Repository.lookupClass("java/lang/RuntimeException"); } catch (ClassNotFoundException cnfe) { runtimeExceptionClass = null; @@ -103,10 +112,38 @@ || (seen == INVOKEINTERFACE) || (seen == INVOKESPECIAL) || (seen == INVOKESTATIC)) { - XMethod method = getXMethod(); - String[] thrownExceptions = method.getThrownExceptions(); - for (String thrownException : thrownExceptions) { - declaredCheckedExceptions.remove(thrownException.replaceAll("/", ".")); + String clsName = getClassConstantOperand(); + if (!safeClasses.contains(clsName)) { + try { + JavaClass cls = Repository.lookupClass(clsName); + Method[] methods = cls.getMethods(); + String methodName = getNameConstantOperand(); + String signature = getSigConstantOperand(); + boolean found = false; + for (Method m : methods) { + if (m.getName().equals(methodName) && m.getSignature().equals(signature)) { + ExceptionTable et = m.getExceptionTable(); + if (et != null) { + String[] thrownExceptions = et.getExceptionNames(); + for (String thrownException : thrownExceptions) { + declaredCheckedExceptions.remove(thrownException.replaceAll("/", ".")); + } + } else { + declaredCheckedExceptions.clear(); + } + found = true; + break; + } + } + + if (!found) { + declaredCheckedExceptions.clear(); + } + } + catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + declaredCheckedExceptions.clear(); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 09:31:39
|
Revision: 1130 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1130&view=rev Author: dbrosius Date: 2009-03-01 09:31:37 +0000 (Sun, 01 Mar 2009) Log Message: ----------- more tests Modified Paths: -------------- trunk/fb-contrib/samples/BED_Sample.java Modified: trunk/fb-contrib/samples/BED_Sample.java =================================================================== --- trunk/fb-contrib/samples/BED_Sample.java 2009-03-01 08:54:28 UTC (rev 1129) +++ trunk/fb-contrib/samples/BED_Sample.java 2009-03-01 09:31:37 UTC (rev 1130) @@ -1,4 +1,6 @@ +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.sql.SQLException; import java.util.zip.DataFormatException; @@ -19,4 +21,9 @@ { } + + public static void doIt() throws SQLException, IOException + { + InputStream is = new FileInputStream("c:\\temp.txt"); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 08:54:38
|
Revision: 1129 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1129&view=rev Author: dbrosius Date: 2009-03-01 08:54:28 +0000 (Sun, 01 Mar 2009) Log Message: ----------- new BED Detector Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml Added Paths: ----------- trunk/fb-contrib/samples/BED_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2009-03-01 07:39:25 UTC (rev 1128) +++ trunk/fb-contrib/etc/findbugs.xml 2009-03-01 08:54:28 UTC (rev 1129) @@ -332,6 +332,10 @@ speed="moderate" reports="DSOC_DUBIOUS_SET_OF_COLLECTIONS" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.BogusExceptionDeclaration" + speed="moderate" + reports="BED_BOGUS_EXCEPTION_DECLARATION" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -442,8 +446,9 @@ <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODITIES_IMPOSSIBLE_NULL" category="CORRECTNESS" /> <BugPattern abbrev="SCA" type="SCA_SUSPICIOUS_CLONE_ALGORITHM" category="CORRECTNESS" /> <BugPattern abbrev="WEM" type="WEM_WEAK_EXCEPTION_MESSAGING" category="STYLE" /> - <BugPattern abbrev="SCSS" type="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="LO" type="LO_SUSPECT_LOG_CLASS" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="IICU" type="IICU_INCORRECT_INTERNAL_CLASS_USE" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="DSOC" type="DSOC_DUBIOUS_SET_OF_COLLECTIONS" category="PERFORMANCE" experimental="true" /> + <BugPattern abbrev="SCSS" type="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" category="CORRECTNESS" /> + <BugPattern abbrev="LO" type="LO_SUSPECT_LOG_CLASS" category="CORRECTNESS" /> + <BugPattern abbrev="IICU" type="IICU_INCORRECT_INTERNAL_CLASS_USE" category="CORRECTNESS" /> + <BugPattern abbrev="DSOC" type="DSOC_DUBIOUS_SET_OF_COLLECTIONS" category="PERFORMANCE" /> + <BugPattern abbrev="BED" type="BED_BOGUS_EXCEPTION_DECLARATION" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2009-03-01 07:39:25 UTC (rev 1128) +++ trunk/fb-contrib/etc/messages.xml 2009-03-01 08:54:28 UTC (rev 1129) @@ -924,6 +924,17 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.BogusExceptionDeclaration"> + <Details> + <![CDATA[ + <p>looks for constructors, static methods and private methods that declare that they throw + checked exceptions that the actual code never throws. Since these methods can't be overridden, + there is no reason to add these exceptions to the method declaration.</p> + <p>It is a moderately fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -2407,6 +2418,19 @@ </Details> </BugPattern> + <BugPattern type="BED_BOGUS_EXCEPTION_DECLARATION"> + <ShortDescription>non derivable method declares throwing an exception that isn't thrown</ShortDescription> + <LongDescription>non derivable method {1} declares throwing an exception that isn't thrown</LongDescription> + <Details> + <![CDATA[ + <p>This method declares that it throws a checked exception that it does not throw. As this method is + either a constructor, static method or private method, there is no reason for this method to declare + the exception in it's throws clause, and just causes calling methods to unnecessarily handle an exception + that will never be thrown. The exception in question should be removed from the throws clause.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -2484,4 +2508,5 @@ <BugCode abbrev="LO">Logger Oddities</BugCode> <BugCode abbrev="IICU">Incorrect Internal Class use</BugCode> <BugCode abbrev="DSOC">Dubious Set of Collections</BugCode> + <BugCode abbrev="BED">Bogus Exception Declaration</BugCode> </MessageCollection> \ No newline at end of file Added: trunk/fb-contrib/samples/BED_Sample.java =================================================================== --- trunk/fb-contrib/samples/BED_Sample.java (rev 0) +++ trunk/fb-contrib/samples/BED_Sample.java 2009-03-01 08:54:28 UTC (rev 1129) @@ -0,0 +1,22 @@ +import java.io.IOException; +import java.sql.SQLException; +import java.util.zip.DataFormatException; + + +public class BED_Sample +{ + public BED_Sample() throws IOException + { + + } + + private void badThrow() throws SQLException + { + + } + + public static void badStatic() throws DataFormatException + { + + } +} Property changes on: trunk/fb-contrib/samples/BED_Sample.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-03-01 08:54:28 UTC (rev 1129) @@ -0,0 +1,113 @@ +package com.mebigfatguy.fbcontrib.detect; + +import java.util.HashSet; +import java.util.Set; + +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.ExceptionTable; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.ba.ClassContext; +import edu.umd.cs.findbugs.ba.XMethod; + +/** + * looks for constructors, private methods or static methods that declare that they + * throw specific checked exceptions, but that do not. This just causes callers of + * these methods to do extra work to handle an exception that will never be thrown. + */ +public class BogusExceptionDeclaration extends BytecodeScanningDetector { + private static JavaClass runtimeExceptionClass; + static { + try { + runtimeExceptionClass = Repository.lookupClass("java/lang/RuntimeException"); + } catch (ClassNotFoundException cnfe) { + runtimeExceptionClass = null; + } + } + private final BugReporter bugReporter; + private Set<String> declaredCheckedExceptions; + + public BogusExceptionDeclaration(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + + @Override + public void visitClassContext(ClassContext classContext) { + try { + if (runtimeExceptionClass != null) { + declaredCheckedExceptions = new HashSet<String>(); + super.visitClassContext(classContext); + } + } finally { + declaredCheckedExceptions = null; + } + } + + /** + * implements the visitor to see if the method declares that it throws any + * checked exceptions. + * + * @param obj the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + Method method = getMethod(); + if (method.isStatic() || method.isPrivate() || "<init>".equals(method.getName())) { + ExceptionTable et = method.getExceptionTable(); + if (et != null) { + String[] exNames = et.getExceptionNames(); + for (String exName : exNames) { + try { + JavaClass exCls = Repository.lookupClass(exName); + if (!exCls.instanceOf(runtimeExceptionClass)) { + declaredCheckedExceptions.add(exName); + } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + } + } + if (!declaredCheckedExceptions.isEmpty()) { + super.visitCode(obj); + if (!declaredCheckedExceptions.isEmpty()) { + BugInstance bi = new BugInstance(this, "BED_BOGUS_EXCEPTION_DECLARATION", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this, 0); + for (String ex : declaredCheckedExceptions) { + bi.addString(ex.replaceAll("/", ".")); + } + bugReporter.reportBug(bi); + } + } + } + } + } + + /** + * implements the visitor to look for method calls that could throw the exceptions + * that are listed in the declaration. + */ + @Override + public void sawOpcode(int seen) { + if (declaredCheckedExceptions.isEmpty()) { + return; + } + + if ((seen == INVOKEVIRTUAL) + || (seen == INVOKEINTERFACE) + || (seen == INVOKESPECIAL) + || (seen == INVOKESTATIC)) { + XMethod method = getXMethod(); + String[] thrownExceptions = method.getThrownExceptions(); + for (String thrownException : thrownExceptions) { + declaredCheckedExceptions.remove(thrownException.replaceAll("/", ".")); + } + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 07:39:30
|
Revision: 1128 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1128&view=rev Author: dbrosius Date: 2009-03-01 07:39:25 +0000 (Sun, 01 Mar 2009) Log Message: ----------- go back to development Modified Paths: -------------- trunk/fb-contrib/build.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2009-03-01 05:08:12 UTC (rev 1127) +++ trunk/fb-contrib/build.xml 2009-03-01 07:39:25 UTC (rev 1128) @@ -20,7 +20,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="3.8.0"/> + <property name="fb-contrib.version" value="3.9.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 05:08:26
|
Revision: 1127 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1127&view=rev Author: dbrosius Date: 2009-03-01 05:08:12 +0000 (Sun, 01 Mar 2009) Log Message: ----------- Tag version 3.8.0 Added Paths: ----------- tags/v3_8_0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 04:50:12
|
Revision: 1126 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1126&view=rev Author: dbrosius Date: 2009-03-01 04:50:03 +0000 (Sun, 01 Mar 2009) Log Message: ----------- UPM Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2009-03-01 04:49:14 UTC (rev 1125) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2009-03-01 04:50:03 UTC (rev 1126) @@ -351,15 +351,6 @@ return null; } - private LoopInfo findLoop(int pc) { - for (LoopInfo loop : loops.values()) { - if (loop.isInLoop(pc)) - return loop; - } - - return null; - } - private void removeLoop(int pc) { Iterator<LoopInfo> it = loops.values().iterator(); while (it.hasNext()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 04:49:23
|
Revision: 1125 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1125&view=rev Author: dbrosius Date: 2009-03-01 04:49:14 +0000 (Sun, 01 Mar 2009) Log Message: ----------- UCPM Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2009-03-01 04:48:13 UTC (rev 1124) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2009-03-01 04:49:14 UTC (rev 1125) @@ -152,7 +152,7 @@ if (loggingClassName != null) { if (stack.getStackDepth() > 0) { if (!loggingClassName.equals(clsName)) { - bugReporter.reportBug(new BugInstance(this, "LO_SUSPECT_LOG_CLASS", (callingClsName.indexOf("$") >= 0) ? LOW_PRIORITY : NORMAL_PRIORITY) + bugReporter.reportBug(new BugInstance(this, "LO_SUSPECT_LOG_CLASS", (callingClsName.indexOf('$') >= 0) ? LOW_PRIORITY : 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...> - 2009-03-01 04:48:23
|
Revision: 1124 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1124&view=rev Author: dbrosius Date: 2009-03-01 04:48:13 +0000 (Sun, 01 Mar 2009) Log Message: ----------- SPP Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java 2009-03-01 04:47:23 UTC (rev 1123) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java 2009-03-01 04:48:13 UTC (rev 1124) @@ -104,7 +104,7 @@ */ @Override public void sawOpcode(int seen) { - if (fbInfo.size() == 0) + if (fbInfo.isEmpty()) return; FinallyBlockInfo fbi = fbInfo.get(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 04:47:33
|
Revision: 1123 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1123&view=rev Author: dbrosius Date: 2009-03-01 04:47:23 +0000 (Sun, 01 Mar 2009) Log Message: ----------- RCN Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2009-03-01 04:43:20 UTC (rev 1122) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2009-03-01 04:47:23 UTC (rev 1123) @@ -151,7 +151,7 @@ if (loggingClassName != null) { if (stack.getStackDepth() > 0) { - if ((loggingClassName != null) && !loggingClassName.equals(clsName)) { + if (!loggingClassName.equals(clsName)) { bugReporter.reportBug(new BugInstance(this, "LO_SUSPECT_LOG_CLASS", (callingClsName.indexOf("$") >= 0) ? LOW_PRIORITY : NORMAL_PRIORITY) .addClass(this) .addMethod(this) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 04:43:25
|
Revision: 1122 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1122&view=rev Author: dbrosius Date: 2009-03-01 04:43:20 +0000 (Sun, 01 Mar 2009) Log Message: ----------- fix javadoc Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java 2009-03-01 04:42:09 UTC (rev 1121) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java 2009-03-01 04:43:20 UTC (rev 1122) @@ -60,7 +60,7 @@ * implements the visitor to look for classes that reference com.sun.xxx, or org.apache.xerces.xxx classes * by looking for class constants in the constant pool * - * @param classContext the context object of the currently parsed class + * @param context the context object of the currently parsed class */ public void visitClassContext(ClassContext context) { JavaClass cls = context.getJavaClass(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 04:42:17
|
Revision: 1121 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1121&view=rev Author: dbrosius Date: 2009-03-01 04:42:09 +0000 (Sun, 01 Mar 2009) Log Message: ----------- stick with 1.4 apis Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2009-03-01 04:38:40 UTC (rev 1120) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2009-03-01 04:42:09 UTC (rev 1121) @@ -152,7 +152,7 @@ if (loggingClassName != null) { if (stack.getStackDepth() > 0) { if ((loggingClassName != null) && !loggingClassName.equals(clsName)) { - bugReporter.reportBug(new BugInstance(this, "LO_SUSPECT_LOG_CLASS", callingClsName.contains("$") ? LOW_PRIORITY : NORMAL_PRIORITY) + bugReporter.reportBug(new BugInstance(this, "LO_SUSPECT_LOG_CLASS", (callingClsName.indexOf("$") >= 0) ? LOW_PRIORITY : 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...> - 2009-03-01 04:38:43
|
Revision: 1120 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1120&view=rev Author: dbrosius Date: 2009-03-01 04:38:40 +0000 (Sun, 01 Mar 2009) Log Message: ----------- prepare for the 3.8.0 release Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2009-03-01 04:32:40 UTC (rev 1119) +++ trunk/fb-contrib/build.xml 2009-03-01 04:38:40 UTC (rev 1120) @@ -20,7 +20,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="3.7.0"/> + <property name="fb-contrib.version" value="3.8.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2009-03-01 04:32:40 UTC (rev 1119) +++ trunk/fb-contrib/htdocs/index.html 2009-03-01 04:38:40 UTC (rev 1120) @@ -48,9 +48,9 @@ <a href="bugdescriptions.html">Bug Descriptions</a> <hr/> - <img id="svn_image" src="flip2.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> - Detectors added in svn<br/> - <div id="svn" style="display:block;"> + <img id="v3_8_0_image" src="flip2.gif" onClick="toggleBlock('v3_8_0', 'v3_8_0_image');" align="top"/> + Detectors added in v3.8.0<br/> + <div id="v3_8_0" style="display:block;"> <ul> <li><b>[DSOC] Dubious Set of Collections</b><br/> Looks for sets or keySets of maps that contain other collections. As typically collections calculate This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 04:32:44
|
Revision: 1119 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1119&view=rev Author: dbrosius Date: 2009-03-01 04:32:40 +0000 (Sun, 01 Mar 2009) Log Message: ----------- spilleng Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2009-03-01 03:20:41 UTC (rev 1118) +++ trunk/fb-contrib/htdocs/index.html 2009-03-01 04:32:40 UTC (rev 1119) @@ -102,7 +102,7 @@ </div> <hr/> <img id="v3_4_0_image" src="flip1.gif" onClick="toggleBlock('v3_4_0', 'v3_4_0_image');" align="top"/> - Detectors add in v3.4.0<br/> + Detectors added in v3.4.0<br/> <div id="v3_4_0" style="display:none;"> <ul> <li><b>[SJVU] Suspicious JDK Version Use</b><br/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-01 03:20:46
|
Revision: 1118 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1118&view=rev Author: dbrosius Date: 2009-03-01 03:20:41 +0000 (Sun, 01 Mar 2009) Log Message: ----------- tighten up UAA, fix 1934619 Modified Paths: -------------- trunk/fb-contrib/samples/UAA_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java Modified: trunk/fb-contrib/samples/UAA_Sample.java =================================================================== --- trunk/fb-contrib/samples/UAA_Sample.java 2009-02-28 04:17:09 UTC (rev 1117) +++ trunk/fb-contrib/samples/UAA_Sample.java 2009-03-01 03:20:41 UTC (rev 1118) @@ -1,4 +1,3 @@ -import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -8,8 +7,8 @@ public class UAA_Sample { - private Set<String> in = new HashSet<String>(); - private Set<String> out = new HashSet<String>(); + private final Set<String> in = new HashSet<String>(); + private final Set<String> out = new HashSet<String>(); public Set<String> testLocalSet(Set<String> in) { Set<String> out = new HashSet<String>(); @@ -88,4 +87,28 @@ System.out.println("Hmm"); } } + + public void testFP1934619_A(final List<String> out, final Set<String> currentParents) + { + for (String currentOid : currentParents) + { + out.add(currentOid); + if (currentOid.indexOf("xx") > -1) { + continue; + } + out.add("don't forget me"); + } + } + + public void testFP1934619_B(final List<String> out, final Set<String> currentParents) + { + for (String currentOid : currentParents) + { + if (currentOid.indexOf("xx") > -1) + { + throw new RuntimeException("enough is enough"); + } + out.add(currentOid); + } + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2009-02-28 04:17:09 UTC (rev 1117) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2009-03-01 03:20:41 UTC (rev 1118) @@ -54,7 +54,7 @@ } } - private BugReporter bugReporter; + private final BugReporter bugReporter; private OpcodeStack stack; /** register/field to alias register/field */ private Map<Comparable<?>, Comparable<?>> userValues; @@ -138,6 +138,8 @@ .addSourceLine(this, loopPC)); } it.remove(); + } else if ((loop.getEndPC() > pc) && (loop.addPC < (pc - 5)) && (loop.addPC > 0)) { + it.remove(); } } @@ -185,9 +187,7 @@ if (uValue != null) { LoopInfo loop = loops.get(uValue); if (loop != null) { - if (loop.inConditionalRange(pc)) - loop.foundAdd(-1); - else if (loop.isInLoop(pc, false)) { + if (loop.isInLoop(pc)) { if (this.getCodeByte(getNextPC()) == POP) { loop.foundAdd(pc); } @@ -202,12 +202,11 @@ if (uValue != null) { LoopInfo loop = loops.get(uValue); if (loop != null) { - if (loop.inConditionalRange(pc)) - loop.foundAdd(-1); - else if (loop.isInLoop(pc, false)) + if (loop.isInLoop(pc)) { if (this.getCodeByte(getNextPC()) == POP) { loop.foundAdd(pc); } + } } } } @@ -244,12 +243,8 @@ } } - if (!loopFound) - { - LoopInfo loop = findLoop(pc, true); - if (loop != null) { - loop.addConditionalRange(pc, getBranchTarget()); - } + if (!loopFound) { + removeLoop(pc); } } } @@ -269,10 +264,7 @@ } } } else if (((seen > IFEQ) && (seen <= GOTO)) || (seen == IFNULL) || (seen == IFNONNULL)) { - LoopInfo loop = findLoop(pc, true); - if (loop != null) { - loop.addConditionalRange(pc, getBranchOffset() > 0 ? getBranchTarget() : loop.end); - } + removeLoop(pc); } else if (seen == CHECKCAST) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); @@ -359,21 +351,29 @@ return null; } - private LoopInfo findLoop(int pc, boolean ignoreConditionals) { + private LoopInfo findLoop(int pc) { for (LoopInfo loop : loops.values()) { - if (loop.isInLoop(pc, ignoreConditionals)) + if (loop.isInLoop(pc)) return loop; } return null; } + private void removeLoop(int pc) { + Iterator<LoopInfo> it = loops.values().iterator(); + while (it.hasNext()) { + if (it.next().isInLoop(pc)) { + it.remove(); + } + } + } + static class LoopInfo { - private int start; - private int end; + private final int start; + private final int end; private int addPC; - private Map<Integer, Integer> conditionalRanges = new HashMap<Integer, Integer>(); public LoopInfo(int loopStart, int loopEnd) { @@ -381,33 +381,12 @@ end = loopEnd; addPC = 0; } - - public void addConditionalRange(int condStart, int condEnd) + + public boolean isInLoop(int pc) { - conditionalRanges.put(Integer14.valueOf(condStart), Integer14.valueOf(condEnd)); + return ((pc >= start) && (pc <= end)); } - public boolean inConditionalRange(int pc) { - for (Map.Entry<Integer, Integer> entry : conditionalRanges.entrySet()) - { - if ((pc >= entry.getKey().intValue()) && pc <= entry.getValue().intValue()) - return true; - } - - return false; - } - - public boolean isInLoop(int pc, boolean ignoreConditionals) - { - if ((pc < start) || (pc > end)) - return false; - - if (ignoreConditionals) - return true; - - return !inConditionalRange(pc); - } - public void foundAdd(int pc) { if (addPC == 0) addPC = pc; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-02-28 04:17:11
|
Revision: 1117 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1117&view=rev Author: dbrosius Date: 2009-02-28 04:17:09 +0000 (Sat, 28 Feb 2009) Log Message: ----------- fix 2646424 by limiting the catch block based on the variable scope of the exception register. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java 2009-02-28 02:03:17 UTC (rev 1116) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java 2009-02-28 04:17:09 UTC (rev 1117) @@ -37,9 +37,12 @@ import org.apache.bcel.classfile.ConstantPool; import org.apache.bcel.classfile.ExceptionTable; import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.LocalVariable; +import org.apache.bcel.classfile.LocalVariableTable; import org.apache.bcel.classfile.Method; import com.mebigfatguy.fbcontrib.utils.Integer14; +import com.mebigfatguy.fbcontrib.utils.RegisterUtils; import com.mebigfatguy.fbcontrib.utils.SignatureUtils; import edu.umd.cs.findbugs.BugInstance; @@ -66,10 +69,11 @@ runtimeClass = null; } } - private BugReporter bugReporter; + private final BugReporter bugReporter; private OpcodeStack stack; private Map<Integer, CodeException> catchHandlerPCs; private List<CatchInfo> catchInfos; + private LocalVariableTable lvt; private Map<String, Set<String>> constrainingInfo; @@ -109,12 +113,14 @@ stack.resetForMethodEntry(this); catchHandlerPCs = collectExceptions(obj.getExceptionTable()); catchInfos = new ArrayList<CatchInfo>(); + lvt = method.getLocalVariableTable(); constrainingInfo = null; super.visitCode(obj); } } finally { catchInfos = null; catchHandlerPCs = null; + lvt = null; constrainingInfo = null; } } @@ -142,6 +148,7 @@ catchInfos.add(ci); } + updateEndPCsOnCatchRegScope(catchInfos, pc, seen); removeFinishedCatchBlocks(catchInfos, pc); if (seen == ATHROW) { @@ -247,24 +254,44 @@ * @param handlers the exception handlers installed * @param pc the current pc */ - private void removeFinishedCatchBlocks(List<CatchInfo> catchInfos, int pc) - { + private void removeFinishedCatchBlocks(List<CatchInfo> catchInfos, int pc) { Iterator<CatchInfo> it = catchInfos.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { if (it.next().getFinish() < pc) it.remove(); } } + /** reduces the end pc based on the optional LocalVariableTable's exception register scope + * + * @param catchInfos the list of active catch blocks + * @param pc the current pc + */ + private void updateEndPCsOnCatchRegScope(List<CatchInfo> catchInfos, int pc, int seen) + { + if (lvt != null) { + for (CatchInfo ci : catchInfos) { + if (ci.getStart() == pc) { + if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { + int exReg = RegisterUtils.getAStoreReg(this, seen); + LocalVariable lv = lvt.getLocalVariable(exReg, pc + 1); + if (lv != null) { + ci.setFinish(lv.getStartPC() + lv.getLength()); + } + break; + } + } + } + } + } + /** returns an array of catch types that the current pc is in * * @param catchInfos the list of catch infos for this method * @param pc the current pc * @return an set of catch exception types that the pc is currently in */ - public Set<String> findPossibleCatchSignatures(List<CatchInfo> catchInfos, int pc) - { + public Set<String> findPossibleCatchSignatures(List<CatchInfo> catchInfos, int pc) { Set<String> catchTypes = new HashSet<String>(); ListIterator<CatchInfo> it = catchInfos.listIterator(catchInfos.size()); while (it.hasPrevious()) { @@ -352,8 +379,7 @@ if (et != null) { int[] indexTable = et.getExceptionIndexTable(); ConstantPool pool = cls.getConstantPool(); - for (int i = 0; i < indexTable.length; i++) { - int index = indexTable[i]; + for (int index : indexTable) { if (index != 0) { ConstantClass ccls = (ConstantClass)pool.getConstant(index); String exName = ccls.getBytes(pool); @@ -378,9 +404,9 @@ } private static class CatchInfo { - private int catchStart; + private final int catchStart; private int catchFinish; - private String catchSignature; + private final String catchSignature; public CatchInfo(int start, int finish, String signature) { catchStart = start; @@ -392,6 +418,10 @@ return catchStart; } + public void setFinish(int finish) { + catchFinish = finish; + } + public int getFinish() { return catchFinish; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |