MCPcopy Index your code
hub / github.com/apache/groovy / invokeMethod

Method invokeMethod

src/main/java/groovy/lang/Script.java:118–140  ·  view source on GitHub ↗

Invoke a method (or closure in the binding) defined. @param name method to call @param args arguments to pass to the method @return value

(String name, Object args)

Source from the content-addressed store, hash-verified

116 * @return value
117 */
118 @Override
119 public Object invokeMethod(String name, Object args) {
120 try {
121 return super.invokeMethod(name, args);
122 } catch (MissingMethodException mme) {
123 // if the method was not found in the current scope (the script's methods)
124 // let's try to see if there's a method closure with the same name in the binding
125 try {
126 if (name.equals(mme.getMethod())) {
127 Object boundClosure = getProperty(name);
128 if (boundClosure instanceof Closure) {
129 return ((Closure<?>) boundClosure).call((Object[]) args);
130 } else {
131 throw mme;
132 }
133 } else {
134 throw mme;
135 }
136 } catch (MissingPropertyException mpe) {
137 throw mme;
138 }
139 }
140 }
141
142 /**
143 * The main instance method of a script which has variables in scope

Callers

nothing calls this directly

Calls 5

getPropertyMethod · 0.95
invokeMethodMethod · 0.65
equalsMethod · 0.65
callMethod · 0.65
getMethodMethod · 0.45

Tested by

no test coverage detected