fb-contrib-commit Mailing List for fb-contrib (Page 13)
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...> - 2010-04-04 08:27:31
|
Revision: 1540
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1540&view=rev
Author: dbrosius
Date: 2010-04-04 08:27:25 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
add fp based on two assigns to the same reg
Modified Paths:
--------------
trunk/fb-contrib/samples/PCAIL_Sample.java
Modified: trunk/fb-contrib/samples/PCAIL_Sample.java
===================================================================
--- trunk/fb-contrib/samples/PCAIL_Sample.java 2010-04-04 08:21:52 UTC (rev 1539)
+++ trunk/fb-contrib/samples/PCAIL_Sample.java 2010-04-04 08:27:25 UTC (rev 1540)
@@ -1,4 +1,7 @@
import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeSet;
public class PCAIL_Sample
@@ -75,4 +78,19 @@
throw new RuntimeException();
}
}
+
+ public void fpTwoAssigns()
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ Set<String> s;
+
+ if ((i % 2) == 0)
+ s = new HashSet<String>();
+ else
+ s = new TreeSet<String>();
+
+ s.add(String.valueOf(i));
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-04-04 08:21:58
|
Revision: 1539
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1539&view=rev
Author: dbrosius
Date: 2010-04-04 08:21:52 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
don't report throws of new Exceptions with no parms
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java 2010-04-04 08:18:39 UTC (rev 1538)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java 2010-04-04 08:21:52 UTC (rev 1539)
@@ -198,6 +198,7 @@
break;
case ARETURN:
+ case ATHROW:
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
Integer allocation = (Integer)item.getUserValue();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-04-04 08:18:45
|
Revision: 1538
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1538&view=rev
Author: dbrosius
Date: 2010-04-04 08:18:39 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
revert -- getting assertion errors
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java 2010-04-04 08:12:31 UTC (rev 1537)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java 2010-04-04 08:18:39 UTC (rev 1538)
@@ -128,17 +128,27 @@
@Override
public void sawOpcode(int seen) {
- ReportInfo info = null;
- if (seen == INVOKESPECIAL || seen == INVOKESTATIC) {
- // static method invocation: no dispatch, straight call
- info = dumbMethods.get(getMethodSignature());
- } else if (seen == INVOKEVIRTUAL || seen == INVOKEINTERFACE) {
- // virtual method invocation: dispatch is based on the class
- info = dumbMethods.get(getVirtualMethodSignature());
- }
- if (info != null) {
- reportBug(info);
+ if (seen == INVOKEVIRTUAL
+ || seen == INVOKEINTERFACE
+ || seen == INVOKESPECIAL
+ || seen == INVOKESTATIC) {
+ final ReportInfo info = dumbMethods.get(getMethodSignature());
+ if (info != null) {
+ reportBug(info);
+ }
}
+
+// ReportInfo info = null;
+// if (seen == INVOKESPECIAL || seen == INVOKESTATIC) {
+// // static method invocation: no dispatch, straight call
+// info = dumbMethods.get(getMethodSignature());
+// } else if (seen == INVOKEVIRTUAL || seen == INVOKEINTERFACE) {
+// // virtual method invocation: dispatch is based on the class
+// info = dumbMethods.get(getVirtualMethodSignature());
+// }
+// if (info != null) {
+// reportBug(info);
+// }
}
private String getMethodSignature() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-04-04 08:12:38
|
Revision: 1537
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1537&view=rev
Author: dbrosius
Date: 2010-04-04 08:12:31 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
add test for throw fp
Modified Paths:
--------------
trunk/fb-contrib/samples/PCAIL_Sample.java
Modified: trunk/fb-contrib/samples/PCAIL_Sample.java
===================================================================
--- trunk/fb-contrib/samples/PCAIL_Sample.java 2010-04-04 08:03:04 UTC (rev 1536)
+++ trunk/fb-contrib/samples/PCAIL_Sample.java 2010-04-04 08:12:31 UTC (rev 1537)
@@ -66,4 +66,13 @@
for (int i = 0; i < 3; i++)
samples[i] = new PCAIL_Sample();
}
+
+ public void fpThrow()
+ {
+ for (int i = 0; i < 3; i++)
+ {
+ if (i == 3)
+ throw new RuntimeException();
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-04-04 08:03:10
|
Revision: 1536
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1536&view=rev
Author: dbrosius
Date: 2010-04-04 08:03:04 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
more tests
Modified Paths:
--------------
trunk/fb-contrib/samples/S508C_Sample.java
Modified: trunk/fb-contrib/samples/S508C_Sample.java
===================================================================
--- trunk/fb-contrib/samples/S508C_Sample.java 2010-04-04 08:02:00 UTC (rev 1535)
+++ trunk/fb-contrib/samples/S508C_Sample.java 2010-04-04 08:03:04 UTC (rev 1536)
@@ -29,6 +29,12 @@
setSize(300, 200);
}
+
+ public void testI18N()
+ {
+ JLabel l = new JLabel("Hello");
+ JFrame f = new JFrame("foo");
+ }
}
class MyComponent extends JComponent
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-04-04 08:02:06
|
Revision: 1535
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1535&view=rev
Author: dbrosius
Date: 2010-04-04 08:02:00 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
naming
Modified Paths:
--------------
trunk/fb-contrib/samples/PRMC_Sample.java
Modified: trunk/fb-contrib/samples/PRMC_Sample.java
===================================================================
--- trunk/fb-contrib/samples/PRMC_Sample.java 2010-04-04 07:59:59 UTC (rev 1534)
+++ trunk/fb-contrib/samples/PRMC_Sample.java 2010-04-04 08:02:00 UTC (rev 1535)
@@ -32,7 +32,7 @@
return data.equals(rmc.data);
}
- public void staticRMC()
+ public void staticPRMC()
{
Factory.getInstance().fee();
Factory.getInstance().fi();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-04-04 08:00:05
|
Revision: 1534
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1534&view=rev
Author: dbrosius
Date: 2010-04-04 07:59:59 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
updates to MDM by Jean-Noel Rouvignac, Thanks!
Added Paths:
-----------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/XClassUtils.java
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/XClassUtils.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/XClassUtils.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/XClassUtils.java 2010-04-04 07:59:59 UTC (rev 1534)
@@ -0,0 +1,107 @@
+/*
+ * fb-contrib - Auxiliary detectors for Java programs
+ * Copyright (C) 2009-2010 Jean-Noel Rouvignac
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.mebigfatguy.fbcontrib.utils;
+
+import edu.umd.cs.findbugs.ba.XClass;
+import edu.umd.cs.findbugs.ba.XMethod;
+import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
+import edu.umd.cs.findbugs.classfile.ClassDescriptor;
+import edu.umd.cs.findbugs.classfile.DescriptorFactory;
+import edu.umd.cs.findbugs.classfile.Global;
+
+/**
+ * Utility class for XClass and XMethod classes.
+ *
+ * @author Jean-Noel Rouvignac
+ */
+public class XClassUtils {
+
+ /**
+ * Returns an <code>XClass</code> object for the given
+ * <code>ClassDescriptor</code> object.
+ *
+ * @param classDesc
+ * the class descriptor for which to find the XClass object
+ * @return the class
+ * @throws AssertionError
+ */
+ public XClass getXClass(final ClassDescriptor classDesc) throws AssertionError {
+ try {
+ return Global.getAnalysisCache().getClassAnalysis(XClass.class,
+ classDesc);
+ } catch (CheckedAnalysisException e) {
+ throw new AssertionError("Can't find ClassInfo for " + classDesc);
+ }
+ }
+
+ /**
+ * Returns an <code>XClass</code> object for the given slashed class name.
+ *
+ * @param slashedClassName
+ * the class name for which to find the XClass object
+ * @return the class
+ * @throws AssertionError
+ */
+ public XClass getXClass(String slashedClassName) {
+ return getXClass(DescriptorFactory
+ .createClassDescriptor(slashedClassName));
+ }
+
+ /**
+ * Looks for the method up the class hierarchy.
+ *
+ * @param xClass
+ * the class where to look for the method
+ * @param methodName
+ * the name of the method to look for
+ * @param methodSig
+ * the signature of the method to look for
+ * @return the method
+ */
+ public XMethod getXMethod(final XClass xClass, final String methodName, final String methodSig) {
+ if (xClass == null) {
+ return null;
+ }
+
+ XMethod xMethod = xClass.findMethod(methodName, methodSig, false);
+ if (xMethod == null) {
+ final XClass superClass = getXClass(xClass
+ .getSuperclassDescriptor());
+ xMethod = getXMethod(superClass, methodName, methodSig);
+ }
+ return xMethod;
+ }
+
+ /**
+ * Looks for the method up the class hierarchy.
+ *
+ * @param slashedClassName
+ * the class slashed name where to look for the method
+ * @param methodName
+ * the name of the method to look for
+ * @param methodSig
+ * the signature of the method to look for
+ * @return the method
+ */
+ public XMethod getXMethod(String slashedClassName, String methodName, String methodSig) {
+ final XClass xClass = getXClass(slashedClassName);
+ return getXMethod(xClass, methodName, methodSig);
+ }
+
+}
Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/XClassUtils.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...> - 2010-04-04 07:59:46
|
Revision: 1533
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1533&view=rev
Author: dbrosius
Date: 2010-04-04 07:59:40 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
updates to MDM by Jean-Noel Rouvignac, Thanks!
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java 2010-04-04 07:05:42 UTC (rev 1532)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java 2010-04-04 07:59:40 UTC (rev 1533)
@@ -1,6 +1,7 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
* Copyright (C) 2005-2010 Chris Peterson
+ * Copyright (C) 2005-2010 Jean-Noel Rouvignac
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -21,9 +22,12 @@
import java.util.HashMap;
import java.util.Map;
+import com.mebigfatguy.fbcontrib.utils.XClassUtils;
+
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
import edu.umd.cs.findbugs.BytecodeScanningDetector;
+import edu.umd.cs.findbugs.ba.XMethod;
/**
* looks for method calls that are unsafe or might indicate bugs.
@@ -109,7 +113,9 @@
dumbMethods.put("java/lang/String.getBytes()[B", new ReportInfo("MDM_STRING_BYTES_ENCODING", NORMAL_PRIORITY));
dumbMethods.put("java/util/Locale.setDefault(Ljava/util/Locale;)V", new ReportInfo("MDM_SETDEFAULTLOCALE", NORMAL_PRIORITY));
}
+
private final BugReporter bugReporter;
+ private final XClassUtils classUtil = new XClassUtils();
/**
* constructs an MDM detector given the reporter to report bugs on
@@ -121,14 +127,17 @@
@Override
public void sawOpcode(int seen) {
- if (seen == INVOKEVIRTUAL
- || seen == INVOKEINTERFACE
- || seen == INVOKESPECIAL
- || seen == INVOKESTATIC) {
- final ReportInfo info = dumbMethods.get(getMethodSignature());
- if (info != null) {
- reportBug(info);
- }
+
+ ReportInfo info = null;
+ if (seen == INVOKESPECIAL || seen == INVOKESTATIC) {
+ // static method invocation: no dispatch, straight call
+ info = dumbMethods.get(getMethodSignature());
+ } else if (seen == INVOKEVIRTUAL || seen == INVOKEINTERFACE) {
+ // virtual method invocation: dispatch is based on the class
+ info = dumbMethods.get(getVirtualMethodSignature());
+ }
+ if (info != null) {
+ reportBug(info);
}
}
@@ -138,7 +147,20 @@
final String methodSig = getSigConstantOperand();
return String.format("%s.%s%s", className, methodName, methodSig);
}
+
+ private String getVirtualMethodSignature() {
+ final XMethod declaredMethod = classUtil.getXMethod(
+ getClassConstantOperand(), getNameConstantOperand(),
+ getSigConstantOperand());
+ final String className = declaredMethod.getClassDescriptor()
+ .getClassName();
+ final String methodName = declaredMethod.getName();
+ final String methodSig = declaredMethod.getSignature();
+ return String.format("%s.%s%s", className, methodName, methodSig);
+ }
+
+
private void reportBug(ReportInfo info) {
bugReporter.reportBug(new BugInstance(this, info.getPattern(), info.getPriority())
.addClass(this)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-04-04 07:05:48
|
Revision: 1532
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1532&view=rev
Author: dbrosius
Date: 2010-04-04 07:05:42 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
better message
Modified Paths:
--------------
trunk/fb-contrib/etc/messages.xml
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2010-04-04 06:57:39 UTC (rev 1531)
+++ trunk/fb-contrib/etc/messages.xml 2010-04-04 07:05:42 UTC (rev 1532)
@@ -3101,7 +3101,9 @@
<![CDATA[
<p>This method allocates an object using the default constructor in a loop, and then
only uses it in a quasi-static way. It is never assigned to anything that lives outside
- the loop, and could potentially be allocated once outside the loop.
+ the loop, and could potentially be allocated once outside the loop. Often this can be
+ achieved by calling a clear() like method in the loop, to reset the state of the object
+ in the loop.
]]>
</Details>
</BugPattern>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-04-04 06:57:45
|
Revision: 1531
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1531&view=rev
Author: dbrosius
Date: 2010-04-04 06:57:39 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
if an allocation is stored in an array, don't report
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java 2010-04-04 06:53:48 UTC (rev 1530)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java 2010-04-04 06:57:39 UTC (rev 1531)
@@ -159,6 +159,16 @@
}
break;
+ case AASTORE:
+ if (stack.getStackDepth() >= 2) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ Integer allocation = (Integer)item.getUserValue();
+ if (allocation != null) {
+ allocations.remove(allocation);
+ }
+ }
+ break;
+
case ALOAD:
case ALOAD_0:
case ALOAD_1:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-04-04 06:53:54
|
Revision: 1530
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1530&view=rev
Author: dbrosius
Date: 2010-04-04 06:53:48 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
add fp for array stores
Modified Paths:
--------------
trunk/fb-contrib/samples/PCAIL_Sample.java
Modified: trunk/fb-contrib/samples/PCAIL_Sample.java
===================================================================
--- trunk/fb-contrib/samples/PCAIL_Sample.java 2010-04-04 06:30:22 UTC (rev 1529)
+++ trunk/fb-contrib/samples/PCAIL_Sample.java 2010-04-04 06:53:48 UTC (rev 1530)
@@ -59,4 +59,11 @@
}
}
}
+
+ public void fpArrayStore()
+ {
+ PCAIL_Sample[] samples = new PCAIL_Sample[3];
+ for (int i = 0; i < 3; i++)
+ samples[i] = new PCAIL_Sample();
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-04-04 06:30:28
|
Revision: 1529
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1529&view=rev
Author: dbrosius
Date: 2010-04-04 06:30:22 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
fix some fps
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java 2010-04-04 06:26:57 UTC (rev 1528)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java 2010-04-04 06:30:22 UTC (rev 1529)
@@ -22,6 +22,7 @@
import java.util.Map;
import org.apache.bcel.classfile.Code;
+import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
@@ -121,6 +122,21 @@
sawAllocationNumber = nextAllocationNumber;
}
}
+ //FALL_THRU
+
+ case INVOKEINTERFACE:
+ case INVOKEVIRTUAL:
+ case INVOKESTATIC:
+ Type[] types = Type.getArgumentTypes(getSigConstantOperand());
+ if (stack.getStackDepth() >= types.length) {
+ for (int i = 0; i < types.length; i++) {
+ OpcodeStack.Item item = stack.getStackItem(i);
+ Integer allocation = (Integer)item.getUserValue();
+ if (allocation != null) {
+ allocations.remove(allocation);
+ }
+ }
+ }
break;
case ASTORE:
@@ -133,7 +149,7 @@
Integer allocation = (Integer)item.getUserValue();
if (allocation != null) {
Integer reg = Integer.valueOf(RegisterUtils.getAStoreReg(this, seen));
- if (storedAllocations.values().contains(reg)) {
+ if (storedAllocations.values().contains(allocation)) {
allocations.remove(allocation);
storedAllocations.remove(reg);
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-04-04 06:27:03
|
Revision: 1528
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1528&view=rev
Author: dbrosius
Date: 2010-04-04 06:26:57 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
add test case for PossibleConstantAllocationInLoop
Added Paths:
-----------
trunk/fb-contrib/samples/PCAIL_Sample.java
Added: trunk/fb-contrib/samples/PCAIL_Sample.java
===================================================================
--- trunk/fb-contrib/samples/PCAIL_Sample.java (rev 0)
+++ trunk/fb-contrib/samples/PCAIL_Sample.java 2010-04-04 06:26:57 UTC (rev 1528)
@@ -0,0 +1,62 @@
+import java.net.URL;
+
+
+public class PCAIL_Sample
+{
+ PCAIL_Sample smpl;
+
+ public void testBasicCase()
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ PCAIL_Sample sample = new PCAIL_Sample();
+ URL u = sample.getClass().getResource("/foo");
+ }
+ }
+
+ public void fpPutField()
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ PCAIL_Sample sample = new PCAIL_Sample();
+ URL u = sample.getClass().getResource("/foo");
+ if (i == 0)
+ smpl = sample;
+ }
+ }
+
+ public void fpTwoRegs()
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ PCAIL_Sample sample = new PCAIL_Sample();
+ URL u = sample.getClass().getResource("/foo");
+ PCAIL_Sample s2 = sample;
+ }
+ }
+
+ public PCAIL_Sample fpReturnAlloc()
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ PCAIL_Sample sample = new PCAIL_Sample();
+ URL u = sample.getClass().getResource("/foo");
+ if (u != null)
+ return sample;
+ }
+
+ return null;
+ }
+
+ public void fpMethodParm()
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ PCAIL_Sample sample = new PCAIL_Sample();
+ if (sample.equals(sample))
+ {
+ return;
+ }
+ }
+ }
+}
Property changes on: trunk/fb-contrib/samples/PCAIL_Sample.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...> - 2010-04-04 05:41:28
|
Revision: 1527
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1527&view=rev
Author: dbrosius
Date: 2010-04-04 05:41:22 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
uncomment PCAIL
Modified Paths:
--------------
trunk/fb-contrib/etc/findbugs.xml
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2010-04-04 04:31:58 UTC (rev 1526)
+++ trunk/fb-contrib/etc/findbugs.xml 2010-04-04 05:41:22 UTC (rev 1527)
@@ -327,11 +327,11 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.ImproperPropertiesUse"
speed="fast"
reports="IPU_IMPROPER_PROPERTIES_USE,IPU_IMPROPER_PROPERTIES_USE_SETPROPERTY" />
-<!--
+
<Detector class="com.mebigfatguy.fbcontrib.detect.PossibleConstantAllocationInLoop"
speed="fast"
reports="PCAIL_POSSIBLE_CONSTANT_ALLOCATION_IN_LOOP" />
- -->
+
<!-- BugPattern -->
<BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-04-04 04:32:04
|
Revision: 1526
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1526&view=rev
Author: dbrosius
Date: 2010-04-04 04:31:58 +0000 (Sun, 04 Apr 2010)
Log Message:
-----------
a first attempt at finding allocations in loops that could be allocated once outside the loop
Added Paths:
-----------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java 2010-04-04 04:31:58 UTC (rev 1526)
@@ -0,0 +1,210 @@
+/*
+ * fb-contrib - Auxiliary detectors for Java programs
+ * Copyright (C) 2005-2010 Dave Brosius
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.mebigfatguy.fbcontrib.detect;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.bcel.classfile.Code;
+
+import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+
+import edu.umd.cs.findbugs.BugInstance;
+import edu.umd.cs.findbugs.BugReporter;
+import edu.umd.cs.findbugs.BytecodeScanningDetector;
+import edu.umd.cs.findbugs.OpcodeStack;
+import edu.umd.cs.findbugs.ba.ClassContext;
+
+public class PossibleConstantAllocationInLoop extends BytecodeScanningDetector {
+
+ private BugReporter bugReporter;
+ private OpcodeStack stack;
+ /** allocation number, info where allocated */
+ private Map<Integer, AllocationInfo> allocations;
+ /** reg, allocation number */
+ private Map<Integer, Integer> storedAllocations;
+ private int nextAllocationNumber;
+
+ public PossibleConstantAllocationInLoop(BugReporter bugReporter) {
+ this.bugReporter = bugReporter;
+ }
+
+ public void visitClassContext(ClassContext classContext) {
+ try {
+ stack = new OpcodeStack();
+ allocations = new HashMap<Integer, AllocationInfo>();
+ storedAllocations = new HashMap<Integer, Integer>();
+ super.visitClassContext(classContext);
+ } finally {
+ stack = null;
+ allocations = null;
+ storedAllocations = null;
+ }
+ }
+
+ public void visitCode(Code obj) {
+ stack.resetForMethodEntry(this);
+ allocations.clear();
+ storedAllocations.clear();
+ nextAllocationNumber = 1;
+ super.visitCode(obj);
+
+ for (AllocationInfo info : allocations.values()) {
+ if (info.loopBottom != -1) {
+ bugReporter.reportBug(new BugInstance(this, "PCAIL_POSSIBLE_CONSTANT_ALLOCATION_IN_LOOP", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(getClassContext(), this, info.allocationPC));
+ }
+ }
+
+ }
+
+ public void sawOpcode(int seen) {
+ boolean sawAllocation = false;
+ Integer sawAllocationNumber = null;
+
+ try {
+ switch (seen) {
+ case IFEQ:
+ case IFNE:
+ case IFLT:
+ case IFGE:
+ case IFGT:
+ case IFLE:
+ case IF_ICMPEQ:
+ case IF_ICMPNE:
+ case IF_ICMPLT:
+ case IF_ICMPGE:
+ case IF_ICMPGT:
+ case IF_ICMPLE:
+ case IF_ACMPEQ:
+ case IF_ACMPNE:
+ case IFNULL:
+ case IFNONNULL:
+ case GOTO:
+ case GOTO_W:
+ if (getBranchOffset() < 0) {
+ int branchLoc = getBranchTarget();
+ int pc = getPC();
+ for (AllocationInfo info : allocations.values()) {
+ if ((info.loopTop == -1) && (branchLoc < info.allocationPC)) {
+ info.loopTop = branchLoc;
+ info.loopBottom = pc;
+ }
+ }
+ }
+ break;
+
+ case INVOKESPECIAL:
+ if ("<init>".equals(getNameConstantOperand()) && "()V".equals(getSigConstantOperand())) {
+ String clsName = getClassConstantOperand();
+ if (!"java/lang/StringBuffer".equals(clsName) && !"java/lang/StringBuilder".equals(clsName)) {
+ allocations.put(Integer.valueOf(nextAllocationNumber), new AllocationInfo(getPC()));
+ sawAllocation = true;
+ sawAllocationNumber = nextAllocationNumber;
+ }
+ }
+ break;
+
+ case ASTORE:
+ case ASTORE_0:
+ case ASTORE_1:
+ case ASTORE_2:
+ case ASTORE_3:
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ Integer allocation = (Integer)item.getUserValue();
+ if (allocation != null) {
+ Integer reg = Integer.valueOf(RegisterUtils.getAStoreReg(this, seen));
+ if (storedAllocations.values().contains(reg)) {
+ allocations.remove(allocation);
+ storedAllocations.remove(reg);
+ } else {
+ storedAllocations.put(reg, allocation);
+ }
+ }
+ }
+ break;
+
+ case ALOAD:
+ case ALOAD_0:
+ case ALOAD_1:
+ case ALOAD_2:
+ case ALOAD_3: {
+ Integer reg = Integer.valueOf(RegisterUtils.getALoadReg(this, seen));
+ Integer allocation = storedAllocations.get(reg);
+ if (allocation != null) {
+ AllocationInfo info = allocations.get(allocation);
+ if ((info != null) && (info.loopBottom != -1)) {
+ allocations.remove(allocation);
+ storedAllocations.remove(reg);
+ } else {
+ sawAllocationNumber = allocation.intValue();
+ sawAllocation = true;
+ }
+ }
+ }
+ break;
+
+ case PUTFIELD:
+ if (stack.getStackDepth() > 1) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ Integer allocation = (Integer)item.getUserValue();
+ allocations.remove(allocation);
+ }
+ break;
+
+ case ARETURN:
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ Integer allocation = (Integer)item.getUserValue();
+ if (allocation != null) {
+ allocations.remove(allocation);
+ }
+ }
+ break;
+ }
+ } finally {
+ stack.sawOpcode(this, seen);
+ if (sawAllocation) {
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ item.setUserValue(Integer.valueOf(sawAllocationNumber));
+ }
+
+ if (seen == INVOKESPECIAL)
+ nextAllocationNumber++;
+ }
+ }
+ }
+
+ static class AllocationInfo {
+
+ int allocationPC;
+ int loopTop;
+ int loopBottom;
+
+ public AllocationInfo(int pc) {
+ allocationPC = pc;
+ loopTop = -1;
+ loopBottom = -1;
+ }
+ }
+}
Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.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...> - 2010-04-03 15:25:05
|
Revision: 1525
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1525&view=rev
Author: dbrosius
Date: 2010-04-03 15:24:59 +0000 (Sat, 03 Apr 2010)
Log Message:
-----------
add SPP check for calling System.arraycopy with a non array for either array parms
Modified Paths:
--------------
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/etc/messages.xml
trunk/fb-contrib/samples/SPP_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2010-03-15 05:46:12 UTC (rev 1524)
+++ trunk/fb-contrib/etc/findbugs.xml 2010-04-03 15:24:59 UTC (rev 1525)
@@ -209,7 +209,7 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.SillynessPotPourri"
speed="fast"
- reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TRINARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING" />
+ reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TRINARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM" />
<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope"
speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" />
@@ -327,7 +327,11 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.ImproperPropertiesUse"
speed="fast"
reports="IPU_IMPROPER_PROPERTIES_USE,IPU_IMPROPER_PROPERTIES_USE_SETPROPERTY" />
-
+<!--
+ <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleConstantAllocationInLoop"
+ speed="fast"
+ reports="PCAIL_POSSIBLE_CONSTANT_ALLOCATION_IN_LOOP" />
+ -->
<!-- BugPattern -->
<BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING"
@@ -501,6 +505,7 @@
experimental="true" />
<BugPattern abbrev="SPP" type="SPP_SERIALVER_SHOULD_BE_PRIVATE"
category="STYLE" />
+ <BugPattern abbrev="SPP" type="SPP_NON_ARRAY_PARM" category="CORRECTNESS" />
<BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE"
category="PERFORMANCE" />
<BugPattern abbrev="SCII"
@@ -620,4 +625,6 @@
category="CORRECTNESS" experimental="true" />
<BugPattern abbrev="IPU" type="IPU_IMPROPER_PROPERTIES_USE_SETPROPERTY"
category="CORRECTNESS" experimental="true" />
+ <BugPattern abbrev="PCAIL" type="PCAIL_POSSIBLE_CONSTANT_ALLOCATION_IN_LOOP"
+ category="PERFORMANCE" experimental="true" />
</FindbugsPlugin>
\ No newline at end of file
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2010-03-15 05:46:12 UTC (rev 1524)
+++ trunk/fb-contrib/etc/messages.xml 2010-04-03 15:24:59 UTC (rev 1525)
@@ -1123,6 +1123,17 @@
]]>
</Details>
</Detector>
+
+ <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleConstantAllocationInLoop">
+ <Details>
+ <![CDATA[
+ <p>This detector looks for allocations of objects using the default constructor in a loop, where
+ the object allocated is never assigned to any object that is used outside the loop.
+ It is possible that this allocation can be done outside the loop to avoid excessive garbage.</p>
+ <p>It is a fast detector</p>
+ ]]>
+ </Details>
+ </Detector>
<!-- BugPattern -->
@@ -2321,6 +2332,18 @@
concern to case, the toUpperCase or toLowerCase calls are pointless and can be removed.
]]>
</Details>
+ </BugPattern>
+
+ <BugPattern type="SPP_NON_ARRAY_PARM">
+ <ShortDescription>method passes a non array object to a parameter that expects an array</ShortDescription>
+ <LongDescription>method {1} passes a non array object to a parameter that expects an array</LongDescription>
+ <Details>
+ <![CDATA[
+ This method expects an array to be passed as one of its parameters, but unfortunately defines
+ the parameter as Object. This invocation of this method does not pass an array and will throw
+ an exception when run.
+ ]]>
+ </Details>
</BugPattern>
<BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE">
@@ -3059,7 +3082,7 @@
</Details>
</BugPattern>
- <BugPattern type="IPU_IMPROPER_PROPERTIES_USE_SETPROPERTY">
+ <BugPattern type="IPU_IMPROPER_PROPERTIES_USE_SETPROPERTY">
<ShortDescription>Method uses Properties.put instead of Properties.setProperty</ShortDescription>
<LongDescription>Method {1} uses Properties.put instead of Properties.setProperty</LongDescription>
<Details>
@@ -3070,6 +3093,18 @@
]]>
</Details>
</BugPattern>
+
+ <BugPattern type="PCAIL_POSSIBLE_CONSTANT_ALLOCATION_IN_LOOP">
+ <ShortDescription>Method allocates an object that is used in a constant way in a loop</ShortDescription>
+ <LongDescription>Method {1} allocates an object that is used in a constant way in a loop</LongDescription>
+ <Details>
+ <![CDATA[
+ <p>This method allocates an object using the default constructor in a loop, and then
+ only uses it in a quasi-static way. It is never assigned to anything that lives outside
+ the loop, and could potentially be allocated once outside the loop.
+ ]]>
+ </Details>
+ </BugPattern>
<!-- BugCode -->
@@ -3165,4 +3200,5 @@
<BugCode abbrev="MDM">More Dumb Methods</BugCode>
<BugCode abbrev="ROOM">Reflection on Object Methods</BugCode>
<BugCode abbrev="IPU">Improper Properties use</BugCode>
+ <BugCode abbrev="PCAIL">Possible Constant Allocation In Loop</BugCode>
</MessageCollection>
Modified: trunk/fb-contrib/samples/SPP_Sample.java
===================================================================
--- trunk/fb-contrib/samples/SPP_Sample.java 2010-03-15 05:46:12 UTC (rev 1524)
+++ trunk/fb-contrib/samples/SPP_Sample.java 2010-04-03 15:24:59 UTC (rev 1525)
@@ -6,6 +6,7 @@
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
@@ -292,4 +293,12 @@
i = (int) r.nextFloat();
}
+
+ public void testSAC(List<String> input)
+ {
+ String[] copy = new String[input.size()];
+ System.arraycopy(input, 0, copy, 0, copy.length);
+
+ System.arraycopy(copy, 0, input, 0, copy.length);
+ }
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2010-03-15 05:46:12 UTC (rev 1524)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2010-04-03 15:24:59 UTC (rev 1525)
@@ -377,9 +377,27 @@
String className = getClassConstantOperand();
String methodName = getNameConstantOperand();
if ("java/lang/System".equals(className)) {
- if ("getProperties".equals(methodName))
- {
+ if ("getProperties".equals(methodName)) {
userValue = "getProperties";
+ } else if ("arraycopy".equals(methodName)) {
+ if (stack.getStackDepth() >= 5) {
+ OpcodeStack.Item item = stack.getStackItem(2);
+ String sig = item.getSignature();
+ if ((sig.charAt(0) != '[') && !"Ljava/lang/Object;".equals(sig)) {
+ bugReporter.reportBug(new BugInstance(this, "SPP_NON_ARRAY_PARM", HIGH_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this));
+ }
+ item = stack.getStackItem(4);
+ sig = item.getSignature();
+ if ((sig.charAt(0) != '[') && !"Ljava/lang/Object;".equals(sig)) {
+ bugReporter.reportBug(new BugInstance(this, "SPP_NON_ARRAY_PARM", HIGH_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this));
+ }
+ }
}
}
} else if (seen == INVOKEVIRTUAL) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-03-15 05:46:20
|
Revision: 1524
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1524&view=rev
Author: dbrosius
Date: 2010-03-15 05:46:12 +0000 (Mon, 15 Mar 2010)
Log Message:
-----------
add 'fp'
Modified Paths:
--------------
trunk/fb-contrib/samples/USBR_Sample.java
Modified: trunk/fb-contrib/samples/USBR_Sample.java
===================================================================
--- trunk/fb-contrib/samples/USBR_Sample.java 2010-03-13 21:42:57 UTC (rev 1523)
+++ trunk/fb-contrib/samples/USBR_Sample.java 2010-03-15 05:46:12 UTC (rev 1524)
@@ -42,4 +42,12 @@
return e;
}
}
+
+ public int fpPlusEquals()
+ {
+ int i = 0;
+ i += 4;
+ i+= dontReport(i);
+ return i;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-03-13 21:43:03
|
Revision: 1523
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1523&view=rev
Author: dbrosius
Date: 2010-03-13 21:42:57 +0000 (Sat, 13 Mar 2010)
Log Message:
-----------
don't report currentTimeMillis
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2010-03-13 21:21:09 UTC (rev 1522)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2010-03-13 21:42:57 UTC (rev 1523)
@@ -74,6 +74,7 @@
riskyMethodNameContents.add("clone");
riskyMethodNameContents.add("close");
riskyMethodNameContents.add("copy");
+ riskyMethodNameContents.add("currentTimeMillis");
String userNameProp = System.getProperty(PRMC_RISKY_FIELD_USER_KEY);
if (userNameProp != null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-03-13 21:21:16
|
Revision: 1522
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1522&view=rev
Author: dbrosius
Date: 2010-03-13 21:21:09 +0000 (Sat, 13 Mar 2010)
Log Message:
-----------
clear the staticMethodCalls collection on new method
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2010-03-13 21:15:44 UTC (rev 1521)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2010-03-13 21:21:09 UTC (rev 1522)
@@ -155,6 +155,7 @@
stack.resetForMethodEntry(this);
localMethodCalls.clear();
fieldMethodCalls.clear();
+ staticMethodCalls.clear();
branchTargets.clear();
CodeException[] codeExceptions = obj.getExceptionTable();
for (CodeException codeEx : codeExceptions) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-03-13 21:15:51
|
Revision: 1521
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1521&view=rev
Author: dbrosius
Date: 2010-03-13 21:15:44 +0000 (Sat, 13 Mar 2010)
Log Message:
-----------
clean up some fps with MAC
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java 2010-03-13 20:52:37 UTC (rev 1520)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java 2010-03-13 21:15:44 UTC (rev 1521)
@@ -33,7 +33,7 @@
*/
public class ManualArrayCopy extends BytecodeScanningDetector
{
- enum State {SAW_NOTHING, SAW_ARRAY1_LOAD, SAW_ARRAY1_INDEX, SAW_ARRAY2_LOAD, SAW_ARRAY2_INDEX, SAW_ELEM_LOAD}
+ enum State {SAW_NOTHING, SAW_ICMP, SAW_ARRAY1_LOAD, SAW_ARRAY1_INDEX, SAW_ARRAY2_LOAD, SAW_ARRAY2_INDEX, SAW_ELEM_LOAD, SAW_ELEM_STORE}
private static final BitSet arrayLoadOps = new BitSet();
static {
arrayLoadOps.set(AALOAD);
@@ -85,7 +85,12 @@
@Override
public void sawOpcode(int seen) {
switch (state) {
- case SAW_NOTHING:
+ case SAW_NOTHING:
+ if ((seen == IF_ICMPGE) || (seen == IF_ICMPGT))
+ state = State.SAW_ICMP;
+ break;
+
+ case SAW_ICMP:
if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3)))
state = State.SAW_ARRAY1_LOAD;
break;
@@ -149,12 +154,22 @@
|| (seen == DASTORE)
|| (seen == FASTORE)) {
if (similarArrayInstructions(loadInstruction, seen)) {
- bugReporter.reportBug( new BugInstance( this, "MAC_MANUAL_ARRAY_COPY", NORMAL_PRIORITY)
- .addClass(this)
- .addMethod(this)
- .addSourceLine(this));
+ state = State.SAW_ELEM_STORE;
+ } else {
+ state = State.SAW_NOTHING;
}
+ } else {
+ state = State.SAW_NOTHING;
}
+ break;
+
+ case SAW_ELEM_STORE:
+ if (seen == IINC) {
+ bugReporter.reportBug( new BugInstance( this, "MAC_MANUAL_ARRAY_COPY", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this));
+ }
state = State.SAW_NOTHING;
break;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-03-13 20:52:44
|
Revision: 1520
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1520&view=rev
Author: dbrosius
Date: 2010-03-13 20:52:37 +0000 (Sat, 13 Mar 2010)
Log Message:
-----------
add static methods to PRMC
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2010-03-13 20:14:27 UTC (rev 1519)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2010-03-13 20:52:37 UTC (rev 1520)
@@ -111,6 +111,7 @@
private OpcodeStack stack = null;
private Map<Integer, MethodCall> localMethodCalls = null;
private Map<String, MethodCall> fieldMethodCalls = null;
+ private Map<String, MethodCall> staticMethodCalls = null;
private Set<Integer> branchTargets = null;
/**
@@ -132,12 +133,14 @@
stack = new OpcodeStack();
localMethodCalls = new HashMap<Integer, MethodCall>();
fieldMethodCalls = new HashMap<String, MethodCall>();
+ staticMethodCalls = new HashMap<String, MethodCall>();
branchTargets = new HashSet<Integer>();
super.visitClassContext(classContext);
} finally {
stack = null;
localMethodCalls = null;
fieldMethodCalls = null;
+ staticMethodCalls = null;
branchTargets = null;
}
}
@@ -187,12 +190,13 @@
localMethodCalls.remove(Integer.valueOf(RegisterUtils.getAStoreReg(this, seen)));
} else if (seen == PUTFIELD) {
fieldMethodCalls.remove(getNameConstantOperand());
- } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE)) {
+ } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE) || (seen == INVOKESTATIC)) {
String className = getClassConstantOperand();
String methodName = getNameConstantOperand();
String signature = getSigConstantOperand();
int parmCount = Type.getArgumentTypes(signature).length;
- if (stack.getStackDepth() > parmCount) {
+ int neededStackSize = parmCount - ((seen == INVOKESTATIC) ? 1 : 0);
+ if (stack.getStackDepth() > neededStackSize) {
Object[] parmConstants = new Object[parmCount];
for (int i = 0; i < parmCount; i++) {
OpcodeStack.Item parm = stack.getStackItem(i);
@@ -200,18 +204,28 @@
if (parmConstants[i] == null)
return;
}
- OpcodeStack.Item obj = stack.getStackItem(parmCount);
- int reg = obj.getRegisterNumber();
- XField field = obj.getXField();
+
MethodCall mc;
- if (reg >= 0) {
- mc = localMethodCalls.get(Integer.valueOf(reg));
- } else if (field != null) {
- mc = fieldMethodCalls.get(field.getName());
- } else
- return;
+ int reg = -1;
+ XField field = null;
+ if (seen == INVOKESTATIC) {
+ mc = staticMethodCalls.get(className);
+ } else {
+ OpcodeStack.Item obj = stack.getStackItem(parmCount);
+ reg = obj.getRegisterNumber();
+ field = obj.getXField();
+
+
+ if (reg >= 0) {
+ mc = localMethodCalls.get(Integer.valueOf(reg));
+ } else if (field != null) {
+ mc = fieldMethodCalls.get(field.getName());
+ } else
+ return;
+ }
+
if (mc != null) {
if (!signature.endsWith("V") && methodName.equals(mc.getName()) && signature.equals(mc.getSignature()) && !isRiskyName(className, methodName)) {
Object[] parms = mc.getParms();
@@ -233,16 +247,25 @@
.addString(methodName + signature));
}
}
- if (reg >= 0) {
- localMethodCalls.remove(Integer.valueOf(reg));
+
+ if (seen == INVOKESTATIC) {
+ staticMethodCalls.remove(className);
} else {
- fieldMethodCalls.remove(field.getName());
+ if (reg >= 0) {
+ localMethodCalls.remove(Integer.valueOf(reg));
+ } else {
+ fieldMethodCalls.remove(field.getName());
+ }
}
} else {
- if (reg >= 0) {
- localMethodCalls.put(Integer.valueOf(reg), new MethodCall(methodName, signature, parmConstants));
- } else if (field != null) {
- fieldMethodCalls.put(field.getName(), new MethodCall(methodName, signature, parmConstants));
+ if (seen == INVOKESTATIC) {
+ staticMethodCalls.put(className, new MethodCall(methodName, signature, parmConstants));
+ } else {
+ if (reg >= 0) {
+ localMethodCalls.put(Integer.valueOf(reg), new MethodCall(methodName, signature, parmConstants));
+ } else if (field != null) {
+ fieldMethodCalls.put(field.getName(), new MethodCall(methodName, signature, parmConstants));
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-03-13 20:14:34
|
Revision: 1519
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1519&view=rev
Author: dbrosius
Date: 2010-03-13 20:14:27 +0000 (Sat, 13 Mar 2010)
Log Message:
-----------
rename and add case
Added Paths:
-----------
trunk/fb-contrib/samples/PRMC_Sample.java
Copied: trunk/fb-contrib/samples/PRMC_Sample.java (from rev 1380, trunk/fb-contrib/samples/RMC_Sample.java)
===================================================================
--- trunk/fb-contrib/samples/PRMC_Sample.java (rev 0)
+++ trunk/fb-contrib/samples/PRMC_Sample.java 2010-03-13 20:14:27 UTC (rev 1519)
@@ -0,0 +1,72 @@
+import java.nio.ByteBuffer;
+import java.util.Calendar;
+import java.util.Date;
+
+@SuppressWarnings("all")
+public class PRMC_Sample
+{
+ String data;
+
+ public boolean test1(Calendar c)
+ {
+ Date d = c.getTime();
+ long l = d.getTime();
+ Date e = c.getTime();
+ long j = e.getTime();
+ return l == j;
+ }
+
+ public void rmcFP(ByteBuffer bb)
+ {
+ int i = bb.getInt();
+ int j = bb.getInt();
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ PRMC_Sample rmc = (PRMC_Sample)o;
+ if (data.equals("INF") || rmc.data.equals("INF"))
+ return false;
+
+ return data.equals(rmc.data);
+ }
+
+ public void staticRMC()
+ {
+ Factory.getInstance().fee();
+ Factory.getInstance().fi();
+ Factory.getInstance().fo();
+ Factory.getInstance().fum();
+ }
+
+ static class Factory
+ {
+ private static Factory f = new Factory();
+
+ private Factory()
+ {
+ }
+
+ public static Factory getInstance()
+ {
+ return f;
+ }
+
+ public void fee()
+ {
+ }
+
+ public void fi()
+ {
+ }
+
+ public void fo()
+ {
+ }
+
+ public void fum()
+ {
+ }
+ }
+}
Property changes on: trunk/fb-contrib/samples/PRMC_Sample.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...> - 2010-03-08 14:57:19
|
Revision: 1518
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1518&view=rev
Author: dbrosius
Date: 2010-03-08 14:57:12 +0000 (Mon, 08 Mar 2010)
Log Message:
-----------
add new test case
Modified Paths:
--------------
trunk/fb-contrib/samples/ISB_Sample.java
Modified: trunk/fb-contrib/samples/ISB_Sample.java
===================================================================
--- trunk/fb-contrib/samples/ISB_Sample.java 2010-02-16 22:28:56 UTC (rev 1517)
+++ trunk/fb-contrib/samples/ISB_Sample.java 2010-03-08 14:57:12 UTC (rev 1518)
@@ -52,8 +52,16 @@
return sb.toString();
}
- public String testFPISB8(int x)
+ public String testISB8()
{
+ String foo = "foo";
+ foo += " bar";
+
+ return foo;
+ }
+
+ public String testFPISB9(int x)
+ {
StringBuffer sb = new StringBuffer();
sb.append(x);
sb.append("hello");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-02-16 22:29:04
|
Revision: 1517
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1517&view=rev
Author: dbrosius
Date: 2010-02-16 22:28:56 +0000 (Tue, 16 Feb 2010)
Log Message:
-----------
typo found by Jean-Noel Rouvignac
Modified Paths:
--------------
trunk/fb-contrib/etc/findbugs.xml
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2010-02-12 19:08:42 UTC (rev 1516)
+++ trunk/fb-contrib/etc/findbugs.xml 2010-02-16 22:28:56 UTC (rev 1517)
@@ -318,7 +318,7 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.MoreDumbMethods"
speed="fast"
- reports="MDM_RUNTIME_EXIT_OR_HALT,MDM_RUNFINALIZATION,EQ_BIGDECIMAL_EQUALS,MDM_INETADDRESS_GETLOCALHOST,MDM_PROMISCUOUS_SERVERSOCKET,MDM_RANDOM_SEED,MDM_SECURERANDOM_CTOR,MDM_SECURERANDOM_GETSEED,MDM_THREAD_PRIORITIES,MDM_THREAD_YIELD,MDM_WAIT_WITHOUT_TIMEOUT,MDM_THREAD_FAIRNESS,MDM_REENTRANTLOCK_HELDBY,MDM_STRING_BYTES_ENCODING,MDM_SETDEFAULTLOCALE" />
+ reports="MDM_RUNTIME_EXIT_OR_HALT,MDM_RUNFINALIZATION,MDM_BIGDECIMAL_EQUALS,MDM_INETADDRESS_GETLOCALHOST,MDM_PROMISCUOUS_SERVERSOCKET,MDM_RANDOM_SEED,MDM_SECURERANDOM_CTOR,MDM_SECURERANDOM_GETSEED,MDM_THREAD_PRIORITIES,MDM_THREAD_YIELD,MDM_WAIT_WITHOUT_TIMEOUT,MDM_THREAD_FAIRNESS,MDM_REENTRANTLOCK_HELDBY,MDM_STRING_BYTES_ENCODING,MDM_SETDEFAULTLOCALE" />
<Detector class="com.mebigfatguy.fbcontrib.detect.ReflectionOnObjectMethods"
speed="fast"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-02-12 19:08:50
|
Revision: 1516
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1516&view=rev
Author: dbrosius
Date: 2010-02-12 19:08:42 +0000 (Fri, 12 Feb 2010)
Log Message:
-----------
add fp
Modified Paths:
--------------
trunk/fb-contrib/samples/BAS_Sample.java
Modified: trunk/fb-contrib/samples/BAS_Sample.java
===================================================================
--- trunk/fb-contrib/samples/BAS_Sample.java 2010-02-12 19:06:45 UTC (rev 1515)
+++ trunk/fb-contrib/samples/BAS_Sample.java 2010-02-12 19:08:42 UTC (rev 1516)
@@ -127,5 +127,16 @@
return 0;
}
+
+ public void testFPSrcOverwrite(int src, boolean b)
+ {
+ int d = src;
+ src = 0;
+
+ if (b)
+ {
+ System.out.println(d);
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|