Minor: fix warnings and refactoring
This commit is contained in:
@@ -24,9 +24,9 @@ import java.lang.reflect.AccessibleObject
|
|||||||
import com.sun.jdi.Type as jdi_Type
|
import com.sun.jdi.Type as jdi_Type
|
||||||
import com.sun.jdi.Value as jdi_Value
|
import com.sun.jdi.Value as jdi_Value
|
||||||
|
|
||||||
val CLASS = Type.getType(Class::class.java)
|
private val CLASS = Type.getType(Class::class.java)
|
||||||
val OBJECT = Type.getType(Any::class.java)
|
private val OBJECT = Type.getType(Any::class.java)
|
||||||
val BOOTSTRAP_CLASS_DESCRIPTORS = setOf("Ljava/lang/String;", "Ljava/lang/ClassLoader;", "Ljava/lang/Class;")
|
private val BOOTSTRAP_CLASS_DESCRIPTORS = setOf("Ljava/lang/String;", "Ljava/lang/ClassLoader;", "Ljava/lang/Class;")
|
||||||
|
|
||||||
class JDIEval(
|
class JDIEval(
|
||||||
private val vm: VirtualMachine,
|
private val vm: VirtualMachine,
|
||||||
@@ -39,7 +39,7 @@ class JDIEval(
|
|||||||
Type.BOOLEAN_TYPE.className to vm.mirrorOf(true).type(),
|
Type.BOOLEAN_TYPE.className to vm.mirrorOf(true).type(),
|
||||||
Type.BYTE_TYPE.className to vm.mirrorOf(1.toByte()).type(),
|
Type.BYTE_TYPE.className to vm.mirrorOf(1.toByte()).type(),
|
||||||
Type.SHORT_TYPE.className to vm.mirrorOf(1.toShort()).type(),
|
Type.SHORT_TYPE.className to vm.mirrorOf(1.toShort()).type(),
|
||||||
Type.INT_TYPE.className to vm.mirrorOf(1.toInt()).type(),
|
Type.INT_TYPE.className to vm.mirrorOf(1).type(),
|
||||||
Type.CHAR_TYPE.className to vm.mirrorOf('1').type(),
|
Type.CHAR_TYPE.className to vm.mirrorOf('1').type(),
|
||||||
Type.LONG_TYPE.className to vm.mirrorOf(1L).type(),
|
Type.LONG_TYPE.className to vm.mirrorOf(1L).type(),
|
||||||
Type.FLOAT_TYPE.className to vm.mirrorOf(1.0f).type(),
|
Type.FLOAT_TYPE.className to vm.mirrorOf(1.0f).type(),
|
||||||
@@ -205,16 +205,13 @@ class JDIEval(
|
|||||||
|
|
||||||
private fun findMethod(methodDesc: MethodDescription, _class: ReferenceType = methodDesc.ownerType.asReferenceType()): Method {
|
private fun findMethod(methodDesc: MethodDescription, _class: ReferenceType = methodDesc.ownerType.asReferenceType()): Method {
|
||||||
val method = when (_class) {
|
val method = when (_class) {
|
||||||
is ClassType -> {
|
is ClassType ->
|
||||||
val m = _class.concreteMethodByName(methodDesc.name, methodDesc.desc)
|
_class.concreteMethodByName(methodDesc.name, methodDesc.desc)
|
||||||
if (m == null) listOf() else listOf(m)
|
else ->
|
||||||
}
|
_class.methodsByName(methodDesc.name, methodDesc.desc).firstOrNull()
|
||||||
else -> _class.methodsByName(methodDesc.name, methodDesc.desc)
|
|
||||||
}
|
}
|
||||||
if (method.isEmpty()) {
|
|
||||||
throwBrokenCodeException(NoSuchMethodError("Method not found: $methodDesc"))
|
return method ?: throwBrokenCodeException(NoSuchMethodError("Method not found: $methodDesc"))
|
||||||
}
|
|
||||||
return method[0]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun invokeStaticMethod(methodDesc: MethodDescription, arguments: List<Value>): Value {
|
override fun invokeStaticMethod(methodDesc: MethodDescription, arguments: List<Value>): Value {
|
||||||
@@ -404,6 +401,7 @@ class JDIEval(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
private sealed class JdiOperationResult<T> {
|
private sealed class JdiOperationResult<T> {
|
||||||
class Fail<T>(val cause: Exception): JdiOperationResult<T>()
|
class Fail<T>(val cause: Exception): JdiOperationResult<T>()
|
||||||
class OK<T>(val value: T): JdiOperationResult<T>()
|
class OK<T>(val value: T): JdiOperationResult<T>()
|
||||||
|
|||||||
Reference in New Issue
Block a user