]> source.dussan.org Git - javassist.git/commitdiff
fixed JASSIST-190
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Sat, 13 Apr 2013 17:27:52 +0000 (17:27 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Sat, 13 Apr 2013 17:27:52 +0000 (17:27 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@703 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

Readme.html
javassist.jar
src/main/javassist/bytecode/stackmap/MapMaker.java
src/test/javassist/JvstTest4.java
src/test/test4/JIRA186.java [new file with mode: 0644]
src/test/test4/MultiCatch.java [new file with mode: 0644]

index a96638e81f398bc7d1994eb233df270d09f0ea2b..a123d0f5246adab9660c95494d151b7526f75ab6 100644 (file)
@@ -283,12 +283,12 @@ see javassist.Dump.
 
 <p>-version 3.18
 <ul>
-JIRA JASSIST-183, 189, 162. 
+JIRA JASSIST-183, 184, 189, 162, 186, 190.
 </ul>
 
 <p>-version 3.17.1 on December 3, 2012
 <ul>
-       <li>JIRA JASSIST-177, 178, 182
+       <li>JIRA JASSIST-177, 178, 182.
 </ul>
 
 
index 5f207309f69a5800233c02cf8b233c5c12c67dc5..8ff2f083bf755b15aaa4201954d079fcef46dd92 100644 (file)
Binary files a/javassist.jar and b/javassist.jar differ
index 9777ca2004fcc27828f539687c9737b03e233c23..e0aa5dac0ba960b38c72d63c4b87749fe5c236ff 100644 (file)
@@ -18,6 +18,7 @@ package javassist.bytecode.stackmap;
 
 import java.util.ArrayList;
 import javassist.ClassPool;
+import javassist.CtClass;
 import javassist.NotFoundException;
 import javassist.bytecode.*;
 
@@ -205,8 +206,14 @@ public class MapMaker extends Tracer {
     {
         while (handler != null) {
             TypedBlock tb = (TypedBlock)handler.body;
-            if (tb.alreadySet())
+            if (tb.alreadySet()) {
                 mergeMap(tb, false);
+                if (tb.stackTop < 1)
+                    throw new BadBytecode("bad catch clause: " + handler.typeIndex);
+
+                tb.stackTypes[0] = merge(toExceptionType(handler.typeIndex),
+                                         tb.stackTypes[0]);
+            }
             else {
                 recordStackMap(tb, handler.typeIndex);
                 MapMaker maker = new MapMaker(this);
@@ -256,14 +263,18 @@ public class MapMaker extends Tracer {
         throws BadBytecode
     {
         TypeData[] tStackTypes = TypeData.make(stackTypes.length);
+        tStackTypes[0] = toExceptionType(exceptionType).join();
+        recordStackMap0(target, 1, tStackTypes);
+    }
+
+    private TypeData.ClassName toExceptionType(int exceptionType) {
         String type;
         if (exceptionType == 0)     // for finally clauses
-            type = "java.lang.Throwable";
+            type= "java.lang.Throwable";
         else
             type = cpool.getClassInfo(exceptionType);
 
-        tStackTypes[0] = new TypeData.ClassName(type);
-        recordStackMap0(target, 1, tStackTypes);
+        return new TypeData.ClassName(type);
     }
 
     private void recordStackMap0(TypedBlock target, int st, TypeData[] tStackTypes)
index 768b740045dd3df98823f3ed881f45e2e0817cfb..7692d5bcb30fc71509d723ba5b4178bba8d6ee26 100644 (file)
@@ -828,4 +828,14 @@ public class JvstTest4 extends JvstTestRoot {
         Object obj = make(cc.getName());
         assertEquals(1, invoke(obj, "test"));
     }
+
+    // JASSIST-190
+    public void testMultipleCatch() throws Exception {
+        CtClass cc = sloader.get("test4.MultiCatch");
+        CtMethod m1 = cc.getDeclaredMethod("m1");
+        m1.insertAfter("print();");
+        cc.writeFile();
+        Object obj = make(cc.getName());
+        assertEquals(12, invoke(obj, "test1"));
+    }
 }
diff --git a/src/test/test4/JIRA186.java b/src/test/test4/JIRA186.java
new file mode 100644 (file)
index 0000000..41935a7
--- /dev/null
@@ -0,0 +1,7 @@
+package test4;
+
+public class JIRA186 {
+       public int test() {
+               return 1;
+       }
+}
diff --git a/src/test/test4/MultiCatch.java b/src/test/test4/MultiCatch.java
new file mode 100644 (file)
index 0000000..142e324
--- /dev/null
@@ -0,0 +1,23 @@
+package test4;
+
+public class MultiCatch {
+    public void print() { System.out.println("MultiCatch"); }
+    public int test1() { return m1(1); }
+    public int m1(int i) {
+        // Java 7 syntax
+        try {
+            return foo(i);
+        }
+        catch (java.io.IOException | NullPointerException e) {
+            return e.getMessage().length();
+        }
+    }
+    public int foo(int i) throws java.io.IOException {
+        if (i < 0)
+            throw new java.io.IOException("negative");
+        else if (i < 10)
+            throw new NullPointerException("less than 10");
+        else
+            return i;
+    }
+}