Invoke method on arbitrary object instance. invocation may be static (through the object instance) or dynamic. Object may be a bsh scripted object (bsh.This type). @return the result of the method call
(Object object, String methodName, Object[] args, Interpreter interpreter, CallStack callstack, SimpleNode callerInfo)
| 78 | * @return the result of the method call |
| 79 | */ |
| 80 | public static Object invokeObjectMethod(Object object, String methodName, Object[] args, Interpreter interpreter, CallStack callstack, SimpleNode callerInfo) throws ReflectError, EvalError, InvocationTargetException { |
| 81 | // Bsh scripted object |
| 82 | if (object instanceof This && !This.isExposedThisMethod(methodName)) { |
| 83 | return ((This) object).invokeMethod(methodName, args, interpreter, callstack, callerInfo, false/*delcaredOnly*/); |
| 84 | } |
| 85 | |
| 86 | // Plain Java object, find the java method |
| 87 | try { |
| 88 | BshClassManager bcm = interpreter == null ? null : interpreter.getClassManager(); |
| 89 | Class clas = object.getClass(); |
| 90 | |
| 91 | Method method = resolveExpectedJavaMethod(bcm, clas, object, methodName, args, false); |
| 92 | |
| 93 | return invokeMethod(method, object, args); |
| 94 | } catch (UtilEvalError e) { |
| 95 | throw e.toEvalError(callerInfo, callstack); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | |
| 100 | /** |
no test coverage detected