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)
| 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 |
nothing calls this directly
no test coverage detected