Browse Source

fixed JASSIST-211

tags/rel_3_19_0_ga
chibash 10 years ago
parent
commit
c135f69c8b
3 changed files with 20 additions and 2 deletions
  1. 1
    1
      Readme.html
  2. 1
    1
      src/main/javassist/compiler/CodeGen.java
  3. 18
    0
      src/test/javassist/JvstTest4.java

+ 1
- 1
Readme.html View File

@@ -283,7 +283,7 @@ see javassist.Dump.

<p>-version 3.19
<ul>
<li>JIRA JASSIST-158, 205, 206, 207, 212, 216.
<li>JIRA JASSIST-158, 205, 206, 207, 211, 212, 216.
</ul>
</p>


+ 1
- 1
src/main/javassist/compiler/CodeGen.java View File

@@ -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());

+ 18
- 0
src/test/javassist/JvstTest4.java View File

@@ -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());
}
}

Loading…
Cancel
Save