Search in sources :

Example 1 with InvalidTypeException

use of com.sun.jdi.InvalidTypeException in project che by eclipse.

the class Evaluator method invokeMethod.

public ExpressionValue invokeMethod(Value value, String name, List<Value> arguments) {
    if (!(value instanceof ObjectReference)) {
        throw new ExpressionException("Value is not object. Cannot invoke method " + name);
    }
    ObjectReference object = (ObjectReference) value;
    ReferenceType type = object.referenceType();
    List<Method> methods = type.methodsByName(name);
    Method method = findMethod(methods, arguments);
    if (method == null) {
        throw new ExpressionException("No method with name " + name + " matched to specified arguments for " + type.name());
    }
    try {
        return new ReadOnlyValue(object.invokeMethod(thread, method, arguments, 0));
    } catch (InvalidTypeException | ClassNotLoadedException | IncompatibleThreadStateException | InvocationException e) {
        throw new ExpressionException(e.getMessage(), e);
    }
}
Also used : ClassNotLoadedException(com.sun.jdi.ClassNotLoadedException) ObjectReference(com.sun.jdi.ObjectReference) IncompatibleThreadStateException(com.sun.jdi.IncompatibleThreadStateException) InvocationException(com.sun.jdi.InvocationException) Method(com.sun.jdi.Method) ReferenceType(com.sun.jdi.ReferenceType) InvalidTypeException(com.sun.jdi.InvalidTypeException)

Aggregations

ClassNotLoadedException (com.sun.jdi.ClassNotLoadedException)1 IncompatibleThreadStateException (com.sun.jdi.IncompatibleThreadStateException)1 InvalidTypeException (com.sun.jdi.InvalidTypeException)1 InvocationException (com.sun.jdi.InvocationException)1 Method (com.sun.jdi.Method)1 ObjectReference (com.sun.jdi.ObjectReference)1 ReferenceType (com.sun.jdi.ReferenceType)1