summaryrefslogtreecommitdiffstats
path: root/test/100-reflect2
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-04-27 17:26:37 -0700
committerAndreas Gampe <agampe@google.com>2015-04-27 19:41:54 -0700
commit8208bddbefa9613422b9c6a19ce39a24391beec3 (patch)
tree618f6ca8791dcf0eaf659f751197f985a9bdec2b /test/100-reflect2
parent97c96f5aab22f75dd54089bdc194588a4b5a2e8d (diff)
downloadart-8208bddbefa9613422b9c6a19ce39a24391beec3.zip
art-8208bddbefa9613422b9c6a19ce39a24391beec3.tar.gz
art-8208bddbefa9613422b9c6a19ce39a24391beec3.tar.bz2
ART: Fix constructor access checking
Constructor access must be checked. (cherry picked from commit 0dd76cd3f09f495a1b9a0e4f8712c09ff885c6fd) Bug: 20639158 Change-Id: I3c586e9572a748d208bea43aa2349c3ef52a2ee5
Diffstat (limited to 'test/100-reflect2')
-rw-r--r--test/100-reflect2/src/Main.java15
-rw-r--r--test/100-reflect2/src/sub/PPClass.java23
2 files changed, 38 insertions, 0 deletions
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 @@ class Main {
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();
}
}
diff --git a/test/100-reflect2/src/sub/PPClass.java b/test/100-reflect2/src/sub/PPClass.java
new file mode 100644
index 0000000..d972287
--- /dev/null
+++ b/test/100-reflect2/src/sub/PPClass.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package sub;
+
+// A package-private class with a public constructor.
+class PPClass {
+ public PPClass() {
+ }
+} \ No newline at end of file