From 0ed1ede707440a9a981c2e0cfd5421b0ba0e364d Mon Sep 17 00:00:00 2001 From: chiba Date: Sun, 18 May 2003 15:34:30 +0000 Subject: fixed a bug in CtBehavior#setBody(). git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@19 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- src/main/javassist/compiler/CodeGen.java | 24 ++++++++++++------------ src/main/javassist/compiler/Javac.java | 2 ++ 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src/main/javassist') diff --git a/src/main/javassist/compiler/CodeGen.java b/src/main/javassist/compiler/CodeGen.java index e0b2dfa4..35ca2605 100644 --- a/src/main/javassist/compiler/CodeGen.java +++ b/src/main/javassist/compiler/CodeGen.java @@ -267,18 +267,18 @@ public abstract class CodeGen extends Visitor implements Opcode, TokenId { } } - private boolean needsSuperCall(Stmnt body) { - if (body.getOperator() == BLOCK) { - Stmnt first = (Stmnt)body.head(); - if (first != null && first.getOperator() == EXPR) { - ASTree expr = first.head(); - if (expr != null && expr instanceof Expr - && ((Expr)expr).getOperator() == CALL) { - ASTree target = ((Expr)expr).head(); - if (target instanceof Keyword) { - int token = ((Keyword)target).get(); - return token != THIS && token != SUPER; - } + private boolean needsSuperCall(Stmnt body) throws CompileError { + if (body.getOperator() == BLOCK) + body = (Stmnt)body.head(); + + if (body != null && body.getOperator() == EXPR) { + ASTree expr = body.head(); + if (expr != null && expr instanceof Expr + && ((Expr)expr).getOperator() == CALL) { + ASTree target = ((Expr)expr).head(); + if (target instanceof Keyword) { + int token = ((Keyword)target).get(); + return token != THIS && token != SUPER; } } } diff --git a/src/main/javassist/compiler/Javac.java b/src/main/javassist/compiler/Javac.java index 9ff801ef..de322cdf 100644 --- a/src/main/javassist/compiler/Javac.java +++ b/src/main/javassist/compiler/Javac.java @@ -170,6 +170,8 @@ public class Javac { /** * Compiles a method (or constructor) body. + * + * @src a single statement or a block. */ public Bytecode compileBody(CtBehavior method, String src) throws CompileError -- cgit v1.2.3