From c979ae5d3e5a950971f801245fbdaae3796f6cc5 Mon Sep 17 00:00:00 2001
From: Paul Stadig <paul@stadig.name>
Date: Thu, 1 Mar 2012 18:43:51 +0000
Subject: [PATCH 1/5] Move compilation of Clojure test source to the right phase.

It was getting compiled before the Java test code was getting compiled.
---
 pom.xml |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pom.xml b/pom.xml
index ae7dd17..6800955 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,7 +78,7 @@
 	  </execution>
 	  <execution>
 	    <id>clojure-test</id>
-	    <phase>compile</phase>
+	    <phase>test</phase>
 	    <goals>
 	      <goal>run</goal>
 	    </goals>
-- 
1.7.1


From 2a7e609c29f940f0b51ed8eb85829a5262d72a03 Mon Sep 17 00:00:00 2001
From: Paul Stadig <paul@stadig.name>
Date: Thu, 1 Mar 2012 18:44:06 +0000
Subject: [PATCH 2/5] Compile Java test source in the ant build.

---
 build.xml |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/build.xml b/build.xml
index 5b61139..1075c9b 100644
--- a/build.xml
+++ b/build.xml
@@ -78,10 +78,9 @@
   <target name="compile-tests" 
           description="Compile the subset of tests that require compilation."
           unless="maven.test.skip">
-    <delete dir="${test-classes}"/>
     <mkdir dir="${test-classes}"/>
-    <!-- <javac srcdir="${jtestsrc}" destdir="${test-classes}" includeJavaRuntime="yes" -->
-    <!--        debug="true" source="1.5" target="1.5" includeantruntime="no"/> -->
+    <javac srcdir="${jtestsrc}" destdir="${test-classes}" includeJavaRuntime="yes"
+           debug="true" source="1.5" target="1.5" includeantruntime="no"/>
     <java classname="clojure.lang.Compile"
           classpath="${test-classes}:${test}:${build}:${cljsrc}"
           failonerror="true"
-- 
1.7.1


From dd4c503e8fc9dd21962458c89663484ff1e01008 Mon Sep 17 00:00:00 2001
From: Paul Stadig <paul@stadig.name>
Date: Thu, 1 Mar 2012 18:44:35 +0000
Subject: [PATCH 3/5] Move ReflectorTryCatchFixture to the test directory.

It was getting packaged up in the jar.
---
 src/jvm/clojure/test/ReflectorTryCatchFixture.java |   17 -----------------
 .../clojure/test/ReflectorTryCatchFixture.java     |   17 +++++++++++++++++
 2 files changed, 17 insertions(+), 17 deletions(-)
 delete mode 100644 src/jvm/clojure/test/ReflectorTryCatchFixture.java
 create mode 100644 test/java/clojure/test/ReflectorTryCatchFixture.java

diff --git a/src/jvm/clojure/test/ReflectorTryCatchFixture.java b/src/jvm/clojure/test/ReflectorTryCatchFixture.java
deleted file mode 100644
index 9256559..0000000
--- a/src/jvm/clojure/test/ReflectorTryCatchFixture.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package clojure.test;
-
-public class ReflectorTryCatchFixture {
-
-	public static void fail(Long x) throws Cookies {
-		throw new Cookies("Long");
-	}
-	
-	public static void fail(Double y) throws Cookies {
-		throw new Cookies("Double");
-	}
-	
-	public static class Cookies extends Exception {
-		public Cookies(String msg) { super(msg); }
-	}
-
-}
diff --git a/test/java/clojure/test/ReflectorTryCatchFixture.java b/test/java/clojure/test/ReflectorTryCatchFixture.java
new file mode 100644
index 0000000..9256559
--- /dev/null
+++ b/test/java/clojure/test/ReflectorTryCatchFixture.java
@@ -0,0 +1,17 @@
+package clojure.test;
+
+public class ReflectorTryCatchFixture {
+
+	public static void fail(Long x) throws Cookies {
+		throw new Cookies("Long");
+	}
+	
+	public static void fail(Double y) throws Cookies {
+		throw new Cookies("Double");
+	}
+	
+	public static class Cookies extends Exception {
+		public Cookies(String msg) { super(msg); }
+	}
+
+}
-- 
1.7.1


