fb-contrib-commit Mailing List for fb-contrib (Page 28)
Brought to you by:
dbrosius
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(56) |
Oct
(60) |
Nov
(58) |
Dec
(89) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(66) |
Feb
(55) |
Mar
(85) |
Apr
(115) |
May
(35) |
Jun
(28) |
Jul
(3) |
Aug
(48) |
Sep
(37) |
Oct
(22) |
Nov
(14) |
Dec
(66) |
2007 |
Jan
(45) |
Feb
(63) |
Mar
(10) |
Apr
(1) |
May
(1) |
Jun
(12) |
Jul
|
Aug
|
Sep
(25) |
Oct
(21) |
Nov
(39) |
Dec
|
2008 |
Jan
(7) |
Feb
|
Mar
(26) |
Apr
(5) |
May
(2) |
Jun
(32) |
Jul
(9) |
Aug
(10) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
|
2009 |
Jan
(10) |
Feb
(31) |
Mar
(32) |
Apr
(35) |
May
(25) |
Jun
|
Jul
(31) |
Aug
(10) |
Sep
(95) |
Oct
(35) |
Nov
(10) |
Dec
(34) |
2010 |
Jan
(90) |
Feb
(4) |
Mar
(7) |
Apr
(20) |
May
(20) |
Jun
(13) |
Jul
(7) |
Aug
(18) |
Sep
(25) |
Oct
(4) |
Nov
(16) |
Dec
(2) |
2011 |
Jan
(1) |
Feb
|
Mar
(11) |
Apr
(3) |
May
(2) |
Jun
(26) |
Jul
(10) |
Aug
(2) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
2012 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(14) |
Nov
(3) |
Dec
(4) |
2013 |
Jan
(3) |
Feb
(2) |
Mar
(1) |
Apr
(4) |
May
|
Jun
(1) |
Jul
(3) |
Aug
|
Sep
|
Oct
(4) |
Nov
(3) |
Dec
(3) |
2014 |
Jan
(4) |
Feb
(2) |
Mar
(4) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(3) |
Dec
(3) |
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
(2) |
Nov
(7) |
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
(5) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(3) |
2018 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(5) |
Jun
(2) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dbr...@us...> - 2009-04-17 08:45:32
|
Revision: 1166 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1166&view=rev Author: dbrosius Date: 2009-04-17 08:45:31 +0000 (Fri, 17 Apr 2009) Log Message: ----------- on second thought, don't clear runtimeExceptions. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java 2009-04-17 08:43:18 UTC (rev 1165) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java 2009-04-17 08:45:31 UTC (rev 1166) @@ -48,6 +48,7 @@ static { try { runtimeExceptionClass = Repository.lookupClass("java.lang.RuntimeException"); + runtimeExceptions.add("java.lang.RuntimeException"); } catch (ClassNotFoundException cnfe) { runtimeExceptionClass = null; } @@ -79,7 +80,6 @@ @Override public void visitMethod(final Method obj) { ExceptionTable et = obj.getExceptionTable(); - runtimeExceptions.clear(); if (et != null) { String[] exNames = et.getExceptionNames(); Set<String> methodRTExceptions = new HashSet<String>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-17 08:43:22
|
Revision: 1165 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1165&view=rev Author: dbrosius Date: 2009-04-17 08:43:18 +0000 (Fri, 17 Apr 2009) Log Message: ----------- no need to guard against multiple invocations of reportMissingClass Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java 2009-04-17 08:39:48 UTC (rev 1164) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java 2009-04-17 08:43:18 UTC (rev 1165) @@ -43,7 +43,6 @@ { private final BugReporter bugReporter; private static final Set<String> runtimeExceptions = new HashSet<String>(); - private static final Set<String> notFoundExceptions = new HashSet<String>(); private static JavaClass runtimeExceptionClass; static { @@ -100,10 +99,7 @@ isRuntime = true; } } catch (ClassNotFoundException cnfe) { - if (!notFoundExceptions.contains(ex)) { bugReporter.reportMissingClass(cnfe); - notFoundExceptions.add(ex); - } } } if (isRuntime) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-17 08:39:55
|
Revision: 1164 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1164&view=rev Author: dbrosius Date: 2009-04-17 08:39:48 +0000 (Fri, 17 Apr 2009) Log Message: ----------- clear the runtimeExceptions set on entry to visitMethod Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java 2009-04-17 08:35:16 UTC (rev 1163) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java 2009-04-17 08:39:48 UTC (rev 1164) @@ -41,7 +41,7 @@ */ public class DeclaredRuntimeException extends PreorderVisitor implements Detector { - private BugReporter bugReporter; + private final BugReporter bugReporter; private static final Set<String> runtimeExceptions = new HashSet<String>(); private static final Set<String> notFoundExceptions = new HashSet<String>(); private static JavaClass runtimeExceptionClass; @@ -80,6 +80,7 @@ @Override public void visitMethod(final Method obj) { ExceptionTable et = obj.getExceptionTable(); + runtimeExceptions.clear(); if (et != null) { String[] exNames = et.getExceptionNames(); Set<String> methodRTExceptions = new HashSet<String>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-17 08:35:17
|
Revision: 1163 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1163&view=rev Author: dbrosius Date: 2009-04-17 08:35:16 +0000 (Fri, 17 Apr 2009) Log Message: ----------- oops, fix bad comparison Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2009-04-17 08:25:37 UTC (rev 1162) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2009-04-17 08:35:16 UTC (rev 1163) @@ -372,7 +372,7 @@ */ private Object getCallingObject() { String sig = getSigConstantOperand(); - if ("V".equals(Type.getReturnType(sig))) + if ("V".equals(Type.getReturnType(sig).getSignature())) { return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-17 08:25:41
|
Revision: 1162 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1162&view=rev Author: dbrosius Date: 2009-04-17 08:25:37 +0000 (Fri, 17 Apr 2009) Log Message: ----------- no auto-boxing Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2009-04-13 01:04:37 UTC (rev 1161) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2009-04-17 08:25:37 UTC (rev 1162) @@ -586,7 +586,7 @@ { assocs = new HashMap<Object, Integer>(); } - assocs.put(assocObject, reg); + assocs.put(assocObject, Integer14.valueOf(reg)); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-13 01:04:43
|
Revision: 1161 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1161&view=rev Author: dbrosius Date: 2009-04-13 01:04:37 +0000 (Mon, 13 Apr 2009) Log Message: ----------- Bug fix for 2737685 Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java 2009-04-13 01:04:06 UTC (rev 1160) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java 2009-04-13 01:04:37 UTC (rev 1161) @@ -47,7 +47,7 @@ private static final int SEEN_NOTHING = 0; private static final int SEEN_LDC = 1; - private BugReporter bugReporter; + private final BugReporter bugReporter; private Set<String> refClasses; private int state; private String clsName; @@ -87,6 +87,9 @@ */ @Override public void visitMethod(Method obj) { + if ("<clinit>".equals(obj.getName())) + return; + if (state == COLLECT) { Type[] argTypes = obj.getArgumentTypes(); for (Type t : argTypes) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-13 01:04:11
|
Revision: 1160 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1160&view=rev Author: dbrosius Date: 2009-04-13 01:04:06 +0000 (Mon, 13 Apr 2009) Log Message: ----------- sample bug as per bug report 2737685 Modified Paths: -------------- trunk/fb-contrib/samples/SCR_Sample.java Modified: trunk/fb-contrib/samples/SCR_Sample.java =================================================================== --- trunk/fb-contrib/samples/SCR_Sample.java 2009-04-11 16:51:55 UTC (rev 1159) +++ trunk/fb-contrib/samples/SCR_Sample.java 2009-04-13 01:04:06 UTC (rev 1160) @@ -5,6 +5,7 @@ public class SCR_Sample { A a; + String name = SCR_Sample.class.getName(); public String testForNameOfThis() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-11 16:52:00
|
Revision: 1159 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1159&view=rev Author: dbrosius Date: 2009-04-11 16:51:55 +0000 (Sat, 11 Apr 2009) Log Message: ----------- flip the comparison Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java 2009-04-11 16:47:42 UTC (rev 1158) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java 2009-04-11 16:51:55 UTC (rev 1159) @@ -52,7 +52,7 @@ for (LineNumber lineNumber : lineNumbers) { int linePC = lineNumber.getStartPC(); - if (linePC <= pc) + if (linePC >= pc) { return linePC == pc; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-11 16:47:47
|
Revision: 1158 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1158&view=rev Author: dbrosius Date: 2009-04-11 16:47:42 +0000 (Sat, 11 Apr 2009) Log Message: ----------- a collection of static methods for doing code attribute queries Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java 2009-04-11 16:47:42 UTC (rev 1158) @@ -0,0 +1,63 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2009 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.utils; + +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.LineNumber; +import org.apache.bcel.classfile.LineNumberTable; + +/** + * a collection of static methods for working with code attribute queries + */ +public class AttributesUtils +{ + private AttributesUtils() { + } + + /** + * returns whether the pc is at a user defined line or whether it's in a compiler + * generated section of code based on the line number table. If the Line number table + * doesn't exist, then assume it's ok. + * + * @param obj the code object to find line number attributes from + * @param pc the pc to check + * + * @return whether the pc is in user code + */ + public static boolean isValidLineNumber(Code obj, int pc) + { + LineNumberTable lnt = obj.getLineNumberTable(); + if (lnt == null) + return true; + + LineNumber[] lineNumbers = lnt.getLineNumberTable(); + if (lineNumbers == null) + return true; + + for (LineNumber lineNumber : lineNumbers) { + int linePC = lineNumber.getStartPC(); + if (linePC <= pc) + { + return linePC == pc; + } + } + + return false; + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-11 15:02:01
|
Revision: 1157 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1157&view=rev Author: dbrosius Date: 2009-04-11 15:01:51 +0000 (Sat, 11 Apr 2009) Log Message: ----------- clear allocationRegs on transition points before processing opcode Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-04-11 14:24:32 UTC (rev 1156) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-04-11 15:01:51 UTC (rev 1157) @@ -68,6 +68,9 @@ public void sawOpcode(int seen) { boolean sawAlloc = false; try { + if (transitionPoints.contains(Integer14.valueOf(getPC()))) + allocationRegs.clear(); + switch (seen) { case NEW: case ANEWARRAY: @@ -149,10 +152,6 @@ allocationRegs.clear(); break; } - - if (transitionPoints.contains(Integer14.valueOf(getPC()))) - allocationRegs.clear(); - } finally { stack.sawOpcode(this, seen); if (sawAlloc) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-11 14:24:34
|
Revision: 1156 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1156&view=rev Author: dbrosius Date: 2009-04-11 14:24:32 +0000 (Sat, 11 Apr 2009) Log Message: ----------- add more opcodes that clear allocation regs Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-04-11 14:21:42 UTC (rev 1155) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-04-11 14:24:32 UTC (rev 1156) @@ -135,6 +135,8 @@ allocationRegs.clear(); break; + case TABLESWITCH: + case LOOKUPSWITCH: case IRETURN: case LRETURN: case FRETURN: @@ -143,6 +145,7 @@ case RETURN: case GOTO: case GOTO_W: + case ATHROW: allocationRegs.clear(); break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-11 14:21:44
|
Revision: 1155 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1155&view=rev Author: dbrosius Date: 2009-04-11 14:21:42 +0000 (Sat, 11 Apr 2009) Log Message: ----------- clear regs on IFNONNULL and IFNULL as well Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-04-11 14:04:37 UTC (rev 1154) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-04-11 14:21:42 UTC (rev 1155) @@ -113,6 +113,8 @@ .addSourceLine(this)); } } + transitionPoints.add(Integer14.valueOf(getBranchTarget())); + allocationRegs.clear(); break; case IFEQ: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-11 14:04:46
|
Revision: 1154 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1154&view=rev Author: dbrosius Date: 2009-04-11 14:04:37 +0000 (Sat, 11 Apr 2009) Log Message: ----------- clear allocationRegs at key points Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-04-11 02:50:18 UTC (rev 1153) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-04-11 14:04:37 UTC (rev 1154) @@ -27,7 +27,7 @@ private final BugReporter bugReporter; private OpcodeStack stack; private Set<Integer> allocationRegs; - private Set<Integer> handlerStarts; + private Set<Integer> transitionPoints; public UnnecessaryNewNullCheck(BugReporter bugReporter) { this.bugReporter = bugReporter; @@ -38,12 +38,12 @@ try { stack = new OpcodeStack(); allocationRegs = new HashSet<Integer>(); - handlerStarts = new HashSet<Integer>(); + transitionPoints = new HashSet<Integer>(); super.visitClassContext(classContext); } finally { stack = null; allocationRegs = null; - handlerStarts = null; + transitionPoints = null; } } @@ -52,12 +52,12 @@ if (prescreen()) { stack.resetForMethodEntry(this); allocationRegs.clear(); - handlerStarts.clear(); + transitionPoints.clear(); CodeException[] ce = obj.getExceptionTable(); if (ce != null) { for (CodeException element : ce) { - handlerStarts.add(Integer14.valueOf(element.getHandlerPC())); + transitionPoints.add(Integer14.valueOf(element.getHandlerPC())); } } super.visitCode(obj); @@ -114,9 +114,38 @@ } } break; + + 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: + transitionPoints.add(Integer14.valueOf(getBranchTarget())); + allocationRegs.clear(); + break; + + case IRETURN: + case LRETURN: + case FRETURN: + case DRETURN: + case ARETURN: + case RETURN: + case GOTO: + case GOTO_W: + allocationRegs.clear(); + break; } - if (handlerStarts.contains(Integer14.valueOf(getPC()))) + if (transitionPoints.contains(Integer14.valueOf(getPC()))) allocationRegs.clear(); } finally { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-11 02:50:20
|
Revision: 1153 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1153&view=rev Author: dbrosius Date: 2009-04-11 02:50:18 +0000 (Sat, 11 Apr 2009) Log Message: ----------- new UNNC detector Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml Added Paths: ----------- trunk/fb-contrib/samples/UNNC_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2009-04-10 15:44:00 UTC (rev 1152) +++ trunk/fb-contrib/etc/findbugs.xml 2009-04-11 02:50:18 UTC (rev 1153) @@ -336,6 +336,10 @@ speed="moderate" reports="BED_BOGUS_EXCEPTION_DECLARATION" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryNewNullCheck" + speed="fast" + reports="UNNC_UNNECESSARY_NEW_NULL_CHECK" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -452,4 +456,5 @@ <BugPattern abbrev="IICU" type="IICU_INCORRECT_INTERNAL_CLASS_USE" category="CORRECTNESS" /> <BugPattern abbrev="DSOC" type="DSOC_DUBIOUS_SET_OF_COLLECTIONS" category="PERFORMANCE" /> <BugPattern abbrev="BED" type="BED_BOGUS_EXCEPTION_DECLARATION" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="UNNC" type="UNNC_UNNECESSARY_NEW_NULL_CHECK" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2009-04-10 15:44:00 UTC (rev 1152) +++ trunk/fb-contrib/etc/messages.xml 2009-04-11 02:50:18 UTC (rev 1153) @@ -935,6 +935,18 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryNewNullCheck"> + <Details> + <![CDATA[ + <p>looks for allocations of objects, and then immediately checking to see if the + object is null, or non null. As the new operator is guaranteed to eiher succeed, or throw + an exception, this null check is useless, and denotes a misunderstanding as to how + the jvm works. You can remove this guard.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -2444,6 +2456,18 @@ </Details> </BugPattern> + <BugPattern type="UNNC_UNNECESSARY_NEW_NULL_CHECK"> + <ShortDescription>method checks the result of a new allocation</ShortDescription> + <LongDescription>method {1} checks the result of a new allocation</LongDescription> + <Details> + <![CDATA[ + <p>This method allocations an object with new, and then checks that the object is null + or non null. As the new operator is guaranteed to either succeed or throw an exception, + this null check is unnecessary and can be removed. + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -2522,4 +2546,5 @@ <BugCode abbrev="IICU">Incorrect Internal Class use</BugCode> <BugCode abbrev="DSOC">Dubious Set of Collections</BugCode> <BugCode abbrev="BED">Bogus Exception Declaration</BugCode> + <BugCode abbrev="UNNC">Unnecessary New Null Check</BugCode> </MessageCollection> \ No newline at end of file Added: trunk/fb-contrib/samples/UNNC_Sample.java =================================================================== --- trunk/fb-contrib/samples/UNNC_Sample.java (rev 0) +++ trunk/fb-contrib/samples/UNNC_Sample.java 2009-04-11 02:50:18 UTC (rev 1153) @@ -0,0 +1,55 @@ + + +public class UNNC_Sample { + public void testPosNEW() + { + UNNC_Sample sample = new UNNC_Sample(); + + if (sample != null) + System.out.println("OK"); + } + + public void testNegNEW() + { + UNNC_Sample sample = new UNNC_Sample(); + + if (sample == null) + return; + + System.out.println("OK"); + } + + public void testPosANEWARAY() + { + String[] s = new String[10]; + if (s != null) + System.out.println("OK"); + } + + public void testNegANEWARRAY() + { + String[] s = new String[10]; + if (s == null) + return; + + System.out.println("OK"); + } + + public void testPosMULTIANEWARRAY() + { + String[][] s = new String[10][5]; + if (s != null) + System.out.println("OK"); + } + + public void testNegMULTIANEWARRAY() + { + String[][] s = new String[10][5]; + if (s == null) + return; + + System.out.println("OK"); + } + + +} Property changes on: trunk/fb-contrib/samples/UNNC_Sample.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-04-11 02:50:18 UTC (rev 1153) @@ -0,0 +1,140 @@ +package com.mebigfatguy.fbcontrib.detect; + +import java.util.BitSet; +import java.util.HashSet; +import java.util.Set; + +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.CodeException; + +import com.mebigfatguy.fbcontrib.utils.Integer14; +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; + +/** looks for construction of new objects, and then the immediate testing + * whether the object is null or not. As the new operator will always succeed, + * or through an exception, this test is unnecessary and represents a misunderstanding + * as to how the jvm works. + */ +public class UnnecessaryNewNullCheck extends BytecodeScanningDetector +{ + private final BugReporter bugReporter; + private OpcodeStack stack; + private Set<Integer> allocationRegs; + private Set<Integer> handlerStarts; + + public UnnecessaryNewNullCheck(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + @Override + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + allocationRegs = new HashSet<Integer>(); + handlerStarts = new HashSet<Integer>(); + super.visitClassContext(classContext); + } finally { + stack = null; + allocationRegs = null; + handlerStarts = null; + } + } + + @Override + public void visitCode(Code obj) { + if (prescreen()) { + stack.resetForMethodEntry(this); + allocationRegs.clear(); + handlerStarts.clear(); + + CodeException[] ce = obj.getExceptionTable(); + if (ce != null) { + for (CodeException element : ce) { + handlerStarts.add(Integer14.valueOf(element.getHandlerPC())); + } + } + super.visitCode(obj); + } + } + + @Override + public void sawOpcode(int seen) { + boolean sawAlloc = false; + try { + switch (seen) { + case NEW: + case ANEWARRAY: + case MULTIANEWARRAY: + sawAlloc = true; + 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); + int reg = RegisterUtils.getAStoreReg(this, seen); + if (item.getUserValue() != null) { + allocationRegs.add(Integer14.valueOf(reg)); + } else { + allocationRegs.remove(Integer14.valueOf(reg)); + } + } + break; + + case ALOAD: + case ALOAD_0: + case ALOAD_1: + case ALOAD_2: + case ALOAD_3: + int reg = RegisterUtils.getALoadReg(this, seen); + if (allocationRegs.contains(Integer14.valueOf(reg))) { + sawAlloc = true; + } + break; + + case IFNONNULL: + case IFNULL: + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + if (item.getUserValue() != null) { + bugReporter.reportBug(new BugInstance(this, "UNNC_UNNECESSARY_NEW_NULL_CHECK", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + break; + } + + if (handlerStarts.contains(Integer14.valueOf(getPC()))) + allocationRegs.clear(); + + } finally { + stack.sawOpcode(this, seen); + if (sawAlloc) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(Boolean.TRUE); + } + } + } + } + + private boolean prescreen() { + BitSet bytecodeSet = getClassContext().getBytecodeSet(getMethod()); + return (bytecodeSet != null) && + (bytecodeSet.get(Constants.NEW) + || bytecodeSet.get(Constants.ANEWARRAY) + || bytecodeSet.get(Constants.MULTIANEWARRAY)); + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-10 15:44:07
|
Revision: 1152 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1152&view=rev Author: dbrosius Date: 2009-04-10 15:44:00 +0000 (Fri, 10 Apr 2009) Log Message: ----------- fix FP due to missed differences with LDC, LDC_W instructions Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java 2009-04-07 02:09:47 UTC (rev 1151) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java 2009-04-10 15:44:00 UTC (rev 1152) @@ -22,6 +22,7 @@ import java.util.Map; import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.ConstantClass; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.ConstantPoolGen; @@ -30,7 +31,9 @@ import org.apache.bcel.generic.InstructionHandle; import org.apache.bcel.generic.InstructionList; import org.apache.bcel.generic.InvokeInstruction; +import org.apache.bcel.generic.LDC; import org.apache.bcel.generic.ReferenceType; +import org.apache.bcel.generic.Type; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -114,7 +117,9 @@ public void visitCode(Code obj) { Method m = getMethod(); if (!m.isPublic() && !m.isProtected() && !m.isAbstract()) + { return; + } Code superCode = superclassCode.get(curMethodInfo); if (superCode != null) { @@ -141,16 +146,22 @@ byte[] parentBytes = parent.getCode(); if ((childBytes == null) || (parentBytes == null)) + { return false; + } if (childBytes.length != parentBytes.length) + { return false; + } InstructionHandle[] childihs = new InstructionList(childBytes).getInstructionHandles(); InstructionHandle[] parentihs = new InstructionList(parentBytes).getInstructionHandles(); if (childihs.length != parentihs.length) + { return false; + } for (int i = 0; i < childihs.length; i++) { InstructionHandle childih = childihs[i]; @@ -159,40 +170,79 @@ Instruction parentin = parentih.getInstruction(); if (!childin.getName().equals(parentin.getName())) + { return false; + } if (childin instanceof FieldInstruction) { String childFName = ((FieldInstruction) childin).getFieldName(childPoolGen); String parentFName = ((FieldInstruction) parentin).getFieldName(parentPoolGen); if (!childFName.equals(parentFName)) + { return false; + } String childFSig = ((FieldInstruction) childin).getSignature(childPoolGen); String parentFSig = ((FieldInstruction) parentin).getSignature(parentPoolGen); if (!childFSig.equals(parentFSig)) + { return false; + } if (childFSig.charAt(0) == 'L') { ReferenceType childRefType = ((FieldInstruction) childin).getReferenceType(childPoolGen); ReferenceType parentRefType = ((FieldInstruction) parentin).getReferenceType(parentPoolGen); if (!childRefType.getSignature().equals(parentRefType.getSignature())) + { return false; + } } } else if (childin instanceof InvokeInstruction) { String childClassName = ((InvokeInstruction) childin).getClassName(childPoolGen); String parentClassName = ((InvokeInstruction) parentin).getClassName(parentPoolGen); if (!childClassName.equals(parentClassName)) + { return false; + } String childMethodName = ((InvokeInstruction) childin).getMethodName(childPoolGen); String parentMethodName = ((InvokeInstruction) parentin).getMethodName(parentPoolGen); if (!childMethodName.equals(parentMethodName)) + { return false; + } String childSignature = ((InvokeInstruction) childin).getSignature(childPoolGen); String parentSignature = ((InvokeInstruction) parentin).getSignature(parentPoolGen); if (!childSignature.equals(parentSignature)) + { return false; - } else { + } + } else if (childin instanceof LDC) { + Type childType = ((LDC) childin).getType(childPoolGen); + Type parentType = ((LDC) parentin).getType(parentPoolGen); + if (!childType.equals(parentType)) + { + return false; + } + + Object childValue = ((LDC) childin).getValue(childPoolGen); + Object parentValue = ((LDC) parentin).getValue(parentPoolGen); + + if (childValue instanceof ConstantClass) + { + ConstantClass childClass = (ConstantClass)childValue; + ConstantClass parentClass = (ConstantClass)parentValue; + if (!childClass.getBytes(childPoolGen.getConstantPool()).equals(parentClass.getBytes(parentPoolGen.getConstantPool()))) + { + return false; + } + } + //TODO: Other Constant types + + } + else { if (!childin.equals(parentin)) + { return false; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-07 02:10:01
|
Revision: 1151 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1151&view=rev Author: dbrosius Date: 2009-04-07 02:09:47 +0000 (Tue, 07 Apr 2009) Log Message: ----------- ignore parameters that are stored in arrays Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2009-04-07 02:03:02 UTC (rev 1150) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2009-04-07 02:09:47 UTC (rev 1151) @@ -226,6 +226,19 @@ parm--; if ((parm >= 0) && (parm < parmCount)) usedParameters.add(Integer14.valueOf(reg)); + } else if (seen == AASTORE) { + //Don't check parameters that are stored in + if (stack.getStackDepth() >= 3) { + OpcodeStack.Item itm = stack.getStackItem(0); + int reg = itm.getRegisterNumber(); + int parm = reg; + if (!methodIsStatic) + parm--; + if ((parm >= 0) && (parm < parmCount)) + parameterDefiners.remove(Integer14.valueOf(reg)); + } else { + parameterDefiners.clear(); + } } } finally { stack.sawOpcode(this, seen); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-07 02:03:21
|
Revision: 1150 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1150&view=rev Author: dbrosius Date: 2009-04-07 02:03:02 +0000 (Tue, 07 Apr 2009) Log Message: ----------- add new FP Modified Paths: -------------- trunk/fb-contrib/samples/OCP_Sample.java Modified: trunk/fb-contrib/samples/OCP_Sample.java =================================================================== --- trunk/fb-contrib/samples/OCP_Sample.java 2009-03-18 20:34:57 UTC (rev 1149) +++ trunk/fb-contrib/samples/OCP_Sample.java 2009-04-07 02:03:02 UTC (rev 1150) @@ -1,3 +1,4 @@ +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; @@ -86,6 +87,11 @@ { ll.add("foo"); } + + public void testFPaastore(Color c) + { + Color[] cc = new Color[] { c, c }; + } } class Z This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-18 20:35:36
|
Revision: 1149 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1149&view=rev Author: dbrosius Date: 2009-03-18 20:34:57 +0000 (Wed, 18 Mar 2009) Log Message: ----------- add SPP check for non private serialVersionUID fields 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 2009-03-17 06:36:26 UTC (rev 1148) +++ trunk/fb-contrib/etc/findbugs.xml 2009-03-18 20:34:57 UTC (rev 1149) @@ -426,6 +426,7 @@ <BugPattern abbrev="SPP" type="SPP_USE_CONTAINSKEY" category="STYLE"/> <BugPattern abbrev="SPP" type="SPP_USE_ISEMPTY" category="STYLE"/> <BugPattern abbrev="SPP" type="SPP_USE_GETPROPERTY" category="STYLE"/> + <BugPattern abbrev="SPP" type="SPP_SERIALVER_SHOULD_BE_PRIVATE" category="STYLE"/> <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" /> <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR" category="STYLE" /> <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" /> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2009-03-17 06:36:26 UTC (rev 1148) +++ trunk/fb-contrib/etc/messages.xml 2009-03-18 20:34:57 UTC (rev 1149) @@ -2097,6 +2097,19 @@ </Details> </BugPattern> + <BugPattern type="SPP_SERIALVER_SHOULD_BE_PRIVATE"> + <ShortDescription>Class defines a serialVersionUID as non private</ShortDescription> + <LongDescription>Class {0} defines a serialVersionUID as non private</LongDescription> + <Details> + <![CDATA[ + This class defines a static field 'serialVersionUID' to define the serialization + version for this class. This field is marked as non private. As the serialVersionUID only + controls the current class, and doesn't effect any derived classes, defining it as non + private is confusing. It is suggested you change this variable to be private. + ]]> + </Details> + </BugPattern> + <BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE"> <ShortDescription>Method assigns a variable in a larger scope then is needed</ShortDescription> <LongDescription>Method {1} assigns a variable in a larger scope then is needed</LongDescription> Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2009-03-17 06:36:26 UTC (rev 1148) +++ trunk/fb-contrib/samples/SPP_Sample.java 2009-03-18 20:34:57 UTC (rev 1149) @@ -1,3 +1,4 @@ +import java.io.Serializable; import java.math.BigDecimal; import java.util.BitSet; import java.util.Calendar; @@ -9,9 +10,11 @@ import java.util.Set; import java.util.StringTokenizer; -public class SPP_Sample +public class SPP_Sample implements Serializable { - private static final double pi = 3.14; + public static final long serialVersionUID = -2766574418713802220L; + + private static final double pi = 3.14; private static final double e = 2.72; public static final String FALSE_POSITIVE = "INTERN_OK_HERE".intern(); @@ -47,13 +50,17 @@ public void testNAN(double d) { if (d == Double.NaN) - System.out.println("It's a nan"); + { + System.out.println("It's a nan"); + } } public void testNAN(float f) { if (f == Float.NaN) - System.out.println("It's a nan"); + { + System.out.println("It's a nan"); + } } public void testBigDecimal() @@ -69,21 +76,29 @@ public void equalsOnEnum(Flap f) { if (f.equals(Flap.Jack)) - System.out.println("Flap Jacks"); + { + System.out.println("Flap Jacks"); + } } public void testCPPBoolean(Boolean a, Boolean b, Boolean c, Boolean d, Boolean e) { if (b && b.booleanValue()) - System.out.println("Booya"); + { + System.out.println("Booya"); + } if (e && e.booleanValue()) - System.out.println("Booya"); + { + System.out.println("Booya"); + } } public char usechatAt(String s) { if (s.length() > 0) - return s.toCharArray()[0]; + { + return s.toCharArray()[0]; + } return ' '; } @@ -95,7 +110,9 @@ public boolean testFPUselessTrinary(boolean a, boolean b) { if (a && b) - return a || b; + { + return a || b; + } return a && b; } @@ -111,18 +128,30 @@ String e = "Foo"; if ((s == null) || (s.length() > 0)) - System.out.println("Booya"); + { + System.out.println("Booya"); + } if ((s == null) || (s.length() != 0)) - System.out.println("Booya"); + { + System.out.println("Booya"); + } if ((s != null) && (s.length() == 0)) - System.out.println("Booya"); + { + System.out.println("Booya"); + } if ((e == null) || (e.length() > 0)) + { System.out.println("Booya"); + } if ((e == null) || (e.length() != 0)) + { System.out.println("Booya"); + } if ((e != null) && (e.length() == 0)) + { System.out.println("Booya"); + } } public void testFPSST(String s) @@ -131,22 +160,34 @@ String e = "Foo"; if ((s == null) || (s.length() == 0)) + { System.out.println("Booya"); + } if ((s != null) && (s.length() >= 0)) + { System.out.println("Booya"); + } if ((s != null) && (s.length() != 0)) + { System.out.println("Booya"); + } if ((e == null) || (e.length() == 0)) + { System.out.println("Booya"); + } if ((e != null) && (e.length() >= 0)) + { System.out.println("Booya"); + } if ((e != null) && (e.length() != 0)) + { System.out.println("Booya"); + } Set<String> m = new HashSet<String>(); Iterator<String> it = m.iterator(); @@ -165,9 +206,13 @@ public void sbToString(StringBuffer sb) { if (sb.toString().length() == 0) - System.out.println("Booya"); - else if (sb.toString().equals("")) - System.out.println("Booya"); + { + System.out.println("Booya"); + } + else if (sb.toString().equals("")) + { + System.out.println("Booya"); + } } public String cpNullOrZero(StringTokenizer tokenizer) @@ -195,13 +240,17 @@ public void testUseContainsKey(Map m) { if (m.keySet().contains("Foo")) - System.out.println("Yup"); + { + System.out.println("Yup"); + } } public void testCollectionSizeEqualsZero(Set<String> s) { if (s.size() == 0) - System.out.println("empty"); + { + System.out.println("empty"); + } } public boolean testDerivedGregorianCalendar() Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2009-03-17 06:36:26 UTC (rev 1148) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2009-03-18 20:34:57 UTC (rev 1149) @@ -32,6 +32,7 @@ import org.apache.bcel.classfile.ConstantNameAndType; import org.apache.bcel.classfile.ConstantPool; import org.apache.bcel.classfile.ConstantString; +import org.apache.bcel.classfile.Field; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.LocalVariable; import org.apache.bcel.classfile.LocalVariableTable; @@ -90,6 +91,17 @@ } @Override + public void visitField(Field field) { + if ("serialVersionUID".equals(field.getName()) + && ((field.getAccessFlags() & ACC_STATIC) != 0) + && ((field.getAccessFlags() & ACC_PRIVATE) == 0)) { + bugReporter.reportBug(new BugInstance(this, "SPP_SERIALVER_SHOULD_BE_PRIVATE", LOW_PRIORITY) + .addClass(this) + .addField(this)); + } + } + + @Override public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); @@ -264,10 +276,14 @@ boolean bug = true; Set<Integer> branchInsSet = branchTargets.get(Integer14.valueOf(lastPCs[1])); if (branchInsSet != null) - bug = false; + { + bug = false; + } branchInsSet = branchTargets.get(Integer14.valueOf(lastPCs[3])); if ((branchInsSet != null) && branchInsSet.size() > 1) - bug = false; + { + bug = false; + } if (bug) { bugReporter.reportBug(new BugInstance(this, "SPP_USELESS_TRINARY", NORMAL_PRIORITY) @@ -363,7 +379,9 @@ String methodName = getNameConstantOperand(); if ("java/lang/System".equals(className)) { if ("getProperties".equals(methodName)) - userValue = "getProperties"; + { + userValue = "getProperties"; + } } } else if (seen == INVOKEVIRTUAL) { String className = getClassConstantOperand(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-17 06:36:33
|
Revision: 1148 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1148&view=rev Author: dbrosius Date: 2009-03-17 06:36:26 +0000 (Tue, 17 Mar 2009) Log Message: ----------- track objects on which method calls are made associated with stores, and clear the store regs when that same object has another method call on it. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2009-03-17 05:41:35 UTC (rev 1147) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2009-03-17 06:36:26 UTC (rev 1148) @@ -29,6 +29,7 @@ import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.CodeException; import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.Integer14; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; @@ -36,7 +37,9 @@ 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; +import edu.umd.cs.findbugs.ba.XField; /** * looks for variable assignments at a scope larger than its use. In this case, @@ -46,6 +49,7 @@ public class BloatedAssignmentScope extends BytecodeScanningDetector { BugReporter bugReporter; + private OpcodeStack stack; private Set<Integer> ignoreRegs; private ScopeBlock rootScopeBlock; private Set<Integer> catchHandlers; @@ -76,12 +80,14 @@ catchHandlers = new HashSet<Integer>(); switchTargets = new HashSet<Integer>(); monitorSyncPCs = new ArrayList<Integer>(); + stack = new OpcodeStack(); super.visitClassContext(classContext); } finally { ignoreRegs = null; catchHandlers = null; switchTargets = null; monitorSyncPCs = null; + stack = null; } } @@ -97,7 +103,9 @@ ignoreRegs.clear(); Method method = getMethod(); if (!method.isStatic()) - ignoreRegs.add(Integer14.valueOf(0)); + { + ignoreRegs.add(Integer14.valueOf(0)); + } int[] parmRegs = RegisterUtils.getParameterRegisters(method); for (int parm : parmRegs) { @@ -114,13 +122,16 @@ } switchTargets.clear(); + stack.resetForMethodEntry(this); dontReport = false; sawDup = false; sawNull = false; super.visitCode(obj); if (!dontReport) + { rootScopeBlock.findBugs(new HashSet<Integer>()); + } } finally { rootScopeBlock = null; @@ -135,159 +146,257 @@ */ @Override public void sawOpcode(int seen) { - if ((seen == ASTORE) - || (seen == ISTORE) - || (seen == LSTORE) - || (seen == FSTORE) - || (seen == DSTORE) - || ((seen >= ASTORE_0) && (seen <= ASTORE_3)) - || ((seen >= ISTORE_0) && (seen <= ISTORE_3)) - || ((seen >= LSTORE_0) && (seen <= LSTORE_1)) - || ((seen >= FSTORE_0) && (seen <= FSTORE_1)) - || ((seen >= DSTORE_0) && (seen <= DSTORE_1))) { - int reg = RegisterUtils.getStoreReg(this, seen); - Integer iReg = Integer14.valueOf(reg); - int pc = getPC(); - if (catchHandlers.contains(Integer14.valueOf(pc))) - ignoreRegs.add(iReg); - else if (monitorSyncPCs.size() > 0) - ignoreRegs.add(iReg); - else if (sawNull) - ignoreRegs.add(iReg); - - if (!ignoreRegs.contains(iReg)) { - ScopeBlock sb = findScopeBlock(rootScopeBlock, pc); - if (sb != null) { - sb.addStore(reg, pc); - if (sawDup) - sb.addLoad(reg, pc); + Object caller = null; + try { + if ((seen == ASTORE) + || (seen == ISTORE) + || (seen == LSTORE) + || (seen == FSTORE) + || (seen == DSTORE) + || ((seen >= ASTORE_0) && (seen <= ASTORE_3)) + || ((seen >= ISTORE_0) && (seen <= ISTORE_3)) + || ((seen >= LSTORE_0) && (seen <= LSTORE_1)) + || ((seen >= FSTORE_0) && (seen <= FSTORE_1)) + || ((seen >= DSTORE_0) && (seen <= DSTORE_1))) { + int reg = RegisterUtils.getStoreReg(this, seen); + Integer iReg = Integer14.valueOf(reg); + int pc = getPC(); + if (catchHandlers.contains(Integer14.valueOf(pc))) + { + ignoreRegs.add(iReg); } - else - ignoreRegs.add(iReg); - } - } else if (seen == IINC) { - int reg = getRegisterOperand(); - Integer iReg = Integer14.valueOf(reg); - if (!ignoreRegs.contains(iReg)) { - ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); - if (sb != null) - sb.addLoad(reg, getPC()); - else - ignoreRegs.add(iReg); - } - int pc = getPC(); - if (catchHandlers.contains(Integer14.valueOf(pc))) - ignoreRegs.add(iReg); - else if (monitorSyncPCs.size() > 0) - ignoreRegs.add(iReg); - else if (sawNull) - ignoreRegs.add(iReg); - - if (!ignoreRegs.contains(iReg)) { - ScopeBlock sb = findScopeBlock(rootScopeBlock, pc); - if (sb != null) { - sb.addStore(reg, pc); - if (sawDup) - sb.addLoad(reg, pc); + else if (monitorSyncPCs.size() > 0) + { + ignoreRegs.add(iReg); } - else - ignoreRegs.add(iReg); - } - } else if ((seen == ALOAD) - || (seen == ILOAD) - || (seen == LLOAD) - || (seen == FLOAD) - || (seen == DLOAD) - || ((seen >= ALOAD_0) && (seen <= ALOAD_3)) - || ((seen >= ILOAD_0) && (seen <= ILOAD_3)) - || ((seen >= LLOAD_0) && (seen <= LLOAD_1)) - || ((seen >= FLOAD_0) && (seen <= FLOAD_1)) - || ((seen >= DLOAD_0) && (seen <= DLOAD_1))) { - int reg = RegisterUtils.getLoadReg(this, seen); - if (!ignoreRegs.contains(Integer14.valueOf(reg))) { - ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); - if (sb != null) - sb.addLoad(reg, getPC()); - else - ignoreRegs.add(Integer14.valueOf(reg)); - } - } else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == GOTO_W)) { - int target = getBranchTarget(); - if (target > getPC()) { - if ((seen == GOTO) || (seen == GOTO_W)) { - Integer nextPC = Integer14.valueOf(getNextPC()); - if (!switchTargets.contains(nextPC)) { - ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), getNextPC()); - if (sb == null) { - sb = new ScopeBlock(getPC(), target); - sb.setLoop(); - sb.setGoto(); - rootScopeBlock.addChild(sb); - } else { - sb = new ScopeBlock(getPC(), target); - sb.setGoto(); - rootScopeBlock.addChild(sb); - } - } - } else { - ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target); - if ((sb != null) && (!sb.isLoop) && !sb.hasChildren()) { - if (sb.isGoto()) { - ScopeBlock parent = sb.getParent(); - sb.pushUpLoadStores(); - if (parent != null) - parent.removeChild(sb); - sb = new ScopeBlock(getPC(), target); - rootScopeBlock.addChild(sb); - } else { - sb.pushUpLoadStores(); - sb.setStart(getPC()); - sb.setFinish(target); + else if (sawNull) + { + ignoreRegs.add(iReg); + } + + if (!ignoreRegs.contains(iReg)) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, pc); + if (sb != null) { + Object assoc = null; + if (stack.getStackDepth() > 0) { + assoc = stack.getStackItem(0).getUserValue(); + } + sb.addStore(reg, pc, assoc); + if (sawDup) + { + sb.addLoad(reg, pc); } - } else { - sb = new ScopeBlock(getPC(), target); - rootScopeBlock.addChild(sb); - } + } + else + { + ignoreRegs.add(iReg); + } + } + } else if (seen == IINC) { + int reg = getRegisterOperand(); + Integer iReg = Integer14.valueOf(reg); + if (!ignoreRegs.contains(iReg)) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); + if (sb != null) + { + sb.addLoad(reg, getPC()); + } + else + { + ignoreRegs.add(iReg); + } + } + int pc = getPC(); + if (catchHandlers.contains(Integer14.valueOf(pc))) + { + ignoreRegs.add(iReg); } - } else { - ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); - if (sb != null) - sb.setLoop(); - } - } else if ((seen == TABLESWITCH) || (seen == LOOKUPSWITCH)) { - int pc = getPC(); - int[] offsets = getSwitchOffsets(); - List<Integer> targets = new ArrayList<Integer>(); - for (int offset : offsets) - targets.add(Integer14.valueOf(offset + pc)); - Integer defOffset = Integer14.valueOf(getDefaultSwitchOffset() + pc); - if (!targets.contains(defOffset)) - targets.add(defOffset); - Collections.sort(targets); - - Integer lastTarget = targets.get(0); - for (int i = 1; i < targets.size(); i++) { - Integer nextTarget = targets.get(i); - ScopeBlock sb = new ScopeBlock(lastTarget.intValue(), nextTarget.intValue()); - rootScopeBlock.addChild(sb); - lastTarget = nextTarget; - } - switchTargets.addAll(targets); - } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE)) { - if ("wasNull".equals(getNameConstantOperand()) - && "()Z".equals(getSigConstantOperand())) - dontReport = true; - } else if (seen == MONITORENTER) { - monitorSyncPCs.add(Integer14.valueOf(getPC())); - } else if (seen == MONITOREXIT) { - if (monitorSyncPCs.size() > 0) - monitorSyncPCs.remove(monitorSyncPCs.size() - 1); + else if (monitorSyncPCs.size() > 0) + { + ignoreRegs.add(iReg); + } + else if (sawNull) + { + ignoreRegs.add(iReg); + } + + if (!ignoreRegs.contains(iReg)) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, pc); + if (sb != null) { + sb.addStore(reg, pc, null); + if (sawDup) + { + sb.addLoad(reg, pc); + } + } + else + { + ignoreRegs.add(iReg); + } + } + } else if ((seen == ALOAD) + || (seen == ILOAD) + || (seen == LLOAD) + || (seen == FLOAD) + || (seen == DLOAD) + || ((seen >= ALOAD_0) && (seen <= ALOAD_3)) + || ((seen >= ILOAD_0) && (seen <= ILOAD_3)) + || ((seen >= LLOAD_0) && (seen <= LLOAD_1)) + || ((seen >= FLOAD_0) && (seen <= FLOAD_1)) + || ((seen >= DLOAD_0) && (seen <= DLOAD_1))) { + int reg = RegisterUtils.getLoadReg(this, seen); + if (!ignoreRegs.contains(Integer14.valueOf(reg))) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); + if (sb != null) + { + sb.addLoad(reg, getPC()); + } + else + { + ignoreRegs.add(Integer14.valueOf(reg)); + } + } + } else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == GOTO_W)) { + int target = getBranchTarget(); + if (target > getPC()) { + if ((seen == GOTO) || (seen == GOTO_W)) { + Integer nextPC = Integer14.valueOf(getNextPC()); + if (!switchTargets.contains(nextPC)) { + ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), getNextPC()); + if (sb == null) { + sb = new ScopeBlock(getPC(), target); + sb.setLoop(); + sb.setGoto(); + rootScopeBlock.addChild(sb); + } else { + sb = new ScopeBlock(getPC(), target); + sb.setGoto(); + rootScopeBlock.addChild(sb); + } + } + } else { + ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target); + if ((sb != null) && (!sb.isLoop) && !sb.hasChildren()) { + if (sb.isGoto()) { + ScopeBlock parent = sb.getParent(); + sb.pushUpLoadStores(); + if (parent != null) + { + parent.removeChild(sb); + } + sb = new ScopeBlock(getPC(), target); + rootScopeBlock.addChild(sb); + } else { + sb.pushUpLoadStores(); + sb.setStart(getPC()); + sb.setFinish(target); + } + } else { + sb = new ScopeBlock(getPC(), target); + rootScopeBlock.addChild(sb); + } + } + } else { + ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); + if (sb != null) + { + sb.setLoop(); + } + } + } else if ((seen == TABLESWITCH) || (seen == LOOKUPSWITCH)) { + int pc = getPC(); + int[] offsets = getSwitchOffsets(); + List<Integer> targets = new ArrayList<Integer>(); + for (int offset : offsets) + { + targets.add(Integer14.valueOf(offset + pc)); + } + Integer defOffset = Integer14.valueOf(getDefaultSwitchOffset() + pc); + if (!targets.contains(defOffset)) + { + targets.add(defOffset); + } + Collections.sort(targets); + + Integer lastTarget = targets.get(0); + for (int i = 1; i < targets.size(); i++) { + Integer nextTarget = targets.get(i); + ScopeBlock sb = new ScopeBlock(lastTarget.intValue(), nextTarget.intValue()); + rootScopeBlock.addChild(sb); + lastTarget = nextTarget; + } + switchTargets.addAll(targets); + } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE)) { + if ("wasNull".equals(getNameConstantOperand()) + && "()Z".equals(getSigConstantOperand())) + { + dontReport = true; + } + + caller = getCallingObject(); + + if (caller != null) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); + if (sb != null) { + sb.removeByAssoc(caller); + } + } + + } else if (seen == MONITORENTER) { + monitorSyncPCs.add(Integer14.valueOf(getPC())); + } else if (seen == MONITOREXIT) { + if (monitorSyncPCs.size() > 0) + { + monitorSyncPCs.remove(monitorSyncPCs.size() - 1); + } + } + + sawDup = (seen == DUP); + sawNull = (seen == ACONST_NULL); + } finally { + stack.sawOpcode(this, seen); + if (caller != null) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(caller); + } + } + } + } + + /** + * returns either a register number of a field reference of the object that a method is being called on, + * or null, if it can't be determined. + * + * @return either an Integer for a register, or a String for the field name, or null + */ + private Object getCallingObject() { + String sig = getSigConstantOperand(); + if ("V".equals(Type.getReturnType(sig))) + { + return null; } - - sawDup = (seen == DUP); - sawNull = (seen == ACONST_NULL); + + Type[] types = Type.getArgumentTypes(sig); + if (stack.getStackDepth() <= types.length) { + return null; + } + + OpcodeStack.Item caller = stack.getStackItem(types.length); + int reg = caller.getRegisterNumber(); + if (reg >= 0) + { + return Integer.valueOf(reg); + } + + /* We ignore the possibility of two fields with the same name in different classes */ + XField f = caller.getXField(); + if (f != null) + { + return f.getName(); + } + return null; } - /** * returns the scope block in which this register was assigned, by traversing the scope block tree * @@ -302,7 +411,9 @@ for (ScopeBlock child : sb.children) { ScopeBlock foundSb = findScopeBlock(child, pc); if (foundSb != null) - return foundSb; + { + return foundSb; + } } } return sb; @@ -322,7 +433,9 @@ ScopeBlock parentBlock = null; if ((sb.startLocation < start) && (sb.finishLocation >= start)) { if ((sb.finishLocation <= target) || (sb.isGoto() && !sb.isLoop())) + { parentBlock = sb; + } } if (sb.children != null) @@ -330,7 +443,9 @@ for (ScopeBlock child : sb.children) { ScopeBlock targetBlock = findScopeBlockWithTarget(child, start, target); if (targetBlock != null) - return targetBlock; + { + return targetBlock; + } } } @@ -348,6 +463,7 @@ private boolean isGoto; private Map<Integer, Integer> loads; private Map<Integer, Integer> stores; + private Map<Object, Integer> assocs; private List<ScopeBlock> children; /** construts a new scope block @@ -363,6 +479,7 @@ isGoto = false; loads = null; stores = null; + assocs = null; children = null; } @@ -458,13 +575,39 @@ * @param reg the register that was stored * @param pc the instruction that did the store */ - public void addStore(int reg, int pc) { + public void addStore(int reg, int pc, Object assocObject) { if (stores == null) - stores = new HashMap<Integer, Integer>(); + { + stores = new HashMap<Integer, Integer>(); + } stores.put(Integer14.valueOf(reg), Integer14.valueOf(pc)); + if (assocs == null) + { + assocs = new HashMap<Object, Integer>(); + } + assocs.put(assocObject, reg); } + /** + * removes stores to registers that where retrieved from method calls on assocObject + * + * @param assocObject the object that a method call was just performed on + */ + public void removeByAssoc(Object assocObject) { + if (assocs != null) { + Integer reg = assocs.remove(assocObject); + if (reg != null) { + if (loads != null) { + loads.remove(reg); + } + if (stores != null) { + stores.remove(reg); + } + } + } + } + /** * adds the register as a load in this scope block * @@ -473,7 +616,9 @@ */ public void addLoad(int reg, int pc) { if (loads == null) - loads = new HashMap<Integer, Integer>(); + { + loads = new HashMap<Integer, Integer>(); + } loads.put(Integer14.valueOf(reg), Integer14.valueOf(pc)); } @@ -514,7 +659,9 @@ */ public void removeChild(ScopeBlock child) { if (children != null) + { children.remove(child); + } } /** @@ -522,17 +669,25 @@ */ public void findBugs(Set<Integer> parentUsedRegs) { if (isLoop) - return; + { + return; + } Set<Integer> usedRegs = new HashSet<Integer>(parentUsedRegs); if (stores != null) + { usedRegs.addAll(stores.keySet()); + } if (loads != null) + { usedRegs.addAll(loads.keySet()); + } if (stores != null) { if (loads != null) - stores.keySet().removeAll(loads.keySet()); + { + stores.keySet().removeAll(loads.keySet()); + } stores.keySet().removeAll(parentUsedRegs); if (stores.size() > 0) { @@ -577,14 +732,20 @@ */ public boolean usesReg(Integer reg) { if ((loads != null) && (loads.containsKey(reg))) - return true; + { + return true; + } if ((stores != null) && (stores.containsKey(reg))) - return true; + { + return true; + } if (children != null) { for (ScopeBlock child : children) { if (child.usesReg(reg)) - return true; + { + return true; + } } } @@ -598,15 +759,23 @@ if (parent != null) { if (loads != null) { if (parent.loads != null) - parent.loads.putAll(loads); - else - parent.loads = loads; + { + parent.loads.putAll(loads); + } + else + { + parent.loads = loads; + } } if (stores != null) { if (parent.stores != null) - parent.stores.putAll(stores); - else - parent.stores = stores; + { + parent.stores.putAll(stores); + } + else + { + parent.stores = stores; + } } loads = null; stores = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-17 05:41:47
|
Revision: 1147 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1147&view=rev Author: dbrosius Date: 2009-03-17 05:41:35 +0000 (Tue, 17 Mar 2009) Log Message: ----------- add fp test Modified Paths: -------------- trunk/fb-contrib/samples/BAS_Sample.java Modified: trunk/fb-contrib/samples/BAS_Sample.java =================================================================== --- trunk/fb-contrib/samples/BAS_Sample.java 2009-03-16 04:12:15 UTC (rev 1146) +++ trunk/fb-contrib/samples/BAS_Sample.java 2009-03-17 05:41:35 UTC (rev 1147) @@ -1,3 +1,4 @@ +import java.util.Calendar; import java.util.List; import java.util.Set; @@ -27,9 +28,13 @@ { Object o = new Object(); if (s.equals("Boo")) - s = o.toString(); - else if (s.equals("Hoo")) - s = o.toString(); + { + s = o.toString(); + } + else if (s.equals("Hoo")) + { + s = o.toString(); + } return s; } @@ -40,9 +45,13 @@ if (s != null) { if (s.equals("Boo")) - s = o.toString(); - else if (s.equals("Hoo")) - s = o.toString(); + { + s = o.toString(); + } + else if (s.equals("Hoo")) + { + s = o.toString(); + } } return s; @@ -104,5 +113,18 @@ d = c; } } + + public int testFPObjChange(Calendar c, boolean b) + { + int hour = c.get(Calendar.HOUR_OF_DAY); + c.set(2000, Calendar.JANUARY, 1); + + if (b) + { + return hour; + } + + return 0; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-16 04:12:25
|
Revision: 1146 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1146&view=rev Author: dbrosius Date: 2009-03-16 04:12:15 +0000 (Mon, 16 Mar 2009) Log Message: ----------- go back to 3.9.0 development Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2009-03-16 04:01:14 UTC (rev 1145) +++ trunk/fb-contrib/build.xml 2009-03-16 04:12:15 UTC (rev 1146) @@ -20,7 +20,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="3.8.1"/> + <property name="fb-contrib.version" value="3.9.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2009-03-16 04:01:14 UTC (rev 1145) +++ trunk/fb-contrib/etc/findbugs.xml 2009-03-16 04:12:15 UTC (rev 1146) @@ -334,8 +334,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BogusExceptionDeclaration" speed="moderate" - reports="BED_BOGUS_EXCEPTION_DECLARATION" - hidden="true" /> + reports="BED_BOGUS_EXCEPTION_DECLARATION" /> <!-- BugPattern --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-16 04:01:23
|
Revision: 1145 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1145&view=rev Author: dbrosius Date: 2009-03-16 04:01:14 +0000 (Mon, 16 Mar 2009) Log Message: ----------- Tag 3.8.1 Added Paths: ----------- tags/v3_8_1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-16 03:59:56
|
Revision: 1144 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1144&view=rev Author: dbrosius Date: 2009-03-16 03:59:42 +0000 (Mon, 16 Mar 2009) Log Message: ----------- get ready for 3.8.1 Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/samples/LEST_Sample.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2009-03-16 03:09:24 UTC (rev 1143) +++ trunk/fb-contrib/build.xml 2009-03-16 03:59:42 UTC (rev 1144) @@ -20,7 +20,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="3.9.0"/> + <property name="fb-contrib.version" value="3.8.1"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2009-03-16 03:09:24 UTC (rev 1143) +++ trunk/fb-contrib/etc/findbugs.xml 2009-03-16 03:59:42 UTC (rev 1144) @@ -334,7 +334,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BogusExceptionDeclaration" speed="moderate" - reports="BED_BOGUS_EXCEPTION_DECLARATION" /> + reports="BED_BOGUS_EXCEPTION_DECLARATION" + hidden="true" /> <!-- BugPattern --> Modified: trunk/fb-contrib/samples/LEST_Sample.java =================================================================== --- trunk/fb-contrib/samples/LEST_Sample.java 2009-03-16 03:09:24 UTC (rev 1143) +++ trunk/fb-contrib/samples/LEST_Sample.java 2009-03-16 03:59:42 UTC (rev 1144) @@ -101,6 +101,19 @@ } } + public void testLestFP6(String s) throws Exception + { + double d; + try + { + d = Double.parseDouble(s); + } + finally + { + throw new Exception("Yikes"); + } + } + private Exception wrap(Exception e) { return new Exception(e); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-16 03:09:37
|
Revision: 1143 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1143&view=rev Author: dbrosius Date: 2009-03-16 03:09:24 +0000 (Mon, 16 Mar 2009) Log Message: ----------- more fps with a throw followed by a store Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2009-03-16 03:01:00 UTC (rev 1142) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2009-03-16 03:09:24 UTC (rev 1143) @@ -288,7 +288,7 @@ } } - lastWasExitPoint = ((seen >= IRETURN) && (seen <= RETURN)) || (seen == GOTO) || (seen == GOTO_W); + lastWasExitPoint = ((seen >= IRETURN) && (seen <= RETURN)) || (seen == GOTO) || (seen == GOTO_W) || (seen == ATHROW); } finally { stack.sawOpcode(this, seen); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-03-16 03:01:08
|
Revision: 1142 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1142&view=rev Author: dbrosius Date: 2009-03-16 03:01:00 +0000 (Mon, 16 Mar 2009) Log Message: ----------- remove some more fps due to crazy jdk6 finally block generations Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2009-03-15 04:28:50 UTC (rev 1141) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2009-03-16 03:01:00 UTC (rev 1142) @@ -67,6 +67,7 @@ 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 @@ -134,6 +135,7 @@ catchInfos.clear(); exceptions = collectExceptions(obj.getExceptionTable()); exReg.clear(); + lastWasExitPoint = false; super.visitCode(obj); } } @@ -255,6 +257,12 @@ } } } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { + if (lastWasExitPoint) { + //crazy jdk6 finally block injection -- shut off detection + catchInfos.clear(); + break; + } + if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); int reg = RegisterUtils.getAStoreReg(this, seen); @@ -279,6 +287,8 @@ it.remove(); } } + + lastWasExitPoint = ((seen >= IRETURN) && (seen <= RETURN)) || (seen == GOTO) || (seen == GOTO_W); } finally { stack.sawOpcode(this, seen); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |