SuspendThreadStack threadStack = SuspendThreadStack.getInstance();
ThreadReference threadRef = threadStack.getCurThreadRef();
Value value = null;
Method matchedMethod = null;
List<Method> methods = null;
ClassType refType = null;
ObjectReference obj = null;
if (invoker instanceof ClassType) {
refType = (ClassType)invoker;
methods = refType.methodsByName(methodName);
} else {
obj = (ObjectReference)invoker;
methods = obj.referenceType().methodsByName(methodName);
}
if (methods == null || methods.size() == 0) {
throw new ExpressionEvalException("eval expression error, method '" + methodName + "' can't be found");
}
if (methods.size() == 1) {
matchedMethod = methods.get(0);
} else {
matchedMethod = findMatchedMethod(methods, args);
}
try {
if (invoker instanceof ClassType) {
ClassType clazz = (ClassType)refType;
value = clazz.invokeMethod(threadRef, matchedMethod, args,
ObjectReference.INVOKE_SINGLE_THREADED);
} else {
value = obj.invokeMethod(threadRef, matchedMethod, args,
ObjectReference.INVOKE_SINGLE_THREADED);
}