From: chibash Date: Mon, 2 Dec 2013 11:05:24 +0000 (+0900) Subject: fixed JASSIST-211 X-Git-Tag: rel_3_19_0_ga~33 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c135f69c8b4d6f64ce22ade1fa9f76c614bb280e;p=javassist.git fixed JASSIST-211 --- diff --git a/Readme.html b/Readme.html index 290d2097..4c5288be 100644 --- a/Readme.html +++ b/Readme.html @@ -283,7 +283,7 @@ see javassist.Dump.

-version 3.19

diff --git a/src/main/javassist/compiler/CodeGen.java b/src/main/javassist/compiler/CodeGen.java index bf61a2b1..bbcce895 100644 --- a/src/main/javassist/compiler/CodeGen.java +++ b/src/main/javassist/compiler/CodeGen.java @@ -434,7 +434,7 @@ public abstract class CodeGen extends Visitor implements Opcode, TokenId { if (notDo) bytecode.write16bit(pc, pc3 - pc + 1); - boolean alwaysBranch = compileBooleanExpr(true, expr); + boolean alwaysBranch = compileBooleanExpr(true, expr) && breakList.size() == 0; bytecode.addIndex(pc2 - bytecode.currentPc() + 1); patchGoto(breakList, bytecode.currentPc()); diff --git a/src/test/javassist/JvstTest4.java b/src/test/javassist/JvstTest4.java index df4533bb..f1aca09e 100644 --- a/src/test/javassist/JvstTest4.java +++ b/src/test/javassist/JvstTest4.java @@ -938,4 +938,22 @@ public class JvstTest4 extends JvstTestRoot { cc.writeFile(); Object obj = make(cc.getName()); } + + public void testWhileTrueKO() throws Exception { + final ClassPool pool = ClassPool.getDefault(); + final CtClass cc = pool.makeClass("test4.TestWhileTrueKO"); + String source = "public void testWhile() { while(true) { break; } }"; + cc.addMethod(CtMethod.make(source, cc)); + cc.writeFile(); + make(cc.getName()); + } + + public void testWhileTrueOK() throws Exception { + final ClassPool pool = ClassPool.getDefault(); + final CtClass cc = pool.makeClass("test4.TestWhileTrueOK"); + String source = "public void testWhile() { while(0==0) { break; }}"; + cc.addMethod(CtMethod.make(source, cc)); + cc.writeFile(); + make(cc.getName()); + } }