From bf5722a70048db339334b23793465c299922785b Mon Sep 17 00:00:00 2001 From: chibash Date: Mon, 2 Dec 2013 12:29:03 +0900 Subject: [PATCH] fixed JASSIST-216 --- Readme.html | 2 +- .../bytecode/analysis/ControlFlow.java | 8 ++++++- .../bytecode/analysis/DomTreeTest.java | 21 +++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Readme.html b/Readme.html index 31d55fa2..5066e134 100644 --- a/Readme.html +++ b/Readme.html @@ -283,7 +283,7 @@ see javassist.Dump.

-version 3.19

diff --git a/src/main/javassist/bytecode/analysis/ControlFlow.java b/src/main/javassist/bytecode/analysis/ControlFlow.java index 0560be6b..736299cb 100644 --- a/src/main/javassist/bytecode/analysis/ControlFlow.java +++ b/src/main/javassist/bytecode/analysis/ControlFlow.java @@ -86,6 +86,12 @@ public class ControlFlow { Block e = b.exit(k); e.entrances[counters[e.index]++] = b; } + + ControlFlow.Catcher[] catchers = b.catchers(); + for (int k = 0; k < catchers.length; k++) { + Block catchBlock = catchers[k].node; + catchBlock.entrances[counters[catchBlock.index]++] = b; + } } } @@ -245,7 +251,7 @@ public class ControlFlow { super.toString2(sbuf); sbuf.append(", incoming{"); for (int i = 0; i < entrances.length; i++) - sbuf.append(entrances[i].position).append(", "); + sbuf.append(entrances[i].position).append(", "); sbuf.append("}"); } diff --git a/src/test/test/javassist/bytecode/analysis/DomTreeTest.java b/src/test/test/javassist/bytecode/analysis/DomTreeTest.java index 4e277e8f..7ea54b80 100644 --- a/src/test/test/javassist/bytecode/analysis/DomTreeTest.java +++ b/src/test/test/javassist/bytecode/analysis/DomTreeTest.java @@ -89,4 +89,25 @@ public class DomTreeTest extends TestCase { return i + 3; } + + public void testDomtree3() throws Exception { + ControlFlow cf = new ControlFlow(pool.get(DomTreeTest.class.getName()).getDeclaredMethod("test3")); + Block[] blocks = cf.basicBlocks(); + for (int i = 0; i < blocks.length; i++) + System.out.println(blocks[i]); + } + + public int test3(int i, int j) { + while (i > 0) { + try { + j++; + } + catch (Throwable t) { + j = 0; + } + i--; + } + + return j; + } } -- 2.39.5