From ec13ef35d920092b8bbbab0cdc5ee127dbad0881 Mon Sep 17 00:00:00 2001
From: Paul Stadig <paul@stadig.name>
Date: Thu, 1 Mar 2012 23:19:19 +0000
Subject: [PATCH 4/5] Add test for extra unwrapping.

---
 test/clojure/test_clojure/try_catch.clj            |    8 ++++++--
 .../clojure/test/ReflectorTryCatchFixture.java     |    5 +++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/test/clojure/test_clojure/try_catch.clj b/test/clojure/test_clojure/try_catch.clj
index 328495a..d907d50 100755
--- a/test/clojure/test_clojure/try_catch.clj
+++ b/test/clojure/test_clojure/try_catch.clj
@@ -29,7 +29,11 @@
 (defn fail [x]
   (ReflectorTryCatchFixture/fail x))
 
+(defn make-instance []
+  (ReflectorTryCatchFixture.))
+
 (deftest catch-receives-checked-exception-from-reflective-call
   (is (thrown-with-msg? ReflectorTryCatchFixture$Cookies #"Long" (fail 1)))
-  (is (thrown-with-msg? ReflectorTryCatchFixture$Cookies #"Double" (fail 1.0))))
-    
+  (is (thrown-with-msg? ReflectorTryCatchFixture$Cookies #"Double" (fail 1.0)))
+  (is (thrown-with-msg? ReflectorTryCatchFixture$Cookies #"Wrapped"
+        (.failWithCause (make-instance) 1.0))))
diff --git a/test/java/clojure/test/ReflectorTryCatchFixture.java b/test/java/clojure/test/ReflectorTryCatchFixture.java
index 9256559..043cff9 100644
--- a/test/java/clojure/test/ReflectorTryCatchFixture.java
+++ b/test/java/clojure/test/ReflectorTryCatchFixture.java
@@ -10,7 +10,12 @@ public class ReflectorTryCatchFixture {
 		throw new Cookies("Double");
 	}
 	
+        public void failWithCause(Double y) throws Cookies {
+                throw new Cookies("Wrapped", new Cookies("Cause"));
+	}
+	
 	public static class Cookies extends Exception {
+                public Cookies(String msg, Throwable cause) { super(msg, cause); }
 		public Cookies(String msg) { super(msg); }
 	}
 
-- 
1.7.1


From 4a46433d5c9603c60ad7fc81ae9788e24ff8b663 Mon Sep 17 00:00:00 2001
From: Paul Stadig <paul@stadig.name>
Date: Thu, 1 Mar 2012 23:19:33 +0000
Subject: [PATCH 5/5] Don't double unwrap when calling an instance method.

---
 src/jvm/clojure/lang/Reflector.java |   22 ++++------------------
 1 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/src/jvm/clojure/lang/Reflector.java b/src/jvm/clojure/lang/Reflector.java
index fb56a7e..a28104b 100644
--- a/src/jvm/clojure/lang/Reflector.java
+++ b/src/jvm/clojure/lang/Reflector.java
@@ -23,16 +23,9 @@ import java.util.List;
 public class Reflector{
 
 public static Object invokeInstanceMethod(Object target, String methodName, Object[] args) {
-	try
-		{
-		Class c = target.getClass();
-		List methods = getMethods(c, args.length, methodName, false);
-		return invokeMatchingMethod(methodName, methods, target, args);
-		}
-	catch(Exception e)
-		{
-		throw Util.sneakyThrow(getCauseOrElse(e));
-		}
+	Class c = target.getClass();
+	List methods = getMethods(c, args.length, methodName, false);
+	return invokeMatchingMethod(methodName, methods, target, args);
 }
 
 private static Throwable getCauseOrElse(Exception e) {
@@ -204,14 +197,7 @@ public static Object invokeStaticMethodVariadic(String className, String methodN
 
 public static Object invokeStaticMethod(String className, String methodName, Object[] args) {
 	Class c = RT.classForName(className);
-	try
-		{
-		return invokeStaticMethod(c, methodName, args);
-		}
-	catch(Exception e)
-		{
-		throw Util.sneakyThrow(getCauseOrElse(e));
-		}
+	return invokeStaticMethod(c, methodName, args);
 }
 
 public static Object invokeStaticMethod(Class c, String methodName, Object[] args) {
-- 
1.7.1

