]> source.dussan.org Git - javassist.git/commitdiff
fixed JASSIST-51
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Tue, 11 Mar 2008 10:42:47 +0000 (10:42 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Tue, 11 Mar 2008 10:42:47 +0000 (10:42 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@424 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

src/main/javassist/expr/NewExpr.java

index f52c67ae9a7c70c545ea7a90c5ef8b80d3031734..353e32cd6aa24e60fdbd3a3fdc312b6a57a70dee 100644 (file)
@@ -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);
         }