Fix a handful of reflection bugs.
We now pass test 046.
Change-Id: Ie605ed99e64038435608fe388c59526674af5489
diff --git a/test/046-reflect/expected.txt b/test/046-reflect/expected.txt
index 55b0eca..b2bb176 100644
--- a/test/046-reflect/expected.txt
+++ b/test/046-reflect/expected.txt
@@ -81,8 +81,9 @@
Field type is int
Access flags are 0x11
cantTouchThis is 77
- got expected set-final failure
- cantTouchThis is now 77
+ setAccessible is always true
+ cantTouchThis is now 99
+ cantTouchThis is now 87
cantTouchThis is now 88
cons modifiers=1
SuperTarget constructor ()V
diff --git a/test/046-reflect/src/Main.java b/test/046-reflect/src/Main.java
index e604979..7b6036b 100644
--- a/test/046-reflect/src/Main.java
+++ b/test/046-reflect/src/Main.java
@@ -272,15 +272,17 @@
System.out.println(" cantTouchThis is " + intVal);
try {
field.setInt(instance, 99);
- System.out.println("ERROR: set-final succeeded");
+ System.out.println(" setAccessible is always true");
} catch (IllegalAccessException iae) {
- System.out.println(" got expected set-final failure");
+ System.out.println("ERROR: set-final failed");
}
intVal = field.getInt(instance);
System.out.println(" cantTouchThis is now " + intVal);
field.setAccessible(true);
field.setInt(instance, 87); // exercise int version
+ intVal = field.getInt(instance);
+ System.out.println(" cantTouchThis is now " + intVal);
field.set(instance, 88); // exercise Object version
intVal = field.getInt(instance);
System.out.println(" cantTouchThis is now " + intVal);