When you use the method pointer in an instance of Class , then it must explicitly use the doCall() method provided by MethodClosure , instead of using call() by default << 24>.
doCall method from MethodClosure overrides the Closure doCall and intercepts the method call using invokeMethod instead of calling call() from Closure .
MethodClosure will also work if you explicitly use InvokerHelper , which is a synonym for doCall in MethodClosure or just a metaClass List.
import org.codehaus.groovy.runtime.InvokerHelper t = List.&isInstance assert t.owner.simpleName == 'List' assert t.doCall([]) == true assert InvokerHelper.getMetaClass(t.owner). invokeStaticMethod(t.owner, 'isInstance', []) == true assert List.metaClass.invokeStaticMethod(t.owner, 'isInstance', []) == true
invokeStaticMethod MOP is used if the object is an instance of Class .
&plus , on the other hand, works accordingly because the method pointer is created on a POJO.
source share