use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class BoxingEvaluator method convertToWrapper.
private static Value convertToWrapper(EvaluationContextImpl context, PrimitiveValue value, String wrapperTypeName) throws EvaluateException {
final DebugProcessImpl process = context.getDebugProcess();
final ClassType wrapperClass = (ClassType) process.findClass(context, wrapperTypeName, null);
final String methodSignature = "(" + JVMNameUtil.getPrimitiveSignature(value.type().name()) + ")L" + wrapperTypeName.replace('.', '/') + ";";
Method method = wrapperClass.concreteMethodByName("valueOf", methodSignature);
if (method == null) {
// older JDK version
method = wrapperClass.concreteMethodByName(JVMNameUtil.CONSTRUCTOR_NAME, methodSignature);
}
if (method == null) {
throw new EvaluateException("Cannot construct wrapper object for value of type " + value.type() + ": Unable to find either valueOf() or constructor method");
}
return process.invokeMethod(context, wrapperClass, method, Collections.singletonList(value));
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class BoxingEvaluator method evaluate.
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
final Object result = myOperand.evaluate(context);
if (result == null || result instanceof ObjectReference) {
return result;
}
if (result instanceof PrimitiveValue) {
PrimitiveValue primitiveValue = (PrimitiveValue) result;
PsiPrimitiveType primitiveType = PsiJavaParserFacadeImpl.getPrimitiveType(primitiveValue.type().name());
if (primitiveType != null) {
return convertToWrapper(context, primitiveValue, primitiveType.getBoxedTypeName());
}
}
throw new EvaluateException("Cannot perform boxing conversion for a value of type " + ((Value) result).type().name());
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class StackFrameProxyImpl method getStackFrame.
/**
* Use with caution. Better access stackframe data through the Proxy's methods
*/
@Override
public StackFrame getStackFrame() throws EvaluateException {
DebuggerManagerThreadImpl.assertIsManagerThread();
checkValid();
if (myStackFrame == null) {
try {
final ThreadReference threadRef = myThreadProxy.getThreadReference();
myStackFrame = threadRef.frame(getFrameIndex());
} catch (IndexOutOfBoundsException e) {
throw new EvaluateException(e.getMessage(), e);
} catch (ObjectCollectedException ignored) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.thread.collected"));
} catch (IncompatibleThreadStateException e) {
throw EvaluateExceptionUtil.createEvaluateException(e);
}
}
return myStackFrame;
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class NewClassInstanceEvaluator method evaluate.
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
DebugProcessImpl debugProcess = context.getDebugProcess();
Object obj = myClassTypeEvaluator.evaluate(context);
if (!(obj instanceof ClassType)) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.evaluate.class.type"));
}
ClassType classType = (ClassType) obj;
// find constructor
Method method = DebuggerUtils.findMethod(classType, JVMNameUtil.CONSTRUCTOR_NAME, myConstructorSignature.getName(debugProcess));
if (method == null) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.resolve.constructor", myConstructorSignature.getDisplayName(debugProcess)));
}
// evaluate arguments
List<Value> arguments;
if (!ArrayUtil.isEmpty(myParamsEvaluators)) {
arguments = new ArrayList<>(myParamsEvaluators.length);
for (Evaluator evaluator : myParamsEvaluators) {
Object res = evaluator.evaluate(context);
if (!(res instanceof Value) && res != null) {
LOG.error("Unable to call newInstance, evaluator " + evaluator + " result is not Value, but " + res);
}
//noinspection ConstantConditions
arguments.add((Value) res);
}
} else {
arguments = Collections.emptyList();
}
ObjectReference objRef;
try {
objRef = debugProcess.newInstance(context, classType, method, arguments);
} catch (EvaluateException e) {
throw EvaluateExceptionUtil.createEvaluateException(e);
}
return objRef;
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class UnBoxingEvaluator method convertToPrimitive.
private static Value convertToPrimitive(EvaluationContextImpl context, ObjectReference value, final String conversionMethodName, String conversionMethodSignature) throws EvaluateException {
final DebugProcessImpl process = context.getDebugProcess();
final ClassType wrapperClass = (ClassType) value.referenceType();
Method method = wrapperClass.concreteMethodByName(conversionMethodName, conversionMethodSignature);
if (method == null) {
throw new EvaluateException("Cannot convert to primitive value of type " + value.type() + ": Unable to find method " + conversionMethodName + conversionMethodSignature);
}
return process.invokeMethod(context, value, method, Collections.emptyList());
}
Aggregations