Add access checks to Method and Field reflection.
Art side of this change. Has a corresponding libcore change.
Bug: 13620925
Change-Id: Ie67f802a2a400e8212b489b9a261b7028422d8ba
diff --git a/test/046-reflect/expected.txt b/test/046-reflect/expected.txt
index fcfaf2f..55b0dbe 100644
--- a/test/046-reflect/expected.txt
+++ b/test/046-reflect/expected.txt
@@ -81,7 +81,8 @@
Field type is int
Access flags are 0x11
cantTouchThis is 77
- cantTouchThis is now 99
+ as expected: set-final throws exception
+ cantTouchThis is still 77
public final int Target.cantTouchThis accessible=false
public final int Target.cantTouchThis accessible=true
cantTouchThis is now 87
diff --git a/test/046-reflect/src/Main.java b/test/046-reflect/src/Main.java
index dfb0d8f..d60fcb4 100644
--- a/test/046-reflect/src/Main.java
+++ b/test/046-reflect/src/Main.java
@@ -335,11 +335,12 @@
System.out.println(" cantTouchThis is " + intVal);
try {
field.setInt(instance, 99);
+ System.out.println("ERROR: set-final did not throw exception");
} catch (IllegalAccessException iae) {
- System.out.println("ERROR: set-final failed");
+ System.out.println(" as expected: set-final throws exception");
}
intVal = field.getInt(instance);
- System.out.println(" cantTouchThis is now " + intVal);
+ System.out.println(" cantTouchThis is still " + intVal);
System.out.println(" " + field + " accessible=" + field.isAccessible());
field.setAccessible(true);