Add VMDebug method for allowing reflection from a specific class
Adds a native method VMDebug.allowHiddenApiReflectionFrom which
takes a Class object and passes it down to the runtime to be
exempt from subsequent non-SDK API checks.
This only works for Java debuggable processes, throws SecurityException
otherwise.
This does not work for non-SDK API uses by linking.
Bug: 64382372
Test: N/A
Change-Id: Ife39c973ddb306cabf648774bb16d8ad26150a2e
diff --git a/dalvik/src/main/java/dalvik/system/VMDebug.java b/dalvik/src/main/java/dalvik/system/VMDebug.java
index 195c251..7c03ed6 100644
--- a/dalvik/src/main/java/dalvik/system/VMDebug.java
+++ b/dalvik/src/main/java/dalvik/system/VMDebug.java
@@ -528,4 +528,16 @@
private static native void nativeAttachAgent(String agent, ClassLoader classLoader)
throws IOException;
+
+ /**
+ * Exempts a class from any future non-SDK API access checks.
+ * Methods declared in the class will be allowed to perform
+ * reflection/JNI against the framework completely unrestricted.
+ * Note that this does not affect uses of non-SDK APIs that the class links against.
+ * Note that this does not affect methods declared outside this class, e.g.
+ * inherited from a superclass or an implemented interface.
+ *
+ * @param klass The class whose methods should be exempted.
+ */
+ public static native void allowHiddenApiReflectionFrom(Class<?> klass);
}