Thread: [Fb-contrib-commit] SF.net SVN: fb-contrib: [592] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/de
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-08-08 05:39:28
|
Revision: 592 Author: dbrosius Date: 2006-08-07 22:39:19 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=592&view=rev Log Message: ----------- fix fp's due to falling to clear catchInfos on method entry 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 2006-08-08 05:06:38 UTC (rev 591) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-08 05:39:19 UTC (rev 592) @@ -18,9 +18,11 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.ArrayList; import java.util.BitSet; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Set; import org.apache.bcel.Constants; @@ -114,12 +116,29 @@ public void visitCode(Code obj) { if (prescreen(obj, getMethod())) { stack.resetForMethodEntry(this); - exceptions = obj.getExceptionTable(); + catchInfos.clear(); + exceptions = collectExceptions(obj.getExceptionTable()); super.visitCode(obj); } } /** + * collects all the valid exception objects (ones where start and finish are before the target + * + * @param exceptions the exceptions from the class file + * @return the filtered exceptions + */ + public CodeException[] collectExceptions(CodeException[] exceptions) { + List<CodeException> filteredEx = new ArrayList<CodeException>(); + for (CodeException ce : exceptions) { + if ((ce.getStartPC() < ce.getEndPC()) && (ce.getEndPC() < ce.getHandlerPC())) { + filteredEx.add(ce); + } + } + return filteredEx.toArray(new CodeException[filteredEx.size()]); + } + + /** * implements the visitor to find throwing alternative exceptions from a catch block, without * forwarding along the original exception */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-08 06:07:56
|
Revision: 594 Author: dbrosius Date: 2006-08-07 23:07:51 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=594&view=rev Log Message: ----------- don't check synthetic methods 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 2006-08-08 05:52:47 UTC (rev 593) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-08 06:07:51 UTC (rev 594) @@ -99,6 +99,9 @@ * @return if the class throws exceptions */ public boolean prescreen(Code code, Method method) { + if (method.isSynthetic()) + return false; + CodeException[] ce = code.getExceptionTable(); if ((ce == null) || (ce.length == 0)) return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-08 06:23:25
|
Revision: 595 Author: dbrosius Date: 2006-08-07 23:23:16 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=595&view=rev Log Message: ----------- mark exceptions valid if initCause is called on them. 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 2006-08-08 06:07:51 UTC (rev 594) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-08 06:23:16 UTC (rev 595) @@ -175,7 +175,8 @@ it.remove(); break; } else if ((pc > catchInfo.getStart()) && (pc <= catchInfo.getFinish())) { - if ((seen == INVOKESPECIAL) && ("<init>".equals(getNameConstantOperand()))) { + String methodName = getNameConstantOperand(); + if ((seen == INVOKESPECIAL) && ("<init>".equals(methodName))) { String className = getClassConstantOperand(); JavaClass exClass = Repository.lookupClass(className); if (exClass.instanceOf(exceptionClass)) { @@ -186,6 +187,12 @@ break; } } + } else if ((seen == INVOKEVIRTUAL) && "initCause".equals(methodName)) { + String className = getClassConstantOperand(); + JavaClass exClass = Repository.lookupClass(className); + if (exClass.instanceOf(exceptionClass)) { + markAsValid = true; + } } else if (seen == ATHROW) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-08 06:28:31
|
Revision: 596 Author: dbrosius Date: 2006-08-07 23:28:26 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=596&view=rev Log Message: ----------- oops 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 2006-08-08 06:23:16 UTC (rev 595) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-08 06:28:26 UTC (rev 596) @@ -175,8 +175,7 @@ it.remove(); break; } else if ((pc > catchInfo.getStart()) && (pc <= catchInfo.getFinish())) { - String methodName = getNameConstantOperand(); - if ((seen == INVOKESPECIAL) && ("<init>".equals(methodName))) { + if ((seen == INVOKESPECIAL) && ("<init>".equals(getNameConstantOperand()))) { String className = getClassConstantOperand(); JavaClass exClass = Repository.lookupClass(className); if (exClass.instanceOf(exceptionClass)) { @@ -187,7 +186,7 @@ break; } } - } else if ((seen == INVOKEVIRTUAL) && "initCause".equals(methodName)) { + } else if ((seen == INVOKEVIRTUAL) && "initCause".equals(getNameConstantOperand())) { String className = getClassConstantOperand(); JavaClass exClass = Repository.lookupClass(className); if (exClass.instanceOf(exceptionClass)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-08 12:50:12
|
Revision: 597 Author: dbrosius Date: 2006-08-08 05:49:59 -0700 (Tue, 08 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=597&view=rev Log Message: ----------- base the signatures on Throwable, not Exception 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 2006-08-08 06:28:26 UTC (rev 596) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-08 12:49:59 UTC (rev 597) @@ -47,12 +47,12 @@ */ public class LostExceptionStackTrace extends BytecodeScanningDetector { - private static JavaClass exceptionClass; + private static JavaClass throwableClass; static { try { - exceptionClass = Repository.lookupClass("java/lang/Exception"); + throwableClass = Repository.lookupClass("java/lang/Throwable"); } catch (ClassNotFoundException cnfe) { - exceptionClass = null; + throwableClass = null; } } @@ -79,7 +79,7 @@ public void visitClassContext(ClassContext classContext) { try { int majorVersion = classContext.getJavaClass().getMajor(); - if ((exceptionClass != null) && (majorVersion >= Constants.MAJOR_1_4)) { + if ((throwableClass != null) && (majorVersion >= Constants.MAJOR_1_4)) { stack = new OpcodeStack(); catchInfos = new HashSet<CatchInfo>(); super.visitClassContext(classContext); @@ -178,7 +178,7 @@ if ((seen == INVOKESPECIAL) && ("<init>".equals(getNameConstantOperand()))) { String className = getClassConstantOperand(); JavaClass exClass = Repository.lookupClass(className); - if (exClass.instanceOf(exceptionClass)) { + if (exClass.instanceOf(throwableClass)) { String sig = getSigConstantOperand(); if ((sig.indexOf("Exception") >= 0) || (sig.indexOf("Throwable") >= 0)) { @@ -189,7 +189,7 @@ } else if ((seen == INVOKEVIRTUAL) && "initCause".equals(getNameConstantOperand())) { String className = getClassConstantOperand(); JavaClass exClass = Repository.lookupClass(className); - if (exClass.instanceOf(exceptionClass)) { + if (exClass.instanceOf(throwableClass)) { markAsValid = true; } } else if (seen == ATHROW) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-12 02:33:31
|
Revision: 609 Author: dbrosius Date: 2006-08-11 19:33:27 -0700 (Fri, 11 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=609&view=rev Log Message: ----------- it is difficult to determine where a catch block ends, when the last instruction of the try is a return. As a start, if a store to the catch exception occurs, after the first one, assume the catch has stopped. 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 2006-08-12 01:15:27 UTC (rev 608) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-12 02:33:27 UTC (rev 609) @@ -223,7 +223,11 @@ } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); - exReg.put(Integer14.valueOf(RegisterUtils.getAStoreReg(this, seen)), (Boolean)itm.getUserValue()); + int reg = RegisterUtils.getAStoreReg(this, seen); + exReg.put(Integer14.valueOf(reg), (Boolean)itm.getUserValue()); + if ((reg == catchInfo.getRegister() && catchInfo.getFinish() == Integer.MAX_VALUE)) { + it.remove(); + } } } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { Boolean valid = exReg.get(Integer14.valueOf(RegisterUtils.getALoadReg(this, seen))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-14 05:00:45
|
Revision: 614 Author: dbrosius Date: 2006-08-13 22:00:38 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=614&view=rev Log Message: ----------- if the localvariabletable attribute exists, use the lifetime of the catch exception variable as a determiner of when the catch block ends. 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 2006-08-12 17:18:40 UTC (rev 613) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-14 05:00:38 UTC (rev 614) @@ -32,6 +32,8 @@ import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.CodeException; import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.LocalVariable; +import org.apache.bcel.classfile.LocalVariableTable; import org.apache.bcel.classfile.Method; import com.mebigfatguy.fbcontrib.utils.Integer14; @@ -178,6 +180,13 @@ int reg = RegisterUtils.getAStoreReg(this, seen); catchInfo.setReg(reg); exReg.put(Integer14.valueOf(reg), Boolean.TRUE); + LocalVariableTable lvt = getMethod().getLocalVariableTable(); + if (lvt != null) { + LocalVariable lv = lvt.getLocalVariable(reg, pc); + int finish = lv.getStartPC() + lv.getLength(); + if (finish < catchInfo.getFinish()) + catchInfo.setFinish(finish); + } break; } } else if (pc > catchInfo.getFinish()) { @@ -280,6 +289,10 @@ return catchFinish; } + public void setFinish(int finish) { + catchFinish = finish; + } + public int getRegister() { return exReg; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-14 05:07:12
|
Revision: 615 Author: dbrosius Date: 2006-08-13 22:07:07 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=615&view=rev Log Message: ----------- guard against npes 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 2006-08-14 05:00:38 UTC (rev 614) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-14 05:07:07 UTC (rev 615) @@ -183,9 +183,11 @@ LocalVariableTable lvt = getMethod().getLocalVariableTable(); if (lvt != null) { LocalVariable lv = lvt.getLocalVariable(reg, pc); - int finish = lv.getStartPC() + lv.getLength(); - if (finish < catchInfo.getFinish()) - catchInfo.setFinish(finish); + if (lv != null) { + int finish = lv.getStartPC() + lv.getLength(); + if (finish < catchInfo.getFinish()) + catchInfo.setFinish(finish); + } } break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-14 22:37:12
|
Revision: 616 Author: dbrosius Date: 2006-08-14 15:37:05 -0700 (Mon, 14 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=616&view=rev Log Message: ----------- javac doesn't consider the exception's original astore to be part of the variable's scope, so when looking for the variable finish, use pc + 1. 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 2006-08-14 05:07:07 UTC (rev 615) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-14 22:37:05 UTC (rev 616) @@ -182,7 +182,7 @@ exReg.put(Integer14.valueOf(reg), Boolean.TRUE); LocalVariableTable lvt = getMethod().getLocalVariableTable(); if (lvt != null) { - LocalVariable lv = lvt.getLocalVariable(reg, pc); + LocalVariable lv = lvt.getLocalVariable(reg, pc+1); if (lv != null) { int finish = lv.getStartPC() + lv.getLength(); if (finish < catchInfo.getFinish()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-15 03:15:43
|
Revision: 617 Author: dbrosius Date: 2006-08-14 20:15:39 -0700 (Mon, 14 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=617&view=rev Log Message: ----------- look for catch variable range end, by looking at pc+2 when entering the catch block to account for ASTORE 5, like operations, not just ASTORE_3. 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 2006-08-14 22:37:05 UTC (rev 616) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-15 03:15:39 UTC (rev 617) @@ -182,7 +182,7 @@ exReg.put(Integer14.valueOf(reg), Boolean.TRUE); LocalVariableTable lvt = getMethod().getLocalVariableTable(); if (lvt != null) { - LocalVariable lv = lvt.getLocalVariable(reg, pc+1); + LocalVariable lv = lvt.getLocalVariable(reg, pc+2); if (lv != null) { int finish = lv.getStartPC() + lv.getLength(); if (finish < catchInfo.getFinish()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-16 04:21:30
|
Revision: 618 Author: dbrosius Date: 2006-08-15 21:21:25 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=618&view=rev Log Message: ----------- the last statement of a try block doesn't have to be a return, or a goto, if there is a finally block. 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 2006-08-15 03:15:39 UTC (rev 617) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-16 04:21:25 UTC (rev 618) @@ -163,10 +163,12 @@ int pc = getPC(); for (CodeException ex : exceptions) { if (pc == ex.getEndPC()) { - if ((seen >= IRETURN) && (seen <= RETURN)) { + if ((seen >= IRETURN) && (seen <= RETURN)) addCatchBlock(ex.getHandlerPC(), Integer.MAX_VALUE); - } else if ((seen == GOTO) || (seen == GOTO_W)) + else if ((seen == GOTO) || (seen == GOTO_W)) addCatchBlock(ex.getHandlerPC(), this.getBranchTarget()); + else + addCatchBlock(ex.getHandlerPC(), Integer.MAX_VALUE); return; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |