GROOVY-12023: unwrap exception in degraded path
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v8/IndyInterface.java b/src/main/java/org/codehaus/groovy/vmplugin/v8/IndyInterface.java index c746dac..81e5d64 100644 --- a/src/main/java/org/codehaus/groovy/vmplugin/v8/IndyInterface.java +++ b/src/main/java/org/codehaus/groovy/vmplugin/v8/IndyInterface.java
@@ -19,6 +19,7 @@ package org.codehaus.groovy.vmplugin.v8; import edu.umd.cs.findbugs.annotations.NonNull; +import groovy.lang.GroovyRuntimeException; import groovy.lang.GroovySystem; import java.lang.invoke.CallSite; import java.lang.invoke.ConstantCallSite; @@ -324,8 +325,12 @@ * @return the method invocation result */ public static Object invokeDegraded(Object receiver, String name, Object[] args) { - return org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(receiver) - .invokeMethod(receiver, name, args); + try { + return org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(receiver) + .invokeMethod(receiver, name, args); + } catch (GroovyRuntimeException e) { + return e; // same as MethodHandles.catchException + UNWRAP_EXCEPTION in normal path + } } /** @@ -337,8 +342,12 @@ * @return the property value */ public static Object getPropertyDegraded(Object receiver, String name) { - return org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(receiver) - .getProperty(receiver, name); + try { + return org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(receiver) + .getProperty(receiver, name); + } catch (GroovyRuntimeException e) { + return e; // same as MethodHandles.catchException + UNWRAP_EXCEPTION in normal path + } } /**