From: chiba Date: Tue, 11 Mar 2008 10:42:47 +0000 (+0000) Subject: fixed JASSIST-51 X-Git-Tag: rel_3_17_1_ga~219 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0904c66e3cbc678e3648eeec303cd5478e70beb9;p=javassist.git fixed JASSIST-51 git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@424 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- diff --git a/src/main/javassist/expr/NewExpr.java b/src/main/javassist/expr/NewExpr.java index f52c67ae..353e32cd 100644 --- a/src/main/javassist/expr/NewExpr.java +++ b/src/main/javassist/expr/NewExpr.java @@ -168,7 +168,8 @@ public class NewExpr extends Expr { /* delete the preceding NEW and DUP (or DUP_X1, SWAP) instructions. */ - int end = pos + canReplace(); + int codeSize = canReplace(); + int end = pos + codeSize; for (int i = pos; i < end; ++i) iterator.writeByte(NOP, i); @@ -203,7 +204,8 @@ public class NewExpr extends Expr { bytecode.addStore(retVar, newType); // initialize $_ jc.compileStmnt(statement); - bytecode.addAload(retVar); + if (codeSize > 3) // if the original code includes DUP. + bytecode.addAload(retVar); replace0(pos, bytecode, bytecodeSize); }