Browse Source

fixed JASSIST-195

tags/log
chibash 11 years ago
parent
commit
29a580826f

+ 1
- 1
Readme.html View File

@@ -285,7 +285,7 @@ see javassist.Dump.
<ul>
<li>The source code repository has been moved to <a href="https://github.com/jboss-javassist/javassist">GitHub</a></li>.

<li>JIRA JASSIST-181, 183, 184, 189, 162, 185, 186, 190.
<li>JIRA JASSIST-181, 183, 184, 189, 162, 185, 186, 190, 199.
</ul>

<p>-version 3.17.1 on December 3, 2012

+ 27
- 0
src/main/javassist/bytecode/stackmap/MapMaker.java View File

@@ -162,6 +162,7 @@ public class MapMaker extends Tracer {
throws BadBytecode
{
make(code, blocks[0]);
findDeadCatchers(code, blocks);
try {
fixTypes(code, blocks);
} catch (NotFoundException e) {
@@ -303,6 +304,32 @@ public class MapMaker extends Tracer {
destTypes[i] = srcTypes[i];
}

// Phase 1.5

/*
* Javac may generate an exception handler that catches only an exception
* thrown within the handler itself. It is dead code.
*/

private void findDeadCatchers(byte[] code, TypedBlock[] blocks) throws BadBytecode {
int len = blocks.length;
for (int i = 0; i < len; i++) {
TypedBlock block = blocks[i];
if (block.localsTypes == null) { // if block is dead code
BasicBlock.Catch handler = block.toCatch;
while (handler != null)
if (handler.body == block) {
BasicBlock.Catch handler2
= new BasicBlock.Catch(block, handler.typeIndex, null);
traceException(code, handler2);
break;
}
else
handler = handler.next;
}
}
}

// Phase 2

/*

+ 9
- 3
src/test/javassist/JvstTest4.java View File

@@ -866,7 +866,13 @@ public class JvstTest4 extends JvstTestRoot {
String s2 = field2.getAnnotation(test4.JIRA181.Condition2.class).toString();
assertEquals("@test4.JIRA181$Condition2(condition=test4.JIRA181<T>.B[].class)", s2);
}
}



public void testJIRA195() throws Exception {
CtClass cc = sloader.get("test4.JIRA195");
CtMethod mth = cc.getDeclaredMethod("test");
mth.getMethodInfo().rebuildStackMap(cc.getClassPool());
cc.writeFile();
Object obj = make(cc.getName());
assertEquals(4, invoke(obj, "run"));
}
}

Loading…
Cancel
Save