MCPcopy Create free account
hub / github.com/apache/groovy / invokeMethod

Method invokeMethod

src/main/java/groovy/util/Expando.java:121–138  ·  view source on GitHub ↗

Invokes a declared method or a closure stored as a dynamic property. @param name the method name @param args the invocation arguments @return the invocation result

(String name, Object args)

Source from the content-addressed store, hash-verified

119 * @return the invocation result
120 */
121 @Override
122 public Object invokeMethod(String name, Object args) {
123 try {
124 return super.invokeMethod(name, args);
125 }
126 catch (GroovyRuntimeException e) {
127 // br should get a "native" property match first. getProperty includes such fall-back logic
128 Object value = this.getProperty(name);
129 if (value instanceof Closure closure) {
130 closure = (Closure) closure.clone();
131 closure.setDelegate(this);
132 return closure.call((Object[]) args);
133 } else {
134 throw e;
135 }
136 }
137
138 }
139
140 /**
141 * This allows toString to be overridden by a closure <i>field</i> method attached

Callers

nothing calls this directly

Calls 5

getPropertyMethod · 0.95
invokeMethodMethod · 0.65
cloneMethod · 0.65
callMethod · 0.65
setDelegateMethod · 0.45

Tested by

no test coverage detected