/** * {@link GroovyObject#invokeMethod(String, Object)} path as fallback. * This method is called by the handle as exception handler in case the * selected method causes a MissingMethodExecutionFailed, where * we will just give through the exception, and a normal * MissingMethodException where we call {@link GroovyObject#invokeMethod(String, Object)} * if receiver class, the type transported by the exception and the name * for the method stored in the exception and our current method name * are equal. * Should those conditions not apply we just rethrow the exception. */ public static Object invokeGroovyObjectInvoker(MissingMethodException e, Object receiver, String name, Object[] args) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException)e.getCause(); } else if (receiver.getClass() == e.getType() && e.getMethod().equals(name)) { //TODO: we should consider calling this one directly for MetaClassImpl, // then we save the new method selection // in case there's nothing else, invoke the object's own invokeMethod() return ((GroovyObject)receiver).invokeMethod(name, args); } else { throw e; } }
public final Object callCurrent(GroovyObject receiver, Object[] args) throws Throwable { if (checkCall(receiver)) { try { try { return metaClass.invokeMethod(array.owner, receiver, name, args, false, true); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException)e.getCause(); } else if (receiver.getClass() == e.getType() && e.getMethod().equals(name)) { // in case there's nothing else, invoke the object's own invokeMethod() return ((GroovyObject)receiver).invokeMethod(name, args); } else { throw e; } } } catch (GroovyRuntimeException gre) { throw ScriptBytecodeAdapter.unwrap(gre); } } else { return CallSiteArray.defaultCallCurrent(this, receiver, args); } } }
public final Object call(Object receiver, Object[] args) throws Throwable { if (checkCall(receiver)) { try { try { return metaClass.invokeMethod(receiver, name, args); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException)e.getCause(); } else if (receiver.getClass() == e.getType() && e.getMethod().equals(name)) { // in case there's nothing else, invoke the object's own invokeMethod() return ((GroovyObject)receiver).invokeMethod(name, args); } else { throw e; } } } catch (GroovyRuntimeException gre) { throw ScriptBytecodeAdapter.unwrap(gre); } } else { return CallSiteArray.defaultCall(this, receiver, args); } }
public static Object invokeMethodOnCurrentN(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments) throws Throwable { Object result = null; boolean intercepting = receiver instanceof GroovyInterceptable; try { try { // if it's a pure interceptable object (even intercepting toString(), clone(), ...) if (intercepting) { result = receiver.invokeMethod(messageName, messageArguments); } //else if there's a statically typed method or a GDK method else { result = receiver.getMetaClass().invokeMethod(senderClass, receiver, messageName, messageArguments, false, true); } } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException)e.getCause(); } else if (!intercepting && receiver.getClass() == e.getType() && e.getMethod().equals(messageName)) { // in case there's nothing else, invoke the object's own invokeMethod() result = receiver.invokeMethod(messageName, messageArguments); } else { throw e; } } } catch (GroovyRuntimeException gre) { throw unwrap(gre); } return result; }
static Object invokePogoMethod(Object object, String methodName, Object arguments) { GroovyObject groovy = (GroovyObject) object; boolean intercepting = groovy instanceof GroovyInterceptable; try { // if it's a pure interceptable object (even intercepting toString(), clone(), ...) if (intercepting) { return groovy.invokeMethod(methodName, asUnwrappedArray(arguments)); } //else try a statically typed method or a GDK method return groovy.getMetaClass().invokeMethod(object, methodName, asArray(arguments)); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException) e.getCause(); } else if (!intercepting && e.getMethod().equals(methodName) && object.getClass() == e.getType()) { // in case there's nothing else, invoke the object's own invokeMethod() return groovy.invokeMethod(methodName, asUnwrappedArray(arguments)); } else { throw e; } } }
public final Object call(Object receiver, Object[] args) throws Throwable { if (checkCall(receiver)) { try { try { return metaClass.invokeMethod(receiver, name, args); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException)e.getCause(); } else if (receiver.getClass() == e.getType() && e.getMethod().equals(name)) { // in case there's nothing else, invoke the object's own invokeMethod() return ((GroovyObject)receiver).invokeMethod(name, args); } else { throw e; } } } catch (GroovyRuntimeException gre) { throw ScriptBytecodeAdapter.unwrap(gre); } } else { return CallSiteArray.defaultCall(this, receiver, args); } }
public final Object call(Object receiver, Object[] args) throws Throwable { if (checkCall(receiver)) { try { try { return metaClass.invokeMethod(receiver, name, args); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException)e.getCause(); } else if (receiver.getClass() == e.getType() && e.getMethod().equals(name)) { // in case there's nothing else, invoke the object's own invokeMethod() return ((GroovyObject)receiver).invokeMethod(name, args); } else { throw e; } } } catch (GroovyRuntimeException gre) { throw ScriptBytecodeAdapter.unwrap(gre); } } else { return CallSiteArray.defaultCall(this, receiver, args); } }
public final Object callCurrent(GroovyObject receiver, Object[] args) throws Throwable { if (checkCall(receiver)) { try { try { return metaClass.invokeMethod(receiver, name, args); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException)e.getCause(); } else if (receiver.getClass() == e.getType() && e.getMethod().equals(name)) { // in case there's nothing else, invoke the object's own invokeMethod() return ((GroovyObject)receiver).invokeMethod(name, args); } else { throw e; } } } catch (GroovyRuntimeException gre) { throw ScriptBytecodeAdapter.unwrap(gre); } } else { return CallSiteArray.defaultCallCurrent(this, receiver, args); } } }
public static Object invokeMethodOnCurrentN(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments) throws Throwable { Object result = null; boolean intercepting = receiver instanceof GroovyInterceptable; try { try { // if it's a pure interceptable object (even intercepting toString(), clone(), ...) if (intercepting) { result = receiver.invokeMethod(messageName, messageArguments); } //else if there's a statically typed method or a GDK method else { result = receiver.getMetaClass().invokeMethod(senderClass, receiver, messageName, messageArguments, false, true); } } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException)e.getCause(); } else if (!intercepting && receiver.getClass() == e.getType() && e.getMethod().equals(messageName)) { // in case there's nothing else, invoke the object's own invokeMethod() result = receiver.invokeMethod(messageName, messageArguments); } else { throw e; } } } catch (GroovyRuntimeException gre) { throw unwrap(gre); } return result; }
public final Object call(Object receiver, Object[] args) throws Throwable { if (checkCall(receiver)) { try { try { return metaClass.invokeMethod(receiver, name, args); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException)e.getCause(); } else if (receiver.getClass() == e.getType() && e.getMethod().equals(name)) { // in case there's nothing else, invoke the object's own invokeMethod() return ((GroovyObject)receiver).invokeMethod(name, args); } else { throw e; } } } catch (GroovyRuntimeException gre) { throw ScriptBytecodeAdapter.unwrap(gre); } } else { return CallSiteArray.defaultCall(this, receiver, args); } }
public static Object invokeMethodOnCurrentN(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments) throws Throwable { Object result = null; boolean intercepting = receiver instanceof GroovyInterceptable; try { try { // if it's a pure interceptable object (even intercepting toString(), clone(), ...) if (intercepting) { result = receiver.invokeMethod(messageName, messageArguments); } //else if there's a statically typed method or a GDK method else { result = receiver.getMetaClass().invokeMethod(senderClass, receiver, messageName, messageArguments, false, true); } } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException)e.getCause(); } else if (!intercepting && receiver.getClass() == e.getType() && e.getMethod().equals(messageName)) { // in case there's nothing else, invoke the object's own invokeMethod() result = receiver.invokeMethod(messageName, messageArguments); } else { throw e; } } } catch (GroovyRuntimeException gre) { throw unwrap(gre); } return result; }
public final Object callCurrent(GroovyObject receiver, Object[] args) throws Throwable { if (checkCall(receiver)) { try { try { return metaClass.invokeMethod(receiver, name, args); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException)e.getCause(); } else if (receiver.getClass() == e.getType() && e.getMethod().equals(name)) { // in case there's nothing else, invoke the object's own invokeMethod() return ((GroovyObject)receiver).invokeMethod(name, args); } else { throw e; } } } catch (GroovyRuntimeException gre) { throw ScriptBytecodeAdapter.unwrap(gre); } } else { return CallSiteArray.defaultCallCurrent(this, receiver, args); } } }
public final Object callCurrent(GroovyObject receiver, Object[] args) throws Throwable { if (checkCall(receiver)) { try { try { return metaClass.invokeMethod(receiver, name, args); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException)e.getCause(); } else if (receiver.getClass() == e.getType() && e.getMethod().equals(name)) { // in case there's nothing else, invoke the object's own invokeMethod() return ((GroovyObject)receiver).invokeMethod(name, args); } else { throw e; } } } catch (GroovyRuntimeException gre) { throw ScriptBytecodeAdapter.unwrap(gre); } } else { return CallSiteArray.defaultCallCurrent(this, receiver, args); } } }
public static Object invokeMethodOnCurrentN(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments) throws Throwable { Object result = null; boolean intercepting = receiver instanceof GroovyInterceptable; try { try { // if it's a pure interceptable object (even intercepting toString(), clone(), ...) if (intercepting) { result = receiver.invokeMethod(messageName, messageArguments); } //else if there's a statically typed method or a GDK method else { result = receiver.getMetaClass().invokeMethod(senderClass, receiver, messageName, messageArguments, false, true); } } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw e.getCause(); } else if (!intercepting && receiver.getClass() == e.getType() && e.getMethod().equals(messageName)) { // in case there's nothing else, invoke the object's own invokeMethod() result = receiver.invokeMethod(messageName, messageArguments); } else { throw e; } } } catch (GroovyRuntimeException t) { throw unwrap(t); } return result; }
public static Object invokeMethodOnCurrentN(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments) throws Throwable { Object result = null; boolean intercepting = receiver instanceof GroovyInterceptable; try { try { // if it's a pure interceptable object (even intercepting toString(), clone(), ...) if (intercepting) { result = receiver.invokeMethod(messageName, messageArguments); } //else if there's a statically typed method or a GDK method else { result = receiver.getMetaClass().invokeMethod(senderClass, receiver, messageName, messageArguments, false, true); } } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException)e.getCause(); } else if (!intercepting && receiver.getClass() == e.getType() && e.getMethod().equals(messageName)) { // in case there's nothing else, invoke the object's own invokeMethod() result = receiver.invokeMethod(messageName, messageArguments); } else { throw e; } } } catch (GroovyRuntimeException gre) { throw unwrap(gre); } return result; }
private static Object invokePogoMethod(Object object, String methodName, Object arguments) { GroovyObject groovy = (GroovyObject) object; boolean intercepting = groovy instanceof GroovyInterceptable; try { // if it's a pure interceptable object (even intercepting toString(), clone(), ...) if (intercepting) { return groovy.invokeMethod(methodName, asUnwrappedArray(arguments)); } //else try a statically typed method or a GDK method return groovy.getMetaClass().invokeMethod(object, methodName, asArray(arguments)); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException) e.getCause(); } else if (!intercepting && e.getMethod().equals(methodName) && object.getClass() == e.getType()) { // in case there's nothing else, invoke the object's own invokeMethod() return groovy.invokeMethod(methodName, asUnwrappedArray(arguments)); } else { throw e; } } }
static Object invokePogoMethod(Object object, String methodName, Object arguments) { GroovyObject groovy = (GroovyObject) object; boolean intercepting = groovy instanceof GroovyInterceptable; try { // if it's a pure interceptable object (even intercepting toString(), clone(), ...) if (intercepting) { return groovy.invokeMethod(methodName, asUnwrappedArray(arguments)); } //else try a statically typed method or a GDK method return groovy.getMetaClass().invokeMethod(object, methodName, asArray(arguments)); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException) e.getCause(); } else if (!intercepting && e.getMethod().equals(methodName) && object.getClass() == e.getType()) { // in case there's nothing else, invoke the object's own invokeMethod() return groovy.invokeMethod(methodName, asUnwrappedArray(arguments)); } else { throw e; } } }
static Object invokePogoMethod(Object object, String methodName, Object arguments) { GroovyObject groovy = (GroovyObject) object; boolean intercepting = groovy instanceof GroovyInterceptable; try { // if it's a pure interceptable object (even intercepting toString(), clone(), ...) if (intercepting) { return groovy.invokeMethod(methodName, asUnwrappedArray(arguments)); } //else try a statically typed method or a GDK method return groovy.getMetaClass().invokeMethod(object, methodName, asArray(arguments)); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException) e.getCause(); } else if (!intercepting && e.getMethod().equals(methodName) && object.getClass() == e.getType()) { // in case there's nothing else, invoke the object's own invokeMethod() return groovy.invokeMethod(methodName, asUnwrappedArray(arguments)); } else { throw e; } } }
static Object invokePogoMethod(Object object, String methodName, Object arguments) { GroovyObject groovy = (GroovyObject) object; boolean intercepting = groovy instanceof GroovyInterceptable; try { // if it's a pure interceptable object (even intercepting toString(), clone(), ...) if (intercepting) { return groovy.invokeMethod(methodName, asUnwrappedArray(arguments)); } //else try a statically typed method or a GDK method return groovy.getMetaClass().invokeMethod(object, methodName, asArray(arguments)); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException) e.getCause(); } else if (!intercepting && e.getMethod().equals(methodName) && object.getClass() == e.getType()) { // in case there's nothing else, invoke the object's own invokeMethod() return groovy.invokeMethod(methodName, asUnwrappedArray(arguments)); } else { throw e; } } }
static Object invokePogoMethod(Object object, String methodName, Object arguments) { GroovyObject groovy = (GroovyObject) object; boolean intercepting = groovy instanceof GroovyInterceptable; try { // if it's a pure interceptable object (even intercepting toString(), clone(), ...) if (intercepting) { return groovy.invokeMethod(methodName, asUnwrappedArray(arguments)); } //else try a statically typed method or a GDK method return groovy.getMetaClass().invokeMethod(object, methodName, asArray(arguments)); } catch (MissingMethodException e) { if (e instanceof MissingMethodExecutionFailed) { throw (MissingMethodException) e.getCause(); } else if (!intercepting && e.getMethod().equals(methodName) && object.getClass() == e.getType()) { // in case there's nothing else, invoke the object's own invokeMethod() return groovy.invokeMethod(methodName, asUnwrappedArray(arguments)); } else { throw e; } } }