From: chiba Date: Sun, 17 Aug 2003 13:59:49 +0000 (+0000) Subject: fixed a bug in the compiler, which could not compile a try statement X-Git-Tag: rel_3_17_1_ga~574 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=421e4885eb233dc616bed0b48eec678f5f0d41c4;p=javassist.git fixed a bug in the compiler, which could not compile a try statement correctly. git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@33 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- diff --git a/Readme.html b/Readme.html index 9aaf4bae..9ca4eb51 100644 --- a/Readme.html +++ b/Readme.html @@ -244,6 +244,7 @@ see javassist.Dump.
  • javassist.expr.Expr.indexOfBytecode() has been added.
  • javassist.Loader has been modified so that getPackage() returns a package object. +
  • Now, the compiler can correctly compile a try statement.

    - version 2.5.1 in May, 2003. @@ -505,8 +506,8 @@ Marc Segura-Devillechaise, Jan Baudisch, Julien Blass, Yoshiki Sato, Fabian Crabus, Bo Norregaard Jorgensen, Bob Lee, Bill Burke, Remy Sanlaville, Muga Nishizawa, Alexey Loubyansky, Saori Oki, Andreas Salathe, Dante Torres estrada, S. Pam, Nuno Santos, -Denis Taye, Colin Sampaleanu, Robert Bialek, and Asato Shimotaki -for their contributions. +Denis Taye, Colin Sampaleanu, Robert Bialek, Asato Shimotaki, +and Howard Lewis Ship for their contributions.


    diff --git a/src/main/javassist/ClassPool.java b/src/main/javassist/ClassPool.java index 07a442ef..e07826f7 100644 --- a/src/main/javassist/ClassPool.java +++ b/src/main/javassist/ClassPool.java @@ -372,9 +372,9 @@ public class ClassPool { /** * Returns a java.lang.Class object that has been loaded - * by writeAsClass(). Note that such an object cannot be + * by writeAsClass(). That object cannot be * obtained by java.lang.Class.forName() because it has - * been loaded by an internal class loader. + * been loaded by an internal class loader of Javassist. * * @see #writeAsClass(String) * @see javassist.CtClass#toClass() diff --git a/src/main/javassist/compiler/MemberCodeGen.java b/src/main/javassist/compiler/MemberCodeGen.java index 97a12341..612b6641 100644 --- a/src/main/javassist/compiler/MemberCodeGen.java +++ b/src/main/javassist/compiler/MemberCodeGen.java @@ -72,6 +72,8 @@ public class MemberCodeGen extends CodeGen { int start = bytecode.currentPc(); body.accept(this); int end = bytecode.currentPc(); + if (start == end) + throw new CompileError("empty try block"); bytecode.addOpcode(Opcode.GOTO); int pc = bytecode.currentPc(); @@ -92,10 +94,10 @@ public class MemberCodeGen extends CodeGen { decl.setClassName(javaToJvmName(type.getName())); bytecode.addExceptionHandler(start, end, bytecode.currentPc(), type); - if (block != null) { - bytecode.addAstore(var); + bytecode.growStack(1); + bytecode.addAstore(var); + if (block != null) block.accept(this); - } bytecode.addOpcode(Opcode.GOTO); bytecode.addIndex(pc - bytecode.currentPc());