Reading static fields supported

This commit is contained in:
Andrey Breslav
2013-10-06 18:01:12 +04:00
parent 2e6d523966
commit 7d7316a077
2 changed files with 15 additions and 0 deletions
@@ -156,4 +156,14 @@ class TestData {
return String.CASE_INSENSITIVE_ORDER;
}
static int FIELD = 0;
static int testPutStaticField() {
FIELD = 5;
int f1 = FIELD;
FIELD = 6;
int f2 = FIELD;
return f2 + f1;
}
}
+5
View File
@@ -143,6 +143,11 @@ object REFLECTION_EVAL : Eval {
override fun setStaticField(fieldDesc: FieldDescription, newValue: Value) {
assertTrue(fieldDesc.isStatic)
val owner = lookup.findClass(fieldDesc.ownerInternalName)
assertNotNull("Class not found: ${fieldDesc.ownerInternalName}", owner)
val field = owner!!.findField(fieldDesc)
assertNotNull("Field not found: $fieldDesc", field)
val result = field!!.set(null, newValue.obj)
}
override fun invokeStaticMethod(methodDesc: MethodDescription, arguments: List<Value>): Value {