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