diff --git a/src/org/jetbrains/eval4j/interpreter.kt b/src/org/jetbrains/eval4j/interpreter.kt index e242b2e346c..f70c76239e2 100644 --- a/src/org/jetbrains/eval4j/interpreter.kt +++ b/src/org/jetbrains/eval4j/interpreter.kt @@ -176,7 +176,7 @@ class SingleInstructionInterpreter(private val eval: Eval) : Interpreter( ObjectValue(value.obj, targetType) } else { - throwException(ClassCastException("Value '$value' cannot be cast to $targetType")) + throwEvalException(ClassCastException("Value '$value' cannot be cast to $targetType")) } } diff --git a/src/org/jetbrains/eval4j/jdi/jdiEval.kt b/src/org/jetbrains/eval4j/jdi/jdiEval.kt index a60f10587a9..e17be8a36cf 100644 --- a/src/org/jetbrains/eval4j/jdi/jdiEval.kt +++ b/src/org/jetbrains/eval4j/jdi/jdiEval.kt @@ -101,7 +101,7 @@ class JDIEval( val _class = fieldDesc.ownerType.asReferenceType() val field = _class.fieldByName(fieldDesc.name) if (field == null) { - throwException(NoSuchFieldError("Field not found: $fieldDesc")) + throwEvalException(NoSuchFieldError("Field not found: $fieldDesc")) } return field } @@ -109,7 +109,7 @@ class JDIEval( private fun findStaticField(fieldDesc: FieldDescription): jdi.Field { val field = findField(fieldDesc) if (!field.isStatic()) { - throwException(NoSuchFieldError("Field is not static: $fieldDesc")) + throwEvalException(NoSuchFieldError("Field is not static: $fieldDesc")) } return field } @@ -123,12 +123,12 @@ class JDIEval( val field = findStaticField(fieldDesc) if (field.isFinal()) { - throwException(NoSuchFieldError("Can't modify a final field: $field")) + throwEvalException(NoSuchFieldError("Can't modify a final field: $field")) } val _class = field.declaringType() if (_class !is jdi.ClassType) { - throwException(NoSuchFieldError("Can't a field in a non-class: $field")) + throwEvalException(NoSuchFieldError("Can't a field in a non-class: $field")) } val jdiValue = newValue.asJdiValue(vm) @@ -145,7 +145,7 @@ class JDIEval( else -> _class.methodsByName(methodDesc.name, methodDesc.desc) } if (method.isEmpty()) { - throwException(NoSuchMethodError("Method not found: $methodDesc")) + throwEvalException(NoSuchMethodError("Method not found: $methodDesc")) } return method[0] } @@ -153,10 +153,10 @@ class JDIEval( override fun invokeStaticMethod(methodDesc: MethodDescription, arguments: List): Value { val method = findMethod(methodDesc) if (!method.isStatic()) { - throwException(NoSuchMethodError("Method is not static: $methodDesc")) + throwEvalException(NoSuchMethodError("Method is not static: $methodDesc")) } val _class = method.declaringType() - if (_class !is jdi.ClassType) throwException(NoSuchMethodError("Static method is a non-class type: $method")) + if (_class !is jdi.ClassType) throwEvalException(NoSuchMethodError("Static method is a non-class type: $method")) val args = arguments.map { v -> v.asJdiValue(vm) } val result = mayThrow { _class.invokeMethod(thread, method, args, 0) } diff --git a/src/org/jetbrains/eval4j/values.kt b/src/org/jetbrains/eval4j/values.kt index ec28d1082c4..932cb6163e9 100644 --- a/src/org/jetbrains/eval4j/values.kt +++ b/src/org/jetbrains/eval4j/values.kt @@ -101,11 +101,11 @@ val Value.obj: Any? fun T?.checkNull(): T { if (this == null) { - throwException(NullPointerException()) + throwEvalException(NullPointerException()) } return this } -fun throwException(e: Throwable): Nothing { +fun throwEvalException(e: Throwable): Nothing { throw ThrownFromEvalException(ObjectValue(e, Type.getType(e.javaClass))) } \ No newline at end of file diff --git a/test/org/jetbrains/eval4j/test/main.kt b/test/org/jetbrains/eval4j/test/main.kt index fdcbaab200c..7b29911bdeb 100644 --- a/test/org/jetbrains/eval4j/test/main.kt +++ b/test/org/jetbrains/eval4j/test/main.kt @@ -170,7 +170,7 @@ object REFLECTION_EVAL : Eval { } } catch (e: Throwable) { - throwException(e) + throwEvalException(e) } }