Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.7.7
-
Fix Version/s: None
-
Component/s: Compiler
-
Labels:None
-
Number of attachments :
Description
GroovyLib.groovy:
class GroovyLib {
void boom() throws IOException { throw new IOException() }
void undeclaredBoom() { throw new IOException() }
Closure closure = { throw new IOException() }
Runnable runnable = { throw new IOException() }
}
GroovyJavaExceptionPropagationTest.java:
public class GroovyJavaExceptionPropagationTest { @Test(expected = IOException.class) public void callGroovyMethodThatThrowsDeclaredCheckedException() throws Exception { new GroovyLib().boom(); // throws IOException } @Test(expected = IOException.class) public void callGroovyMethodThatThrowsUndeclaredCheckedException() throws Exception { new GroovyLib().undeclaredBoom(); // throws IOException } @Test(expected = IOException.class) public void callGroovyClosureThatThrowsCheckedException() throws Exception { new GroovyLib().getClosure().call(); // throws InvokerInvocationException } @Test(expected = IOException.class) public void callGroovyClosureDisguisedAsRunnableThatThrowsCheckedException() throws Exception { new GroovyLib().getRunnable().run(); // throws InvokerInvocationException } }
Can we get this fixed for 1.7.8? It is causing problems both in Spock and Gradle. Working around it by wrapping all Closure.call() invocations made from Java code with a try-catch block isn't feasible, especially not for Gradle. If Jochen (or someone else) assesses the fix as straight-forward, I can devote some time to it.