summaryrefslogtreecommitdiffstats
path: root/src/main/javassist/bytecode/stackmap/MapMaker.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/javassist/bytecode/stackmap/MapMaker.java')
-rw-r--r--src/main/javassist/bytecode/stackmap/MapMaker.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/javassist/bytecode/stackmap/MapMaker.java b/src/main/javassist/bytecode/stackmap/MapMaker.java
index e0aa5dac..16d3f294 100644
--- a/src/main/javassist/bytecode/stackmap/MapMaker.java
+++ b/src/main/javassist/bytecode/stackmap/MapMaker.java
@@ -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
/*