fb-contrib-commit Mailing List for fb-contrib (Page 24)
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-09-06 20:29:49
|
Revision: 1266 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1266&view=rev Author: dbrosius Date: 2009-09-06 20:29:36 +0000 (Sun, 06 Sep 2009) Log Message: ----------- add TODO for AALOAD, loading a multiarray sub index Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 20:23:45 UTC (rev 1265) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 20:29:36 UTC (rev 1266) @@ -145,6 +145,12 @@ } break; + case AALOAD: { + //TODO: + } + break; + + case IASTORE: case LASTORE: case FASTORE: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-06 20:23:52
|
Revision: 1265 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1265&view=rev Author: dbrosius Date: 2009-09-06 20:23:45 +0000 (Sun, 06 Sep 2009) Log Message: ----------- add multi fp case Modified Paths: -------------- trunk/fb-contrib/samples/SUA_Sample.java Modified: trunk/fb-contrib/samples/SUA_Sample.java =================================================================== --- trunk/fb-contrib/samples/SUA_Sample.java 2009-09-06 20:22:42 UTC (rev 1264) +++ trunk/fb-contrib/samples/SUA_Sample.java 2009-09-06 20:23:45 UTC (rev 1265) @@ -50,4 +50,11 @@ Long[][] multi = new Long[3][4]; return multi; } + + public float[][] getMultiFP() + { + float[][] multi = new float[1][1]; + multi[0][0] = 1.0f; + return multi; + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-06 20:22:51
|
Revision: 1264 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1264&view=rev Author: dbrosius Date: 2009-09-06 20:22:42 +0000 (Sun, 06 Sep 2009) Log Message: ----------- handle multi arrays Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 20:16:45 UTC (rev 1263) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 20:22:42 UTC (rev 1264) @@ -123,15 +123,7 @@ break; case MULTIANEWARRAY: { - int dims = getIntConstant(); - StringBuilder sig = new StringBuilder(); - while (--dims >= 0) { - sig.append("["); - } - sig.append("L"); - sig.append(getClassConstantOperand()); - sig.append(";"); - if (returnArraySig.equals(sig.toString())) { + if (returnArraySig.equals(getClassConstantOperand())) { userValue = UNINIT_ARRAY; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-06 20:16:52
|
Revision: 1263 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1263&view=rev Author: dbrosius Date: 2009-09-06 20:16:45 +0000 (Sun, 06 Sep 2009) Log Message: ----------- more fps Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 20:12:06 UTC (rev 1262) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 20:16:45 UTC (rev 1263) @@ -225,11 +225,9 @@ } } finally { stack.sawOpcode(this, seen); - if (UNINIT_ARRAY.equals(userValue)) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item item = stack.getStackItem(0); - item.setUserValue(UNINIT_ARRAY); - } + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(userValue != null ? UNINIT_ARRAY : null); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-06 20:12:15
|
Revision: 1262 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1262&view=rev Author: dbrosius Date: 2009-09-06 20:12:06 +0000 (Sun, 06 Sep 2009) Log Message: ----------- ignore arrays stored in fields Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 20:07:58 UTC (rev 1261) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 20:12:06 UTC (rev 1262) @@ -200,7 +200,14 @@ break; case PUTFIELD: { - + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(null); + int reg = item.getRegisterNumber(); + if (reg >= 0) { + uninitializedRegs.clear(reg); + } + } } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-06 20:08:06
|
Revision: 1261 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1261&view=rev Author: dbrosius Date: 2009-09-06 20:07:58 +0000 (Sun, 06 Sep 2009) Log Message: ----------- add fp for when storing an array in a field Modified Paths: -------------- trunk/fb-contrib/samples/SUA_Sample.java Modified: trunk/fb-contrib/samples/SUA_Sample.java =================================================================== --- trunk/fb-contrib/samples/SUA_Sample.java 2009-09-06 20:06:15 UTC (rev 1260) +++ trunk/fb-contrib/samples/SUA_Sample.java 2009-09-06 20:07:58 UTC (rev 1261) @@ -2,6 +2,8 @@ public class SUA_Sample { + boolean[] b; + public int[] getAnArray() { return new int[10]; @@ -19,6 +21,12 @@ return c; } + public boolean[] buildAMemberFP() { + boolean[] bb = new boolean[2]; + b = bb; + return bb; + } + public String[] getDetailedArray() { String [] s = new String[3]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-06 20:06:35
|
Revision: 1260 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1260&view=rev Author: dbrosius Date: 2009-09-06 20:06:15 +0000 (Sun, 06 Sep 2009) Log Message: ----------- knock down some fps Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 19:38:27 UTC (rev 1259) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 20:06:15 UTC (rev 1260) @@ -161,7 +161,14 @@ case BASTORE: case CASTORE: case SASTORE: { - + if (stack.getStackDepth() >= 3) { + OpcodeStack.Item item = stack.getStackItem(2); + item.setUserValue(null); + int reg = item.getRegisterNumber(); + if (reg >= 0) { + uninitializedRegs.clear(reg); + } + } } break; @@ -171,7 +178,12 @@ case ASTORE_2: case ASTORE_3: { int reg = RegisterUtils.getAStoreReg(this, seen); - uninitializedRegs.set(reg); + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + uninitializedRegs.set(reg, (UNINIT_ARRAY.equals(item.getUserValue()))); + } else { + uninitializedRegs.clear(reg); + } } break; @@ -206,7 +218,7 @@ } } finally { stack.sawOpcode(this, seen); - if (userValue != null) { + if (UNINIT_ARRAY.equals(userValue)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); item.setUserValue(UNINIT_ARRAY); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-06 19:38:37
|
Revision: 1259 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1259&view=rev Author: dbrosius Date: 2009-09-06 19:38:27 +0000 (Sun, 06 Sep 2009) Log Message: ----------- add normal case Modified Paths: -------------- trunk/fb-contrib/samples/SUA_Sample.java Modified: trunk/fb-contrib/samples/SUA_Sample.java =================================================================== --- trunk/fb-contrib/samples/SUA_Sample.java 2009-09-06 19:35:22 UTC (rev 1258) +++ trunk/fb-contrib/samples/SUA_Sample.java 2009-09-06 19:38:27 UTC (rev 1259) @@ -7,6 +7,18 @@ return new int[10]; } + public char[] normalCase() + { + char[] c = new char[5]; + c[0] = 'h'; + c[1] = 'e'; + c[2] = 'l'; + c[3] = 'l'; + c[4] = 'o'; + + return c; + } + public String[] getDetailedArray() { String [] s = new String[3]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-06 19:35:29
|
Revision: 1258 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1258&view=rev Author: dbrosius Date: 2009-09-06 19:35:22 +0000 (Sun, 06 Sep 2009) Log Message: ----------- starting to work, but with many fps Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 05:59:36 UTC (rev 1257) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 19:35:22 UTC (rev 1258) @@ -18,11 +18,15 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.BitSet; + import org.apache.bcel.classfile.Code; import org.apache.bcel.generic.Type; +import com.mebigfatguy.fbcontrib.utils.RegisterUtils; import com.mebigfatguy.fbcontrib.utils.SignatureUtils; +import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.OpcodeStack; @@ -39,6 +43,7 @@ private final BugReporter bugReporter; private OpcodeStack stack; private String returnArraySig; + private BitSet uninitializedRegs; /** * constructs a SUA detector given the reporter to report bugs on @@ -57,9 +62,11 @@ public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); + uninitializedRegs = new BitSet(); super.visitClassContext(classContext); } finally { stack = null; + uninitializedRegs = null; } } @@ -76,6 +83,7 @@ if (sigPos >= 0) { stack.resetForMethodEntry(this); returnArraySig = sig.substring(sigPos + 1); + uninitializedRegs.clear(); super.visitCode(obj); } } @@ -92,56 +100,109 @@ public void sawOpcode(int seen) { String userValue = null; try { - if (seen == NEWARRAY) { - if (!isTOS0()) { - int typeCode = getIntConstant(); - String sig = "[" + SignatureUtils.getTypeCodeSignature(typeCode); - if (returnArraySig.equals(sig)) { - userValue = UNINIT_ARRAY; + switch (seen) { + case NEWARRAY: { + if (!isTOS0()) { + int typeCode = getIntConstant(); + String sig = "[" + SignatureUtils.getTypeCodeSignature(typeCode); + if (returnArraySig.equals(sig)) { + userValue = UNINIT_ARRAY; + } } } - } else if (seen == ANEWARRAY) { - if (!isTOS0()) { - String sig = "[L" + getClassConstantOperand() + ";"; - if (returnArraySig.equals(sig)) { + break; + + case ANEWARRAY: { + if (!isTOS0()) { + String sig = "[L" + getClassConstantOperand() + ";"; + if (returnArraySig.equals(sig)) { + userValue = UNINIT_ARRAY; + } + } + } + break; + + case MULTIANEWARRAY: { + int dims = getIntConstant(); + StringBuilder sig = new StringBuilder(); + while (--dims >= 0) { + sig.append("["); + } + sig.append("L"); + sig.append(getClassConstantOperand()); + sig.append(";"); + if (returnArraySig.equals(sig.toString())) { userValue = UNINIT_ARRAY; } } - } else if (seen == MULTIANEWARRAY) { - int dims = getIntConstant(); - StringBuilder sig = new StringBuilder(); - while (--dims >= 0) { - sig.append("["); + break; + + case INVOKEVIRTUAL: + case INVOKEINTERFACE: + case INVOKESPECIAL: { + int parmOffset = (seen == INVOKESPECIAL) ? 0 : 1; + String methodSig = getSigConstantOperand(); + Type[] types = Type.getArgumentTypes(methodSig); + for (int t = 0; t < types.length; t++) { + Type type = types[t]; + if (returnArraySig.equals(type.getSignature())) { + int parmIndex = types.length - t - 1 + parmOffset; + //TODO + } + } } - sig.append("L"); - sig.append(getClassConstantOperand()); - sig.append(";"); - if (returnArraySig.equals(sig.toString())) { - userValue = UNINIT_ARRAY; + break; + + case IASTORE: + case LASTORE: + case FASTORE: + case DASTORE: + case AASTORE: + case BASTORE: + case CASTORE: + case SASTORE: { + } - } else if ((seen == INVOKEVIRTUAL) - || (seen == INVOKEINTERFACE) - || (seen == INVOKESPECIAL)) { - int parmOffset = (seen == INVOKESPECIAL) ? 0 : 1; - String methodSig = getSigConstantOperand(); - Type[] types = Type.getArgumentTypes(methodSig); - for (int t = 0; t < types.length; t++) { - Type type = types[t]; - if (returnArraySig.equals(type.getSignature())) { - int parmIndex = types.length - t - 1 + parmOffset; - //TODO + break; + + case ASTORE: + case ASTORE_0: + case ASTORE_1: + case ASTORE_2: + case ASTORE_3: { + int reg = RegisterUtils.getAStoreReg(this, seen); + uninitializedRegs.set(reg); + } + break; + + case ALOAD: + case ALOAD_0: + case ALOAD_1: + case ALOAD_2: + case ALOAD_3: { + int reg = RegisterUtils.getALoadReg(this, seen); + if (uninitializedRegs.get(reg)) { + userValue = UNINIT_ARRAY; } } - - } else if ((seen >= IASTORE) - && (seen <= SASTORE)) { - - } else if ((seen == ASTORE) - || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { - - } else if ((seen == ALOAD) - || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { - } else if (seen == PUTFIELD) { + break; + + case PUTFIELD: { + + } + break; + + case ARETURN: { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + if (UNINIT_ARRAY.equals(item.getUserValue())) + bugReporter.reportBug(new BugInstance(this, "SUA_SUSPICIOUS_UNINITIALIZED_ARRAY", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + break; } } 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-09-06 05:59:46
|
Revision: 1257 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1257&view=rev Author: dbrosius Date: 2009-09-06 05:59:36 +0000 (Sun, 06 Sep 2009) Log Message: ----------- stub in MULTIANEWARRAY Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 05:54:53 UTC (rev 1256) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 05:59:36 UTC (rev 1257) @@ -108,7 +108,17 @@ } } } else if (seen == MULTIANEWARRAY) { - + int dims = getIntConstant(); + StringBuilder sig = new StringBuilder(); + while (--dims >= 0) { + sig.append("["); + } + sig.append("L"); + sig.append(getClassConstantOperand()); + sig.append(";"); + if (returnArraySig.equals(sig.toString())) { + userValue = UNINIT_ARRAY; + } } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE) || (seen == INVOKESPECIAL)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-06 05:55:01
|
Revision: 1256 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1256&view=rev Author: dbrosius Date: 2009-09-06 05:54:53 +0000 (Sun, 06 Sep 2009) Log Message: ----------- stub in NEWARRAY support Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 05:53:44 UTC (rev 1255) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-09-06 05:54:53 UTC (rev 1256) @@ -21,6 +21,8 @@ import org.apache.bcel.classfile.Code; import org.apache.bcel.generic.Type; +import com.mebigfatguy.fbcontrib.utils.SignatureUtils; + import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.OpcodeStack; @@ -90,13 +92,23 @@ public void sawOpcode(int seen) { String userValue = null; try { - if (seen == ANEWARRAY) { - String sig = "[L" + getClassConstantOperand() + ";"; - if (returnArraySig.equals(sig)) { - userValue = UNINIT_ARRAY; + if (seen == NEWARRAY) { + if (!isTOS0()) { + int typeCode = getIntConstant(); + String sig = "[" + SignatureUtils.getTypeCodeSignature(typeCode); + if (returnArraySig.equals(sig)) { + userValue = UNINIT_ARRAY; + } } + } else if (seen == ANEWARRAY) { + if (!isTOS0()) { + String sig = "[L" + getClassConstantOperand() + ";"; + if (returnArraySig.equals(sig)) { + userValue = UNINIT_ARRAY; + } + } } else if (seen == MULTIANEWARRAY) { - + } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE) || (seen == INVOKESPECIAL)) { @@ -131,4 +143,13 @@ } } } + + private boolean isTOS0() { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + return item.mustBeZero(); + } + + return false; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-06 05:53:54
|
Revision: 1255 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1255&view=rev Author: dbrosius Date: 2009-09-06 05:53:44 +0000 (Sun, 06 Sep 2009) Log Message: ----------- add getTypeCodeSignature Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2009-09-06 04:03:39 UTC (rev 1254) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2009-09-06 05:53:44 UTC (rev 1255) @@ -18,6 +18,7 @@ */ package com.mebigfatguy.fbcontrib.utils; +import org.apache.bcel.Constants; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; @@ -87,6 +88,39 @@ return similarPackages(packName1.substring(dot1+1), packName2.substring(dot2+1), depth-1); } + + /** + * converts a primitive type code to a signature + */ + public static String getTypeCodeSignature(int typeCode) { + switch (typeCode) { + case Constants.T_BOOLEAN: + return "Z"; + + case Constants.T_CHAR: + return "C"; + + case Constants.T_FLOAT: + return "F"; + + case Constants.T_DOUBLE: + return "D"; + + case Constants.T_BYTE: + return "B"; + + case Constants.T_SHORT: + return "S"; + + case Constants.T_INT: + return "I"; + + case Constants.T_LONG: + return "L"; + } + + return "Ljava/lang/Object;"; + } private static JavaClass findInheritedMethod(JavaClass[] classes, String methodName, String signature) { @@ -106,4 +140,5 @@ } return null; } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-06 04:03:47
|
Revision: 1254 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1254&view=rev Author: dbrosius Date: 2009-09-06 04:03:39 +0000 (Sun, 06 Sep 2009) Log Message: ----------- don't catch exception that isn't thrown Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java 2009-09-06 04:02:51 UTC (rev 1253) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java 2009-09-06 04:03:39 UTC (rev 1254) @@ -160,8 +160,6 @@ } break; } - } catch (ClassNotFoundException cnfe) { - bugReporter.reportMissingClass(cnfe); } finally { stack.sawOpcode(this, seen); if (fieldSource != null) { @@ -180,7 +178,7 @@ * @param parms the arguments to the method being called * @return if there are duplicates */ - private boolean duplicateArguments(OpcodeStack stack, Type[] parms) throws ClassNotFoundException + private boolean duplicateArguments(OpcodeStack stack, Type[] parms) { Set<String> args = new HashSet<String>(); for (int i = 0; i < parms.length; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-06 04:02:58
|
Revision: 1253 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1253&view=rev Author: dbrosius Date: 2009-09-06 04:02:51 +0000 (Sun, 06 Sep 2009) Log Message: ----------- npe guard Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java 2009-09-05 21:59:44 UTC (rev 1252) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java 2009-09-06 04:02:51 UTC (rev 1253) @@ -114,7 +114,7 @@ } JavaClass parmClass = Repository.lookupClass(parmSignature.substring(1, parmSignature.length() - 1)); - if (parmClass.instanceOf(returnClass)) { + if ((parmRegs != null) && parmClass.instanceOf(returnClass)) { possibleParmRegs.put(Integer14.valueOf(parmRegs[p]), new ParmUsage()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-05 21:59:50
|
Revision: 1252 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1252&view=rev Author: dbrosius Date: 2009-09-05 21:59:44 +0000 (Sat, 05 Sep 2009) Log Message: ----------- oops Modified Paths: -------------- trunk/fb-contrib/samples/SUA_Sample.java Modified: trunk/fb-contrib/samples/SUA_Sample.java =================================================================== --- trunk/fb-contrib/samples/SUA_Sample.java 2009-09-05 21:31:21 UTC (rev 1251) +++ trunk/fb-contrib/samples/SUA_Sample.java 2009-09-05 21:59:44 UTC (rev 1252) @@ -1,5 +1,5 @@ +import java.util.Date; - public class SUA_Sample { public int[] getAnArray() @@ -14,7 +14,7 @@ int sum = 0; for (int i = 0; i < 3; i++) { - sum += s[i]; + sum += s[i].hashCode(); } return s; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-05 21:31:27
|
Revision: 1251 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1251&view=rev Author: dbrosius Date: 2009-09-05 21:31:21 +0000 (Sat, 05 Sep 2009) Log Message: ----------- test case for SuspiciousUnitializedArray Added Paths: ----------- trunk/fb-contrib/samples/SUA_Sample.java Added: trunk/fb-contrib/samples/SUA_Sample.java =================================================================== --- trunk/fb-contrib/samples/SUA_Sample.java (rev 0) +++ trunk/fb-contrib/samples/SUA_Sample.java 2009-09-05 21:31:21 UTC (rev 1251) @@ -0,0 +1,33 @@ + + +public class SUA_Sample +{ + public int[] getAnArray() + { + return new int[10]; + } + + public String[] getDetailedArray() + { + String [] s = new String[3]; + + int sum = 0; + for (int i = 0; i < 3; i++) + { + sum += s[i]; + } + + return s; + } + + public Date[] ok() + { + return new Date[0]; + } + + public Long[][] getMulti() + { + Long[][] multi = new Long[3][4]; + return multi; + } +} \ No newline at end of file Property changes on: trunk/fb-contrib/samples/SUA_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...> - 2009-08-20 06:14:04
|
Revision: 1250 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1250&view=rev Author: dbrosius Date: 2009-08-20 06:13:56 +0000 (Thu, 20 Aug 2009) Log Message: ----------- add TODO Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-08-20 06:13:03 UTC (rev 1249) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2009-08-20 06:13:56 UTC (rev 1250) @@ -107,6 +107,7 @@ Type type = types[t]; if (returnArraySig.equals(type.getSignature())) { int parmIndex = types.length - t - 1 + parmOffset; + //TODO } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-08-20 06:13:12
|
Revision: 1249 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1249&view=rev Author: dbrosius Date: 2009-08-20 06:13:03 +0000 (Thu, 20 Aug 2009) Log Message: ----------- remove warninsg Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java 2009-08-20 05:13:30 UTC (rev 1248) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java 2009-08-20 06:13:03 UTC (rev 1249) @@ -124,7 +124,7 @@ case AALOAD: if ("main".equals(this.getMethodName())) break; - //FALL THRU + //$FALL-THROUGH$ case IALOAD: case LALOAD: case FALOAD: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-08-20 05:13:39
|
Revision: 1248 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1248&view=rev Author: dbrosius Date: 2009-08-20 05:13:30 +0000 (Thu, 20 Aug 2009) Log Message: ----------- allow toString on StringWriter Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java 2009-08-11 06:14:37 UTC (rev 1247) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java 2009-08-20 05:13:30 UTC (rev 1248) @@ -54,6 +54,7 @@ validToStringClasses.add("java/lang/Number"); validToStringClasses.add("java/lang/StringBuffer"); validToStringClasses.add("java/lang/StringBuilder"); + validToStringClasses.add("java/io/StringWriter"); } private static final Set<String> stringAlgoMethods = new HashSet<String>(); static { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-08-11 06:14:47
|
Revision: 1247 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1247&view=rev Author: dbrosius Date: 2009-08-11 06:14:37 +0000 (Tue, 11 Aug 2009) Log Message: ----------- when a transition pt is reached clear all the items on the stack 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-08-11 05:52:29 UTC (rev 1246) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-08-11 06:14:37 UTC (rev 1247) @@ -41,17 +41,17 @@ * or through an exception, this test is unnecessary and represents a misunderstanding * as to how the jvm works. */ -public class UnnecessaryNewNullCheck extends BytecodeScanningDetector +public class UnnecessaryNewNullCheck extends BytecodeScanningDetector { private final BugReporter bugReporter; private OpcodeStack stack; private Set<Integer> allocationRegs; private Set<Integer> transitionPoints; - + public UnnecessaryNewNullCheck(BugReporter bugReporter) { this.bugReporter = bugReporter; } - + @Override public void visitClassContext(ClassContext classContext) { try { @@ -65,14 +65,14 @@ transitionPoints = null; } } - + @Override public void visitCode(Code obj) { if (prescreen()) { stack.resetForMethodEntry(this); allocationRegs.clear(); transitionPoints.clear(); - + CodeException[] ce = obj.getExceptionTable(); if (ce != null) { for (CodeException element : ce) { @@ -82,7 +82,7 @@ super.visitCode(obj); } } - + @Override public void sawOpcode(int seen) { boolean sawAlloc = false; @@ -90,90 +90,95 @@ if (transitionPoints.contains(Integer14.valueOf(getPC()))) { allocationRegs.clear(); + int depth = stack.getStackDepth(); + for (int i = 0; i < depth; i++) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(null); + } } - + switch (seen) { - case NEW: - case ANEWARRAY: - case MULTIANEWARRAY: - sawAlloc = true; + 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)); - } + + 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; - } + + 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) { - if (AttributesUtils.isValidLineNumber(getCode(), getPC())) { - bugReporter.reportBug(new BugInstance(this, "UNNC_UNNECESSARY_NEW_NULL_CHECK", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } + + case IFNONNULL: + case IFNULL: + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + if (item.getUserValue() != null) { + if (AttributesUtils.isValidLineNumber(getCode(), getPC())) { + bugReporter.reportBug(new BugInstance(this, "UNNC_UNNECESSARY_NEW_NULL_CHECK", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); } } - transitionPoints.add(Integer14.valueOf(getBranchTarget())); - allocationRegs.clear(); + } + transitionPoints.add(Integer14.valueOf(getBranchTarget())); + allocationRegs.clear(); 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: - case GOTO: - case GOTO_W: - transitionPoints.add(Integer14.valueOf(getBranchTarget())); - allocationRegs.clear(); + + 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 GOTO: + case GOTO_W: + transitionPoints.add(Integer14.valueOf(getBranchTarget())); + allocationRegs.clear(); break; - - case TABLESWITCH: - case LOOKUPSWITCH: - case IRETURN: - case LRETURN: - case FRETURN: - case DRETURN: - case ARETURN: - case RETURN: - case ATHROW: - allocationRegs.clear(); - break; + + case TABLESWITCH: + case LOOKUPSWITCH: + case IRETURN: + case LRETURN: + case FRETURN: + case DRETURN: + case ARETURN: + case RETURN: + case ATHROW: + allocationRegs.clear(); + break; } } finally { stack.sawOpcode(this, seen); @@ -185,12 +190,12 @@ } } } - + private boolean prescreen() { BitSet bytecodeSet = getClassContext().getBytecodeSet(getMethod()); - return (bytecodeSet != null) && - (bytecodeSet.get(Constants.NEW) - || bytecodeSet.get(Constants.ANEWARRAY) - || bytecodeSet.get(Constants.MULTIANEWARRAY)); + return (bytecodeSet != null) && + (bytecodeSet.get(Constants.NEW) + || bytecodeSet.get(Constants.ANEWARRAY) + || bytecodeSet.get(Constants.MULTIANEWARRAY)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-08-11 05:52:37
|
Revision: 1246 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1246&view=rev Author: dbrosius Date: 2009-08-11 05:52:29 +0000 (Tue, 11 Aug 2009) Log Message: ----------- add trinary case Modified Paths: -------------- trunk/fb-contrib/samples/UNNC_Sample.java Modified: trunk/fb-contrib/samples/UNNC_Sample.java =================================================================== --- trunk/fb-contrib/samples/UNNC_Sample.java 2009-08-10 00:08:15 UTC (rev 1245) +++ trunk/fb-contrib/samples/UNNC_Sample.java 2009-08-11 05:52:29 UTC (rev 1246) @@ -1,57 +1,66 @@ +import java.util.ArrayList; +import java.util.List; + public class UNNC_Sample { public void testPosNEW() { UNNC_Sample sample = new UNNC_Sample(); - - if (sample != null) + + if (sample != null) { System.out.println("OK"); + } } - + public void testNegNEW() { UNNC_Sample sample = new UNNC_Sample(); - - if (sample == null) + + if (sample == null) { return; - + } + System.out.println("OK"); } - + public void testPosANEWARAY() { String[] s = new String[10]; - if (s != null) + if (s != null) { System.out.println("OK"); + } } - + public void testNegANEWARRAY() { String[] s = new String[10]; - if (s == null) + if (s == null) { return; - + } + System.out.println("OK"); } - + public void testPosMULTIANEWARRAY() { String[][] s = new String[10][5]; - if (s != null) + if (s != null) { System.out.println("OK"); + } } - + public void testNegMULTIANEWARRAY() { String[][] s = new String[10][5]; - if (s == null) + if (s == null) { return; - + } + System.out.println("OK"); } - + public void testFPFinally() throws Exception { StringBuilder sb = null; @@ -62,11 +71,19 @@ } finally { - if (sb != null) + if (sb != null) { sb.setLength(0); + } } + } + public void testTrinary(Boolean b) + { + List<String> l = (b == null) ? null : new ArrayList<String>(); + + if (l != null) + { + l.add("foo"); + } } - - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-08-10 00:08:42
|
Revision: 1245 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1245&view=rev Author: dbrosius Date: 2009-08-10 00:08:15 +0000 (Mon, 10 Aug 2009) Log Message: ----------- add java/lang/Object as too many fps exists with it. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java 2009-08-06 06:21:33 UTC (rev 1244) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java 2009-08-10 00:08:15 UTC (rev 1245) @@ -41,6 +41,7 @@ private static final Set<String> validToStringClasses = new HashSet<String>(); static { + validToStringClasses.add("java/lang/Object"); // too many fps validToStringClasses.add("java/lang/Byte"); validToStringClasses.add("java/lang/Character"); validToStringClasses.add("java/lang/Short"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-08-06 06:21:41
|
Revision: 1244 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1244&view=rev Author: dbrosius Date: 2009-08-06 06:21:33 +0000 (Thu, 06 Aug 2009) Log Message: ----------- make sure LDC refer to the same value 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-08-06 06:21:04 UTC (rev 1243) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java 2009-08-06 06:21:33 UTC (rev 1244) @@ -46,21 +46,21 @@ */ public class CopiedOverriddenMethod extends DismantleBytecode implements Detector { - private BugReporter bugReporter; + private final BugReporter bugReporter; private Map<String, Code> superclassCode; private ClassContext classContext; private String curMethodInfo; private ConstantPoolGen childPoolGen, parentPoolGen; - - /** - * constructs a COM detector given the reporter to report bugs on - * @param bugReporter the sync of bug reports - */ + /** + * constructs a COM detector given the reporter to report bugs on + + * @param bugReporter the sync of bug reports + */ public CopiedOverriddenMethod(BugReporter bugReporter) { this.bugReporter = bugReporter; } - + /** * overrides the visitor to accept classes derived from non java.lang.Object classes. * @@ -80,8 +80,8 @@ for (Method m : methods) { String methodName = m.getName(); if ((m.isPublic() || m.isProtected()) - && (!m.isAbstract()) - && (!"<init>".equals(methodName) && !"<clinit>".equals(methodName))) { + && (!m.isAbstract()) + && (!"<init>".equals(methodName) && !"<clinit>".equals(methodName))) { String methodInfo = methodName + ":" + m.getSignature(); superclassCode.put(methodInfo, m.getCode()); } @@ -97,7 +97,7 @@ parentPoolGen = null; } } - + /** * overrides the visitor to get the methodInfo * @@ -107,7 +107,7 @@ public void visitMethod(Method obj) { curMethodInfo = obj.getName() + ":" + obj.getSignature(); } - + /** * overrides the visitor to find code blocks of methods that are the same as its parents * @@ -120,18 +120,18 @@ { return; } - + Code superCode = superclassCode.get(curMethodInfo); if (superCode != null) { if (codeEquals(obj, superCode)) { bugReporter.reportBug(new BugInstance(this, "COM_COPIED_OVERRIDDEN_METHOD", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(classContext, this, getPC())); + .addClass(this) + .addMethod(this) + .addSourceLine(classContext, this, getPC())); } } } - + /** * compares two code blocks to see if they are equal with regard to instructions and field accesses * @@ -144,63 +144,58 @@ public boolean codeEquals(Code child, Code parent) { byte[] childBytes = child.getCode(); 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]; InstructionHandle parentih = parentihs[i]; Instruction childin = childih.getInstruction(); Instruction parentin = parentih.getInstruction(); - - if (!childin.getName().equals(parentin.getName())) - { + + 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)) - { + if (!childFName.equals(parentFName)) { return false; } String childFSig = ((FieldInstruction) childin).getSignature(childPoolGen); String parentFSig = ((FieldInstruction) parentin).getSignature(parentPoolGen); - if (!childFSig.equals(parentFSig)) - { + 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())) - { + 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)) - { + if (!childClassName.equals(parentClassName)) { return false; } String childMethodName = ((InvokeInstruction) childin).getMethodName(childPoolGen); @@ -218,38 +213,33 @@ } else if (childin instanceof LDC) { Type childType = ((LDC) childin).getType(childPoolGen); Type parentType = ((LDC) parentin).getType(parentPoolGen); - if (!childType.equals(parentType)) - { + if (!childType.equals(parentType)) { return false; } - + Object childValue = ((LDC) childin).getValue(childPoolGen); Object parentValue = ((LDC) parentin).getValue(parentPoolGen); - - if (childValue instanceof ConstantClass) - { + + if (childValue instanceof ConstantClass) { ConstantClass childClass = (ConstantClass)childValue; ConstantClass parentClass = (ConstantClass)parentValue; - if (!childClass.getBytes(childPoolGen.getConstantPool()).equals(parentClass.getBytes(parentPoolGen.getConstantPool()))) - { + if (!childClass.getBytes(childPoolGen.getConstantPool()).equals(parentClass.getBytes(parentPoolGen.getConstantPool()))) { return false; } + } else if (!childValue.equals(parentValue)) { + return false; } //TODO: Other Constant types - - } - else { - if (!childin.equals(parentin)) - { + } else { + if (!childin.equals(parentin)) { return false; } } - } return true; } - + /** * implements the detector with an empty implementation */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-08-06 06:21:11
|
Revision: 1243 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1243&view=rev Author: dbrosius Date: 2009-08-06 06:21:04 +0000 (Thu, 06 Aug 2009) Log Message: ----------- add more tests Modified Paths: -------------- trunk/fb-contrib/samples/COM_Sample.java Modified: trunk/fb-contrib/samples/COM_Sample.java =================================================================== --- trunk/fb-contrib/samples/COM_Sample.java 2009-08-06 06:19:07 UTC (rev 1242) +++ trunk/fb-contrib/samples/COM_Sample.java 2009-08-06 06:21:04 UTC (rev 1243) @@ -1,18 +1,18 @@ import java.util.HashSet; import java.util.Set; -public class COM_Sample +public class COM_Sample { public void test1() { } - + public String test2(int i) { return String.valueOf(i); } - + public Set<String> test3(String a, String b, String c) { Set<String> ss = new HashSet<String>(); @@ -21,14 +21,14 @@ ss.add(c); return ss; } - + public static class Derived extends COM_Sample { @Override public void test1() { } - + @Override public Set<String> test3(String a, String b, String c) { @@ -38,13 +38,13 @@ ss.add(c); return ss; } - + @Override public String test2(int i) { return String.valueOf(i); } - } + } } interface Inf @@ -62,3 +62,24 @@ { public void m2() {} } + +abstract class s1 +{ + public static final String FOO = "foo"; + + public String getFoo() + { + return FOO; + } +} + +abstract class s2 extends s1 +{ + public static final String FOO = "foo2"; + + @Override + public String getFoo() + { + return FOO; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-08-06 06:19:18
|
Revision: 1242 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1242&view=rev Author: dbrosius Date: 2009-08-06 06:19:07 +0000 (Thu, 06 Aug 2009) Log Message: ----------- add ITU Modified Paths: -------------- trunk/fb-contrib/etc/bugrank.txt Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2009-08-01 04:27:34 UTC (rev 1241) +++ trunk/fb-contrib/etc/bugrank.txt 2009-08-06 06:19:07 UTC (rev 1242) @@ -119,3 +119,4 @@ 0 BugPattern SMA_STUTTERED_METHOD_ARGUMENTS 0 BugPattern TBP_TRISTATE_BOOLEAN_PATTERN 0 BugPattern SUA_SUSPICIOUS_UNINITIALIZED_ARRAY +0 BugPattern ITU_INAPPROPRIATE_TOSTRING_USE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |