From: chiba Date: Tue, 9 Jun 2009 08:50:06 +0000 (+0000) Subject: fixed JIRA JASSIST-83 X-Git-Tag: rel_3_17_1_ga~168 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ebd545653c4c1d36009db5e6616afede3b65f1c2;p=javassist.git fixed JIRA JASSIST-83 git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@479 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- diff --git a/src/main/javassist/bytecode/ExceptionTable.java b/src/main/javassist/bytecode/ExceptionTable.java index b24bd04b..1c74e6e0 100644 --- a/src/main/javassist/bytecode/ExceptionTable.java +++ b/src/main/javassist/bytecode/ExceptionTable.java @@ -153,6 +153,8 @@ public class ExceptionTable implements Cloneable { * Returns catchType of the n-th entry. * * @param nth the n-th (>= 0). + * @return an index into the constant_pool table, + * or zero if this exception handler is for all exceptions. */ public int catchType(int nth) { ExceptionTableEntry e = (ExceptionTableEntry)entries.get(nth); diff --git a/src/main/javassist/expr/Handler.java b/src/main/javassist/expr/Handler.java index 6f8c44cf..5bed0924 100644 --- a/src/main/javassist/expr/Handler.java +++ b/src/main/javassist/expr/Handler.java @@ -20,7 +20,7 @@ import javassist.bytecode.*; import javassist.compiler.*; /** - * Catch clause. + * A catch clause or a finally block. */ public class Handler extends Expr { private static String EXCEPTION_NAME = "$1"; @@ -69,11 +69,24 @@ public class Handler extends Expr { /** * Returns the type handled by the catch clause. + * If this is a finally block, null is returned. */ public CtClass getType() throws NotFoundException { - ConstPool cp = getConstPool(); - String name = cp.getClassInfo(etable.catchType(index)); - return thisClass.getClassPool().getCtClass(name); + int type = etable.catchType(index); + if (type == 0) + return null; + else { + ConstPool cp = getConstPool(); + String name = cp.getClassInfo(type); + return thisClass.getClassPool().getCtClass(name); + } + } + + /** + * Returns true if this is a finally block. + */ + public boolean isFinally() { + return etable.catchType(index) == 0; } /**