summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2008-03-11 10:42:47 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2008-03-11 10:42:47 +0000
commit0904c66e3cbc678e3648eeec303cd5478e70beb9 (patch)
tree6caffcc8e2f6288ee849e60408fa7a9221c61764
parent1c59c2e7f6cef3e7389cae2746962db2fa65c620 (diff)
downloadjavassist-0904c66e3cbc678e3648eeec303cd5478e70beb9.tar.gz
javassist-0904c66e3cbc678e3648eeec303cd5478e70beb9.zip
fixed JASSIST-51
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@424 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r--src/main/javassist/expr/NewExpr.java6
1 files changed, 4 insertions, 2 deletions
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);
}