Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

runtime: Fix java/lang/reflect/Field.set() for base types

This fix unblocks Maven from starting up.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
  • Loading branch information...
commit 8736a3382e051054486dc474408755ab23a4eb9b 1 parent 9a061b4
@penberg authored
View
2  runtime/java_lang_reflect_VMField.c
@@ -467,7 +467,7 @@ void java_lang_reflect_VMField_set(struct vm_object *this, struct vm_object *o,
return;
}
- if (o->class != vmf->class) {
+ if (!vm_object_is_instance_of(o, vmf->class)) {
signal_new_exception(vm_java_lang_IllegalArgumentException, NULL);
return;
}
View
22 test/functional/test/java/lang/reflect/FieldTest.java
@@ -107,7 +107,29 @@ public static void testTag(Tag tag) throws Exception {
public @interface Tag2 { }
+ public static class BaseType {
+ public Object baseField;
+ }
+
+ public static class Type extends BaseType {
+ public Object field;
+ }
+
+ public static void testSet() throws Exception {
+ Type t = new Type();
+ Field field = t.getClass().getField("field");
+ Object o1 = new Object();
+ field.set(t, o1);
+ assertEquals(o1, t.field);
+
+ Field baseField = t.getClass().getField("baseField");
+ Object o2 = new Object();
+ baseField.set(t, o2);
+ assertEquals(o2, t.baseField);
+ }
+
public static void main(String[] args) throws Exception {
testGetAnnotation();
+ testSet();
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.