[jboss-cvs] javassist SVN: r703 - in trunk: src/main/javassist/bytecode/stackmap and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Apr 13 13:27:53 EDT 2013


Author: chiba
Date: 2013-04-13 13:27:52 -0400 (Sat, 13 Apr 2013)
New Revision: 703

Added:
   trunk/src/test/test4/JIRA186.java
   trunk/src/test/test4/MultiCatch.java
Modified:
   trunk/Readme.html
   trunk/javassist.jar
   trunk/src/main/javassist/bytecode/stackmap/MapMaker.java
   trunk/src/test/javassist/JvstTest4.java
Log:
fixed JASSIST-190

Modified: trunk/Readme.html
===================================================================
--- trunk/Readme.html	2013-04-12 09:21:45 UTC (rev 702)
+++ trunk/Readme.html	2013-04-13 17:27:52 UTC (rev 703)
@@ -283,12 +283,12 @@
 
 <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>
 
 

Modified: trunk/javassist.jar
===================================================================
(Binary files differ)

Modified: trunk/src/main/javassist/bytecode/stackmap/MapMaker.java
===================================================================
--- trunk/src/main/javassist/bytecode/stackmap/MapMaker.java	2013-04-12 09:21:45 UTC (rev 702)
+++ trunk/src/main/javassist/bytecode/stackmap/MapMaker.java	2013-04-13 17:27:52 UTC (rev 703)
@@ -18,6 +18,7 @@
 
 import java.util.ArrayList;
 import javassist.ClassPool;
+import javassist.CtClass;
 import javassist.NotFoundException;
 import javassist.bytecode.*;
 
@@ -205,8 +206,14 @@
     {
         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 @@
         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)

Modified: trunk/src/test/javassist/JvstTest4.java
===================================================================
--- trunk/src/test/javassist/JvstTest4.java	2013-04-12 09:21:45 UTC (rev 702)
+++ trunk/src/test/javassist/JvstTest4.java	2013-04-13 17:27:52 UTC (rev 703)
@@ -828,4 +828,14 @@
         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"));
+    }
 }

Added: trunk/src/test/test4/JIRA186.java
===================================================================
--- trunk/src/test/test4/JIRA186.java	                        (rev 0)
+++ trunk/src/test/test4/JIRA186.java	2013-04-13 17:27:52 UTC (rev 703)
@@ -0,0 +1,7 @@
+package test4;
+
+public class JIRA186 {
+	public int test() {
+		return 1;
+	}
+}


Property changes on: trunk/src/test/test4/JIRA186.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/src/test/test4/MultiCatch.java
===================================================================
--- trunk/src/test/test4/MultiCatch.java	                        (rev 0)
+++ trunk/src/test/test4/MultiCatch.java	2013-04-13 17:27:52 UTC (rev 703)
@@ -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;
+    }
+}


Property changes on: trunk/src/test/test4/MultiCatch.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain



More information about the jboss-cvs-commits mailing list