[Fb-contrib-commit] SF.net SVN: fb-contrib:[1720] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2012-10-20 02:17:35
|
Revision: 1720
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1720&view=rev
Author: dbrosius
Date: 2012-10-20 02:17:27 +0000 (Sat, 20 Oct 2012)
Log Message:
-----------
sync from git
Modified Paths:
--------------
trunk/fb-contrib/build.xml
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/htdocs/repository.html
trunk/fb-contrib/samples/LEST_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java
Modified: trunk/fb-contrib/build.xml
===================================================================
--- trunk/fb-contrib/build.xml 2012-10-19 22:23:05 UTC (rev 1719)
+++ trunk/fb-contrib/build.xml 2012-10-20 02:17:27 UTC (rev 1720)
@@ -17,7 +17,7 @@
<property name="javac.deprecation" value="on" />
<property name="javac.debug" value="on" />
- <property name="fb-contrib.version" value="4.8.0" />
+ <property name="fb-contrib.version" value="4.9.0" />
<property name="findbugs.version" value="2.0.0" />
<property name="findbugs-bcel.version" value="2.0.0" />
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2012-10-19 22:23:05 UTC (rev 1719)
+++ trunk/fb-contrib/etc/findbugs.xml 2012-10-20 02:17:27 UTC (rev 1720)
@@ -30,9 +30,9 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedCollectionContents" speed="fast" reports="UCC_UNRELATED_COLLECTION_CONTENTS" />
<Detector class="com.mebigfatguy.fbcontrib.detect.DeclaredRuntimeException" speed="fast" reports="DRE_DECLARED_RUNTIME_EXCEPTION" />
-<!--
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="fast" reports="CE_CLASS_ENVY" disabled="true" />
--->
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison" speed="fast" reports="LSC_LITERAL_STRING_COMPARISON" />
<Detector class="com.mebigfatguy.fbcontrib.detect.PartiallyConstructedObjectAccess" speed="fast" reports="PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS" />
@@ -73,9 +73,9 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.AbstractOverriddenMethod" speed="fast" reports="AOM_ABSTRACT_OVERRIDDEN_METHOD" />
<Detector class="com.mebigfatguy.fbcontrib.detect.CustomBuiltXML" speed="fast" reports="CBX_CUSTOM_BUILT_XML" />
-<!--
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" />
--->
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.ConstantListIndex" speed="fast" reports="CLI_CONSTANT_LIST_INDEX" />
<Detector class="com.mebigfatguy.fbcontrib.detect.SloppyClassReflection" speed="fast" reports="SCR_SLOPPY_CLASS_REFLECTION" />
@@ -176,9 +176,9 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryNewNullCheck" speed="fast" reports="UNNC_UNNECESSARY_NEW_NULL_CHECK" />
<Detector class="com.mebigfatguy.fbcontrib.detect.DeprecatedTypesafeEnumPattern" speed="fast" reports="DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN" />
-<!--
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" />
--->
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.TristateBooleanPattern" speed="fast" reports="TBP_TRISTATE_BOOLEAN_PATTERN" />
@@ -193,9 +193,9 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.PoorlyDefinedParameter" speed="fast" reports="PDP_POORLY_DEFINED_PARAMETER" />
<Detector class="com.mebigfatguy.fbcontrib.detect.NonSymmetricEquals" speed="fast" reports="NSE_NON_SYMMETRIC_EQUALS" />
-<!--
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" />
--->
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.NonFunctionalField" speed="fast" reports="NFF_NON_FUNCTIONAL_FIELD" />
@@ -221,9 +221,9 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousGetterSetterUse" speed="fast" reports="SGSU_SUSPICIOUS_GETTER_SETTER_USE" />
<Detector class="com.mebigfatguy.fbcontrib.detect.LingeringGraphicsObjects" speed="fast" reports="LGO_LINGERING_GRAPHICS_OBJECT" />
-<!--
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" />
- -->
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.CommonsEqualsBuilderToEquals" speed="fast" reports="CEBE_COMMONS_EQUALS_BUILDER_ISEQUALS" />
<Detector class="com.mebigfatguy.fbcontrib.detect.CommonsHashcodeBuilderToHashcode" speed="fast" reports="CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE" />
Modified: trunk/fb-contrib/htdocs/repository.html
===================================================================
--- trunk/fb-contrib/htdocs/repository.html 2012-10-19 22:23:05 UTC (rev 1719)
+++ trunk/fb-contrib/htdocs/repository.html 2012-10-20 02:17:27 UTC (rev 1720)
@@ -22,7 +22,7 @@
<table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;">
<tr><td><b>GroupId:</b></td><td>com.mebigfatguy</td></tr>
<tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr>
- <tr><td><b>Version:</b></td><td>4.6.1</td></tr>
+ <tr><td><b>Version:</b></td><td>4.8.0</td></tr>
</table>
</div>
Modified: trunk/fb-contrib/samples/LEST_Sample.java
===================================================================
--- trunk/fb-contrib/samples/LEST_Sample.java 2012-10-19 22:23:05 UTC (rev 1719)
+++ trunk/fb-contrib/samples/LEST_Sample.java 2012-10-20 02:17:27 UTC (rev 1720)
@@ -4,7 +4,7 @@
import java.util.Date;
@SuppressWarnings("all")
-public class LEST_Sample
+public class LEST_Sample
{
public Date testLest1(String input)
{
@@ -12,33 +12,33 @@
{
DateFormat df = new SimpleDateFormat("YYYY");
return df.parse(input);
- }
+ }
catch (ParseException pe)
{
throw new IllegalArgumentException(pe.getMessage());
}
}
-
+
public Date testLest2(String input)
{
try
{
DateFormat df = new SimpleDateFormat("YYYY");
return df.parse(input);
- }
+ }
catch (ParseException pe)
{
throw new IllegalArgumentException(pe.getMessage(), pe);
}
}
-
+
public Date testLestFP1(String input) throws ParseException
{
try
{
DateFormat df = new SimpleDateFormat("YYYY");
return df.parse(input);
- }
+ }
catch (ParseException pe)
{
throw pe;
@@ -51,7 +51,7 @@
{
DateFormat df = new SimpleDateFormat("YYYY");
return df.parse(input);
- }
+ }
catch (ParseException pe)
{
IllegalArgumentException iae = new IllegalArgumentException(pe.getMessage());
@@ -59,7 +59,7 @@
throw iae;
}
}
-
+
public void testLestFP3(String s)
{
double d;
@@ -69,11 +69,11 @@
}
catch (NumberFormatException nfe)
{
-
+
}
throw new RuntimeException("ok");
}
-
+
public void testLestFP4(String s) throws Exception
{
double d;
@@ -87,7 +87,7 @@
throw e;
}
}
-
+
public void testLestFP5(String s) throws Exception
{
double d;
@@ -101,7 +101,7 @@
throw e;
}
}
-
+
public void testLestFP6(String s) throws Exception
{
double d;
@@ -114,11 +114,23 @@
throw new Exception("Yikes");
}
}
-
+
+ public void testLestFP7(String s)
+ {
+ try
+ {
+ double d = Double.parseDouble(s);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
private Exception wrap(Exception e) {
return new Exception(e);
}
-
+
private static Exception wrapStatic(Exception e) {
return new Exception(e);
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2012-10-19 22:23:05 UTC (rev 1719)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2012-10-20 02:17:27 UTC (rev 1720)
@@ -1,17 +1,17 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
* Copyright (C) 2005-2012 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
@@ -51,42 +51,45 @@
* the original exception within it. Doing this loses the stack history, and where the original
* problem occurred. This makes finding and fixing errors difficult.
*/
-public class LostExceptionStackTrace extends BytecodeScanningDetector
+public class LostExceptionStackTrace extends BytecodeScanningDetector
{
- private static JavaClass throwableClass;
+ private static JavaClass errorClass;
+ private static JavaClass throwableClass;
static {
try {
- throwableClass = Repository.lookupClass("java/lang/Throwable");
+ errorClass = Repository.lookupClass("java/lang/Error");
+ throwableClass = Repository.lookupClass("java/lang/Throwable");
} catch (ClassNotFoundException cnfe) {
- throwableClass = null;
+ errorClass = null;
+ throwableClass = null;
}
}
-
+
private final BugReporter bugReporter;
private OpcodeStack stack;
private CodeException[] exceptions;
private Set<CatchInfo> catchInfos;
private Map<Integer, Boolean> exReg;
private boolean lastWasExitPoint = false;
-
+
/**
* constructs a LEST detector given the reporter to report bugs on
* @param bugReporter the sync of bug reports
- */
+ */
public LostExceptionStackTrace(BugReporter bugReporter) {
this.bugReporter = bugReporter;
}
-
+
/**
* implements the visitor to make sure the jdk is 1.4 or better
- *
+ *
* @param classContext the context object of the currently parsed class
*/
@Override
public void visitClassContext(ClassContext classContext) {
try {
- if (throwableClass != null && !isPre14Class(classContext.getJavaClass())) {
+ if (errorClass != null && throwableClass != null && !isPre14Class(classContext.getJavaClass())) {
stack = new OpcodeStack();
catchInfos = new HashSet<CatchInfo>();
exReg = new HashMap<Integer, Boolean>();
@@ -99,10 +102,10 @@
exReg = null;
}
}
-
+
/**
* looks for methods that contain a catch block and an ATHROW opcode
- *
+ *
* @param code the context object of the current code block
* @param method the context object of the current method
* @return if the class throws exceptions
@@ -112,7 +115,7 @@
{
return false;
}
-
+
CodeException[] ce = code.getExceptionTable();
if (ce == null || ce.length == 0)
{
@@ -125,7 +128,7 @@
/**
* implements the visitor to filter out methods that don't throw exceptions
- *
+ *
* @param obj the context object of the currently parsed code block
*/
@Override
@@ -139,10 +142,10 @@
super.visitCode(obj);
}
}
-
+
/**
* collects all the valid exception objects (ones where start and finish are before the target
- *
+ *
* @param exs the exceptions from the class file
* @return the filtered exceptions
*/
@@ -155,7 +158,7 @@
}
return filteredEx.toArray(new CodeException[filteredEx.size()]);
}
-
+
/**
* implements the visitor to find throwing alternative exceptions from a catch block, without
* forwarding along the original exception
@@ -163,7 +166,7 @@
@Override
public void sawOpcode(int seen) {
boolean markAsValid = false;
-
+
try {
stack.mergeJumps(this);
int pc = getPC();
@@ -185,7 +188,7 @@
removePreviousHandlers(pc);
}
}
-
+
Iterator<CatchInfo> it = catchInfos.iterator();
while (it.hasNext()) {
try {
@@ -204,10 +207,11 @@
if ("<init>".equals(getNameConstantOperand())) {
String className = getClassConstantOperand();
JavaClass exClass = Repository.lookupClass(className);
- if (exClass.instanceOf(throwableClass)) {
+ if (exClass.instanceOf(errorClass) || (exClass.instanceOf(throwableClass))) {
String sig = getSigConstantOperand();
if (sig.indexOf("Exception") >= 0
- || sig.indexOf("Throwable") >= 0) {
+ || sig.indexOf("Throwable") >= 0
+ || sig.indexOf("Error") >= 0) {
markAsValid = true;
break;
}
@@ -219,7 +223,7 @@
if ("initCause".equals(getNameConstantOperand())) {
String className = getClassConstantOperand();
JavaClass exClass = Repository.lookupClass(className);
- if (exClass.instanceOf(throwableClass)) {
+ if (exClass.instanceOf(errorClass)) {
if (stack.getStackDepth() > 1) {
OpcodeStack.Item itm = stack.getStackItem(1);
int reg = itm.getRegisterNumber();
@@ -254,7 +258,7 @@
.addSourceLine(this));
}
it.remove();
- break;
+ break;
}
}
} else if (seen == ASTORE || seen >= ASTORE_0 && seen <= ASTORE_3) {
@@ -263,7 +267,7 @@
catchInfos.clear();
break;
}
-
+
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
int reg = RegisterUtils.getAStoreReg(this, seen);
@@ -282,13 +286,13 @@
removeIndeterminateHandlers(pc);
break;
}
- }
+ }
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
it.remove();
}
}
-
+
lastWasExitPoint = seen >= IRETURN && seen <= RETURN || seen == GOTO || seen == GOTO_W || seen == ATHROW;
}
finally {
@@ -303,7 +307,7 @@
}
}
}
-
+
/** returns whether the method called might be a method that builds an exception using
* the original exception. It does so by looking to see if the method returns an exception,
* and if one of the parameters is the original exception
@@ -317,7 +321,7 @@
if (returnSig.startsWith("L")) {
returnSig = returnSig.substring(1, returnSig.length() - 1);
JavaClass retCls = Repository.lookupClass(returnSig);
- if (retCls.instanceOf(throwableClass)) {
+ if (retCls.instanceOf(errorClass)) {
int numParms = Type.getArgumentTypes(sig).length;
if (stack.getStackDepth() >= numParms) {
for (int p = 0; p < numParms; p++) {
@@ -332,15 +336,15 @@
}
return false;
}
-
+
/** returns whether the class in question was compiled with a jdk less than 1.4
- *
+ *
* @param cls the class to check
* @return whether the class is compiled with a jdk less than 1.4
*/
private boolean isPre14Class(JavaClass cls)
{
- return cls != null && cls.getMajor() < Constants.MAJOR_1_4;
+ return cls != null && cls.getMajor() < Constants.MAJOR_1_4;
}
private void removePreviousHandlers(int pc)
@@ -355,7 +359,7 @@
}
}
}
-
+
private void removeIndeterminateHandlers(int pc)
{
Iterator<CatchInfo> it = catchInfos.iterator();
@@ -367,16 +371,16 @@
}
}
}
-
+
/**
- * looks to update the catchinfo block with the register used for the
+ * 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) {
@@ -402,11 +406,11 @@
}
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
*/
@@ -414,34 +418,34 @@
CatchInfo ci = new CatchInfo(start, finish);
catchInfos.add(ci);
}
-
+
private static class CatchInfo {
private final int catchStart;
private int catchFinish;
private int exReg;
-
+
public CatchInfo(int start, int finish) {
catchStart = start;
catchFinish = finish;
exReg = -1;
}
-
+
public void setReg(int reg) {
exReg = reg;
}
-
+
public int getStart() {
return catchStart;
}
-
+
public int getFinish() {
return catchFinish;
}
-
+
public void setFinish(int finish) {
catchFinish = finish;
}
-
+
public int getRegister() {
return exReg;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|