Eval4J: Do not report certain kinds of exceptions to EA
This commit is contained in:
@@ -25,8 +25,6 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter
|
||||
|
||||
class UnsupportedByteCodeException(message: String) : RuntimeException(message)
|
||||
|
||||
class Eval4JInterpreterException(override val cause: Throwable) : RuntimeException(cause)
|
||||
|
||||
interface Eval {
|
||||
fun loadClass(classType: Type): Value
|
||||
fun loadString(str: String): Value
|
||||
@@ -186,7 +184,7 @@ class SingleInstructionInterpreter(private val eval: Eval) : Interpreter<Value>(
|
||||
when {
|
||||
value == NULL_VALUE -> NULL_VALUE
|
||||
eval.isInstanceOf(value, targetType) -> ObjectValue(value.obj(), targetType)
|
||||
else -> throwEvalException(ClassCastException("${value.asmType.className} cannot be cast to ${targetType.className}"))
|
||||
else -> throwInterpretingException(ClassCastException("${value.asmType.className} cannot be cast to ${targetType.className}"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +214,7 @@ class SingleInstructionInterpreter(private val eval: Eval) : Interpreter<Value>(
|
||||
}
|
||||
}
|
||||
|
||||
private fun divisionByZero(): Nothing = throw Eval4JInterpreterException(ArithmeticException("Division by zero"))
|
||||
private fun divisionByZero(): Nothing = throwInterpretingException(ArithmeticException("Division by zero"))
|
||||
|
||||
override fun binaryOperation(insn: AbstractInsnNode, value1: Value, value2: Value): Value? {
|
||||
return when (insn.opcode) {
|
||||
|
||||
@@ -64,8 +64,10 @@ abstract class ThrownFromEvalExceptionBase(cause: Throwable): RuntimeException(c
|
||||
override fun toString(): String = "Thrown by evaluator: ${cause}"
|
||||
}
|
||||
|
||||
class BrokenCode(cause: Throwable): ThrownFromEvalExceptionBase(cause)
|
||||
class ThrownFromEvalException(cause: Throwable): ThrownFromEvalExceptionBase(cause)
|
||||
class BrokenCode(cause: Throwable) : ThrownFromEvalExceptionBase(cause)
|
||||
|
||||
// Interpreting exceptions should not be sent to EA
|
||||
class Eval4JInterpretingException(override val cause: Throwable) : RuntimeException(cause)
|
||||
|
||||
class ThrownFromEvaluatedCodeException(val exception: ObjectValue): RuntimeException() {
|
||||
override fun toString(): String = "Thrown from evaluated code: $exception"
|
||||
|
||||
@@ -166,7 +166,7 @@ class JDIEval(
|
||||
return array.array().getValue(index.int).asValue()
|
||||
}
|
||||
catch (e: IndexOutOfBoundsException) {
|
||||
throwEvalException(ArrayIndexOutOfBoundsException(e.message))
|
||||
throwInterpretingException(ArrayIndexOutOfBoundsException(e.message))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ class JDIEval(
|
||||
return array.array().setValue(index.int, newValue.asJdiValue(vm, array.asmType.arrayElementType))
|
||||
}
|
||||
catch (e: IndexOutOfBoundsException) {
|
||||
throwEvalException(ArrayIndexOutOfBoundsException(e.message))
|
||||
throwInterpretingException(ArrayIndexOutOfBoundsException(e.message))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,15 +118,15 @@ fun Value.obj(expectedType: Type = asmType): Any? {
|
||||
}
|
||||
}
|
||||
|
||||
fun <T: Any> T?.checkNull(): T {
|
||||
fun <T : Any> T?.checkNull(): T {
|
||||
if (this == null) {
|
||||
throwEvalException(NullPointerException())
|
||||
throwInterpretingException(NullPointerException())
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
fun throwEvalException(e: Throwable): Nothing {
|
||||
throw ThrownFromEvalException(e)
|
||||
fun throwInterpretingException(e: Throwable): Nothing {
|
||||
throw Eval4JInterpretingException(e)
|
||||
}
|
||||
|
||||
fun throwBrokenCodeException(e: Throwable): Nothing {
|
||||
|
||||
Reference in New Issue
Block a user