ART: Fix constructor access checking
Constructor access must be checked.
(cherry picked from commit 0dd76cd3f09f495a1b9a0e4f8712c09ff885c6fd)
Bug: 20639158
Change-Id: I3c586e9572a748d208bea43aa2349c3ef52a2ee5
diff --git a/test/100-reflect2/src/Main.java b/test/100-reflect2/src/Main.java
index 0cc1488..86a5ef8 100644
--- a/test/100-reflect2/src/Main.java
+++ b/test/100-reflect2/src/Main.java
@@ -266,9 +266,24 @@
show(ctor.newInstance(new char[] { 'x', 'y', 'z', '!' }, 1, 2));
}
+ private static void testPackagePrivate() {
+ try {
+ Class<?> c = Class.forName("sub.PPClass");
+ Constructor cons = c.getConstructor();
+ cons.newInstance();
+ throw new RuntimeException("Expected IllegalAccessException.");
+ } catch (IllegalAccessException e) {
+ // Expected.
+ } catch (Exception e) {
+ // Error.
+ e.printStackTrace();
+ }
+ }
+
public static void main(String[] args) throws Exception {
testFieldReflection();
testMethodReflection();
testConstructorReflection();
+ testPackagePrivate();
}
}