[Fb-contrib-commit] SF.net SVN: fb-contrib:[1740] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2013-02-06 05:02:36
|
Revision: 1740
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1740&view=rev
Author: dbrosius
Date: 2013-02-06 05:02:24 +0000 (Wed, 06 Feb 2013)
Log Message:
-----------
sync from github
Modified Paths:
--------------
trunk/fb-contrib/build.xml
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/etc/messages.xml
trunk/fb-contrib/htdocs/repository.html
trunk/fb-contrib/pom.xml
trunk/fb-contrib/samples/STB_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java
Modified: trunk/fb-contrib/build.xml
===================================================================
--- trunk/fb-contrib/build.xml 2013-01-30 06:57:26 UTC (rev 1739)
+++ trunk/fb-contrib/build.xml 2013-02-06 05:02:24 UTC (rev 1740)
@@ -17,7 +17,7 @@
<property name="javac.deprecation" value="on" />
<property name="javac.debug" value="on" />
- <property name="fb-contrib.version" value="4.8.2" />
+ <property name="fb-contrib.version" value="4.9.0" />
<property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" />
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2013-01-30 06:57:26 UTC (rev 1739)
+++ trunk/fb-contrib/etc/findbugs.xml 2013-02-06 05:02:24 UTC (rev 1740)
@@ -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
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="fast" reports="CE_CLASS_ENVY" disabled="true" />
- COMMENT OUT FOR RELEASE -->
+<!-- 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
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" />
- COMMENT OUT FOR RELEASE -->
+<!-- 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
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" />
- COMMENT OUT FOR RELEASE -->
+<!-- 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
+<!-- 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 -->
+<!-- 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
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" />
- COMMENT OUT FOR RELEASE -->
+<!-- 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" />
@@ -236,6 +236,8 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.CloneUsability" speed="fast" reports="CU_CLONE_USABILITY_OBJECT_RETURN,CU_CLONE_USABILITY_THROWS" />
+ <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingArrayAsList" speed="fast" reports="CAAL_CONFUSING_ARRAY_AS_LIST" />
+
<!-- BugPattern -->
<BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" />
@@ -410,4 +412,5 @@
<BugPattern abbrev="BRPI" type="BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS" category ="PERFORMANCE" />
<BugPattern abbrev="CU" type="CU_CLONE_USABILITY_OBJECT_RETURN" category="STYLE" />
<BugPattern abbrev="CU" type="CU_CLONE_USABILITY_THROWS" category="STYLE" />
+ <BugPattern abbrev="CAAL" type="CAAL_CONFUSING_ARRAY_AS_LIST" category="CORRECTNESS" />
</FindbugsPlugin>
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2013-01-30 06:57:26 UTC (rev 1739)
+++ trunk/fb-contrib/etc/messages.xml 2013-02-06 05:02:24 UTC (rev 1740)
@@ -1281,6 +1281,17 @@
]]>
</Details>
</Detector>
+
+ <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingArrayAsList">
+ <Details>
+ <![CDATA[
+ <p> Looks for calls to Arrays.asList where the parameter is a primitive array.
+ This does not produce a list that holds the primitive boxed values, but a list of
+ one item, the array itself.
+ </p>
+ ]]>
+ </Details>
+ </Detector>
<!-- BugPattern -->
@@ -3493,7 +3504,21 @@
]]>
</Details>
</BugPattern>
-
+
+ <BugPattern type="CAAL_CONFUSING_ARRAY_AS_LIST">
+ <ShortDescription>Method calls Array.asList on an array of primitive values</ShortDescription>
+ <LongDescription>Method {1} calls Array.asList on an array of primitive values</LongDescription>
+ <Details>
+ <![CDATA[
+ <p> This method passes an array of primitive values to the Array.asList call. As primitive
+ values in arrays aren't automatically promoted to boxed primitives in arrays, the asList call
+ cannot convert this array in a list of boxed primitives. It therefore just creates an array
+ with one item in it, the array itself. This is rarely what is desired.
+ </p>
+ ]]>
+ </Details>
+ </BugPattern>
+
<!-- BugCode -->
<BugCode abbrev="ISB">Inefficient String Buffering</BugCode>
@@ -3602,4 +3627,5 @@
<BugCode abbrev="CCNE">Compare class name equals</BugCode>
<BugCode abbrev="BRPI">Backport concurrent reuse of public identifiers</BugCode>
<BugCode abbrev="CU">Clone Usability</BugCode>
+ <BugCode abbrev="CAAL">Confusing Array asList</BugCode>
</MessageCollection>
Modified: trunk/fb-contrib/htdocs/repository.html
===================================================================
--- trunk/fb-contrib/htdocs/repository.html 2013-01-30 06:57:26 UTC (rev 1739)
+++ trunk/fb-contrib/htdocs/repository.html 2013-02-06 05:02:24 UTC (rev 1740)
@@ -18,14 +18,16 @@
<p><a href="http://master.dl.sourceforge.net/project/fb-contrib/repo">http://master.dl.sourceforge.net/project/fb-contrib/repo</a></p>
-<div style="width: 200px">
+<div style="width: 400px">
<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>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr>
<tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr>
<tr><td><b>Version:</b></td><td>4.8.2</td></tr>
</table>
</div>
+<p>fb-contrib is also now available at <a href="http://search.maven.org">search.maven.org</a></p>
+
</div>
</body>
</html>
Modified: trunk/fb-contrib/pom.xml
===================================================================
--- trunk/fb-contrib/pom.xml 2013-01-30 06:57:26 UTC (rev 1739)
+++ trunk/fb-contrib/pom.xml 2013-02-06 05:02:24 UTC (rev 1740)
@@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.mebigfatguy.fb-contrib</groupId>
<artifactId>fb-contrib</artifactId>
- <version>4.8.2</version>
+ <version>4.9.0</version>
<parent>
<groupId>org.sonatype.oss</groupId>
Modified: trunk/fb-contrib/samples/STB_Sample.java
===================================================================
--- trunk/fb-contrib/samples/STB_Sample.java 2013-01-30 06:57:26 UTC (rev 1739)
+++ trunk/fb-contrib/samples/STB_Sample.java 2013-02-06 05:02:24 UTC (rev 1740)
@@ -18,6 +18,38 @@
}
}
+ public void testSTB2(File f1, File f2) throws STBException {
+ try {
+ InputStream is = new FileInputStream(f1);
+ } catch (IOException ioe) {
+ throw new STBException("It's broken");
+ }
+
+ try {
+ InputStream is = new FileInputStream(f2);
+ } catch (IOException ioe) {
+ throw new STBException("It's broken");
+ }
+ }
+
+ public void testSTB3(File f1, File f2) throws STBException {
+ try {
+ InputStream is = new FileInputStream(f1);
+ } catch (IOException ioe) {
+ STBException se = new STBException("It's broken");
+ se.initCause(ioe);
+ throw se;
+ }
+
+ try {
+ InputStream is = new FileInputStream(f2);
+ } catch (IOException ioe) {
+ STBException se = new STBException("It's broken");
+ se.initCause(ioe);
+ throw se;
+ }
+ }
+
public void fpTestMethodDeclaresThrownType(File f1, File f2) throws STBException, IOException {
try {
InputStream is = new FileInputStream(f1);
@@ -31,7 +63,7 @@
throw new STBException();
}
}
-
+
public void fpTestDiffMessages(File f1, File f2) throws STBException {
try {
InputStream is = new FileInputStream(f1);
@@ -45,7 +77,7 @@
throw new STBException("Couldn't open file 2");
}
}
-
+
public void fpTestDiffMessagesByAppending(File f1, File f2) throws STBException {
try {
InputStream is = new FileInputStream(f1);
@@ -61,10 +93,10 @@
}
static class STBException extends Exception {
-
+
public STBException() {
}
-
+
public STBException(String message) {
super(message);
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java 2013-01-30 06:57:26 UTC (rev 1739)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java 2013-02-06 05:02:24 UTC (rev 1740)
@@ -88,11 +88,11 @@
case ASTORE_1:
case ASTORE_2:
case ASTORE_3:
- if(stack.getStackDepth() > 0){
- OpcodeStack.Item item = stack.getStackItem(0);
+ if(stack.getStackDepth() > 0) {
LocalVariable lv = getMethod().getLocalVariableTable()
.getLocalVariable(RegisterUtils.getAStoreReg(this, seen), getNextPC());
- if(lv != null){
+ if(lv != null) {
+ OpcodeStack.Item item = stack.getStackItem(0);
String sourceSignature = item.getSignature();
String targetSignature = lv.getSignature();
checkSignatures(sourceSignature, targetSignature);
@@ -101,7 +101,7 @@
break;
case PUTFIELD:
case PUTSTATIC:
- if(stack.getStackDepth() > 0){
+ if(stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
String sourceSignature = item.getSignature();
String targetSignature = getSigConstantOperand();
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java 2013-01-30 06:57:26 UTC (rev 1739)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java 2013-02-06 05:02:24 UTC (rev 1740)
@@ -19,7 +19,9 @@
package com.mebigfatguy.fbcontrib.detect;
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.generic.Type;
@@ -35,6 +37,13 @@
public class PossibleConstantAllocationInLoop extends BytecodeScanningDetector {
+ private static final Set<String> SYNTHETIC_ALLOCATION_CLASSES = new HashSet<String>();
+ static {
+ SYNTHETIC_ALLOCATION_CLASSES.add("java/lang/StringBuffer");
+ SYNTHETIC_ALLOCATION_CLASSES.add("java/lang/StringBuilder");
+ SYNTHETIC_ALLOCATION_CLASSES.add("java/lang/AssertionError");
+ }
+
private final BugReporter bugReporter;
private OpcodeStack stack;
/** allocation number, info where allocated */
@@ -119,7 +128,7 @@
case INVOKESPECIAL:
if ("<init>".equals(getNameConstantOperand()) && "()V".equals(getSigConstantOperand())) {
String clsName = getClassConstantOperand();
- if (!"java/lang/StringBuffer".equals(clsName) && !"java/lang/StringBuilder".equals(clsName)) {
+ if (!SYNTHETIC_ALLOCATION_CLASSES.contains(clsName)) {
sawAllocationNumber = Integer.valueOf(nextAllocationNumber);
allocations.put(sawAllocationNumber, new AllocationInfo(getPC()));
sawAllocation = true;
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2013-01-30 06:57:26 UTC (rev 1739)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2013-02-06 05:02:24 UTC (rev 1740)
@@ -1,17 +1,17 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
* Copyright (C) 2005-2013 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,7 +51,7 @@
private static final String SAW_TEXT_LABEL = "SAW_TEXT_LABEL";
private static final String FROM_UIMANAGER = "FROM_UIMANAGER";
private static final String APPENDED_STRING = "APPENDED_STRING";
-
+
private static JavaClass windowClass;
private static JavaClass componentClass;
private static JavaClass jcomponentClass;
@@ -83,16 +83,16 @@
clsNFException = cnfe;
}
}
-
+
private static final Map<String, Integer> displayTextMethods = new HashMap<String, Integer>();
static {
- displayTextMethods.put("javax/swing/JLabel#<init>(Ljava/lang/String;)", Integer.valueOf(0));
+ displayTextMethods.put("javax/swing/JLabel#<init>(Ljava/lang/String;)", Integer.valueOf(0));
displayTextMethods.put("javax/swing/JLabel#<init>(Ljava/lang/String;Ljavax/swing/Icon;I)", Integer.valueOf(1));
displayTextMethods.put("javax/swing/JLabel#<init>(Ljava/lang/String;I)", Integer.valueOf(2));
- displayTextMethods.put("javax/swing/JButton#<init>(Ljava/lang/String;)", Integer.valueOf(0));
- displayTextMethods.put("javax/swing/JButton#<init>(Ljava/lang/String;Ljavax/swing/Icon;)", Integer.valueOf(1));
- displayTextMethods.put("javax/swing/JFrame#<init>(Ljava/lang/String;)", Integer.valueOf(0));
- displayTextMethods.put("javax/swing/JFrame#<init>(Ljava/lang/String;Ljava/awt/GraphicsConfiguration;)", Integer.valueOf(1));
+ displayTextMethods.put("javax/swing/JButton#<init>(Ljava/lang/String;)", Integer.valueOf(0));
+ displayTextMethods.put("javax/swing/JButton#<init>(Ljava/lang/String;Ljavax/swing/Icon;)", Integer.valueOf(1));
+ displayTextMethods.put("javax/swing/JFrame#<init>(Ljava/lang/String;)", Integer.valueOf(0));
+ displayTextMethods.put("javax/swing/JFrame#<init>(Ljava/lang/String;Ljava/awt/GraphicsConfiguration;)", Integer.valueOf(1));
displayTextMethods.put("javax/swing/JDialog#<init>(Ljava/awt/Dialog;Ljava/lang/String;)", Integer.valueOf(0));
displayTextMethods.put("javax/swing/JDialog#<init>(Ljava/awt/Dialog;Ljava/lang/String;Z)", Integer.valueOf(1));
displayTextMethods.put("javax/swing/JDialog#<init>(Ljava/awt/Dialog;Ljava/lang/String;ZLjava/awt/GraphicsConfiguration;)", Integer.valueOf(2));
@@ -102,12 +102,12 @@
displayTextMethods.put("java/awt/Dialog#setTitle(Ljava/lang/String;)", Integer.valueOf(0));
displayTextMethods.put("java/awt/Frame#setTitle(Ljava/lang/String;)", Integer.valueOf(0));
displayTextMethods.put("javax/swing/JMenu#<init>(Ljava/lang/String;)", Integer.valueOf(0));
- displayTextMethods.put("javax/swing/JMenu#<init>(Ljava/lang/String;Z)", Integer.valueOf(1));
- displayTextMethods.put("javax/swing/JMenuItem#<init>(Ljava/lang/String;)", Integer.valueOf(0));
+ displayTextMethods.put("javax/swing/JMenu#<init>(Ljava/lang/String;Z)", Integer.valueOf(1));
+ displayTextMethods.put("javax/swing/JMenuItem#<init>(Ljava/lang/String;)", Integer.valueOf(0));
displayTextMethods.put("javax/swing/JMenuItem#<init>(Ljava/lang/String;Ljavax/swing/Icon;)", Integer.valueOf(1));
displayTextMethods.put("javax/swing/JMenuItem#<init>(Ljava/lang/String;I)", Integer.valueOf(1));
}
-
+
private final BugReporter bugReporter;
private OpcodeStack stack;
private Set<XField> fieldLabels;
@@ -125,7 +125,7 @@
/**
* implements the visitor to create and clear the stack
- *
+ *
* @param classContext the context object of the currently visited class
*/
@Override
@@ -161,7 +161,7 @@
/**
* looks for fields that are JLabels and stores them in a set
- *
+ *
* @param obj the field object of the current field
*/
@Override
@@ -176,7 +176,7 @@
/**
* implements the visitor to reset the stack
- *
+ *
* @param obj the context object for the currently visited code block
*/
@Override
@@ -199,7 +199,7 @@
/**
* implements the visitor to find 508 compliance concerns
- *
+ *
* @param seen the opcode of the currently parsed instruction
*/
@Override
@@ -239,7 +239,7 @@
} else if (seen == INVOKEVIRTUAL) {
String className = getClassConstantOperand();
String methodName = getNameConstantOperand();
-
+
if ("javax/swing/JLabel".equals(className)) {
if ("setLabelFor".equals(methodName)) {
if (stack.getStackDepth() > 1) {
@@ -276,7 +276,7 @@
}
}
}
-
+
processSetSizeOps(methodName);
processNullLayouts(className, methodName);
processSetColorOps(methodName);
@@ -285,7 +285,7 @@
sawUIManager = true;
}
}
-
+
if ((seen == INVOKEVIRTUAL) || (seen == INVOKESPECIAL) || (seen == INVOKEINTERFACE)) {
processFaultyGuiStrings();
}
@@ -304,7 +304,7 @@
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
item.setUserValue(FROM_UIMANAGER);
- }
+ }
} else if (sawAppend) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
@@ -313,7 +313,7 @@
}
}
}
-
+
/**
* looks for calls to set a readable string that is generated from a static constant, as these strings
* are not translatable. also looks for setting readable strings that are appended together. This is
@@ -329,7 +329,7 @@
methodInfo.append(signature);
Integer parmIndex = displayTextMethods.get(methodInfo.toString());
if (parmIndex != null) {
- if (stack.getStackDepth() >= parmIndex.intValue()) {
+ if (stack.getStackDepth() > parmIndex.intValue()) {
OpcodeStack.Item item = stack.getStackItem(parmIndex.intValue());
if (item.getConstant() != null) {
bugReporter.reportBug(new BugInstance(this, "S508C_NON_TRANSLATABLE_STRING", NORMAL_PRIORITY)
@@ -341,15 +341,15 @@
.addClass(this)
.addMethod(this)
.addSourceLine(this));
-
+
}
}
}
}
-
+
/**
* looks for containers where a null layout is installed
- *
+ *
* @param className class that a method call is made on
* @param methodName name of the method that is called
*/
@@ -368,12 +368,12 @@
}
}
}
-
+
/**
* looks for calls to set the color of components where the color isn't from UIManager
- *
+ *
* @param methodName the method that is called
- *
+ *
* @throws ClassNotFoundException if the gui component class can't be found
*/
private void processSetColorOps(String methodName) throws ClassNotFoundException {
@@ -396,12 +396,12 @@
}
}
}
-
+
/**
* looks for calls to setSize on components, rather than letting the layout manager set them
- *
+ *
* @param methodName the method that was called on a component
- *
+ *
* @throws ClassNotFoundException if the gui class wasn't found
*/
private void processSetSizeOps(String methodName) throws ClassNotFoundException {
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java 2013-01-30 06:57:26 UTC (rev 1739)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java 2013-02-06 05:02:24 UTC (rev 1740)
@@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -33,7 +34,7 @@
public class StackedTryBlocks extends BytecodeScanningDetector {
private static JavaClass THROWABLE_CLASS;
-
+
static {
try {
THROWABLE_CLASS = Repository.lookupClass("java.lang.Throwable");
@@ -44,6 +45,7 @@
private final BugReporter bugReporter;
private List<TryBlock> blocks;
private List<TryBlock> inBlocks;
+ private List<Integer> transitionPoints;
private OpcodeStack stack;
public StackedTryBlocks(BugReporter bugReporter) {
@@ -72,6 +74,7 @@
blocks = new ArrayList<TryBlock>();
inBlocks = new ArrayList<TryBlock>();
+ transitionPoints = new ArrayList<Integer>();
CodeException[] ces = obj.getExceptionTable();
for (CodeException ce : ces) {
@@ -99,19 +102,23 @@
super.visitCode(obj);
if (blocks.size() > 1) {
- TryBlock firstBlock = blocks.get(0);
+ Collections.sort(transitionPoints);
+
+ TryBlock firstBlock = blocks.get(0);
for (int i = 1; i < blocks.size(); i++) {
TryBlock secondBlock = blocks.get(i);
- if ((firstBlock.getCatchType() == secondBlock.getCatchType())
- && (firstBlock.getThrowSignature().equals(secondBlock.getThrowSignature())
- && ((firstBlock.getMessage().length() > 0) && firstBlock.getMessage().equals(secondBlock.getMessage())
- && (firstBlock.getExceptionSignature().equals(secondBlock.getExceptionSignature()))))) {
- bugReporter.reportBug(new BugInstance(this, "STB_STACKED_TRY_BLOCKS", NORMAL_PRIORITY)
- .addClass(this).addMethod(this)
- .addSourceLineRange(this, firstBlock.getStartPC(), firstBlock.getEndHandlerPC())
- .addSourceLineRange(this, secondBlock.getStartPC(), secondBlock.getEndHandlerPC()));
+ if (!blocksSplitAcrossTransitions(firstBlock, secondBlock)) {
+ if ((firstBlock.getCatchType() == secondBlock.getCatchType())
+ && (firstBlock.getThrowSignature().equals(secondBlock.getThrowSignature())
+ && (firstBlock.getMessage().equals(secondBlock.getMessage())
+ && (firstBlock.getExceptionSignature().equals(secondBlock.getExceptionSignature()))))) {
+ bugReporter.reportBug(new BugInstance(this, "STB_STACKED_TRY_BLOCKS", NORMAL_PRIORITY)
+ .addClass(this).addMethod(this)
+ .addSourceLineRange(this, firstBlock.getStartPC(), firstBlock.getEndHandlerPC())
+ .addSourceLineRange(this, secondBlock.getStartPC(), secondBlock.getEndHandlerPC()));
+ }
}
firstBlock = secondBlock;
@@ -121,6 +128,7 @@
} finally {
blocks = null;
inBlocks = null;
+ transitionPoints = null;
}
}
@@ -129,6 +137,12 @@
String message = null;
try {
+ if ((seen == TABLESWITCH) || (seen == LOOKUPSWITCH)) {
+ for (int offset : getSwitchOffsets()) {
+ transitionPoints.add(Integer.valueOf(offset));
+ }
+ }
+
int pc = getPC();
TryBlock block = findBlockWithStart(pc);
if (block != null) {
@@ -178,16 +192,19 @@
if (exCls.instanceOf(THROWABLE_CLASS)) {
String signature = getSigConstantOperand();
Type[] types = Type.getArgumentTypes(signature);
- if ((types.length > 0) && "Ljava/lang/String;".equals(types[0].getSignature())) {
- if (stack.getStackDepth() >= types.length) {
- OpcodeStack.Item item = stack.getStackItem(types.length - 1);
- message = (String)item.getConstant();
- if (message == null) {
- message = "____UNKNOWN____" + System.currentTimeMillis();
- }
+ if (types.length > 0) {
+ if ("Ljava/lang/String;".equals(types[0].getSignature())) {
+ if (stack.getStackDepth() >= types.length) {
+ OpcodeStack.Item item = stack.getStackItem(types.length - 1);
+ message = (String)item.getConstant();
+ if (message == null) {
+ message = "____UNKNOWN____" + System.identityHashCode(item);
+ }
+ }
}
+ } else {
+ message = "";
}
-
}
}
}
@@ -214,6 +231,22 @@
return null;
}
+ private boolean blocksSplitAcrossTransitions(TryBlock firstBlock, TryBlock secondBlock) {
+ if (!transitionPoints.isEmpty()) {
+ Iterator<Integer> it = transitionPoints.iterator();
+ while (it.hasNext()) {
+ Integer transitionPoint = it.next();
+ if (transitionPoint.intValue() < firstBlock.handlerPC) {
+ it.remove();
+ } else {
+ return transitionPoint.intValue() < secondBlock.handlerPC;
+ }
+ }
+ }
+
+ return false;
+ }
+
static class TryBlock {
public enum State {
@@ -277,11 +310,11 @@
public void setExceptionSignature(String sig) {
exSig = sig;
}
-
+
public void setThrowSignature(String sig) {
throwSig = sig;
}
-
+
public void setMessage(String m) {
message = m;
}
@@ -289,13 +322,13 @@
public String getExceptionSignature() {
return (exSig == null) ? String.valueOf(System.identityHashCode(this)) : exSig;
}
-
+
public String getThrowSignature() {
return (throwSig == null) ? String.valueOf(System.identityHashCode(this)) : throwSig;
}
-
+
public String getMessage() {
- return (message == null) ? String.valueOf(System.identityHashCode(this)) : message;
+ return (message == null) ? String.valueOf(System.identityHashCode(this)) : message;
}
public int getStartPC() {
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2013-01-30 06:57:26 UTC (rev 1739)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2013-02-06 05:02:24 UTC (rev 1740)
@@ -85,14 +85,15 @@
public void visitCode(Code obj) {
try {
Method m = getMethod();
- String methodName = m.getName();
String signature = m.getSignature();
if (signature.endsWith(")Ljava/lang/Object;")) {
- boolean isInherited = SignatureUtils.isInheritedMethod(currentClass, methodName, signature);
stack.resetForMethodEntry(this);
returnTypes.clear();
super.visitCode(obj);
if (returnTypes.size() > 1) {
+ String methodName = m.getName();
+ boolean isInherited = SignatureUtils.isInheritedMethod(currentClass, methodName, signature);
+
int priority = NORMAL_PRIORITY;
for (JavaClass cls : returnTypes.keySet()) {
if ((cls != null) && "java.lang.Object".equals(cls.getClassName())) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|