author | dholmes |
Sat, 23 Jun 2018 01:32:41 -0400 | |
changeset 50735 | 2f2af62dfac7 |
permissions | -rw-r--r-- |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
1 |
/* |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
4 |
* |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
8 |
* |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
13 |
* accompanied this code). |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
14 |
* |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
18 |
* |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
21 |
* questions. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
22 |
*/ |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
23 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
24 |
/* |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
25 |
* @test |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
26 |
* @bug 8046171 |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
27 |
* @summary Test access to private methods between nestmates where there |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
28 |
* is an inheritance hierarchy and we invoke private methods that |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
29 |
* exist in specific classes in the hierarchy. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
30 |
* @run main TestReflectionHierarchy |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
31 |
* @run main/othervm -Dsun.reflect.noInflation=true TestReflectionHierarchy |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
32 |
*/ |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
33 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
34 |
// The first run will use NativeMethodAccessor and due to the limited number |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
35 |
// of calls we will not reach the inflation threshold. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
36 |
// The second run disables inflation so we will use the GeneratedMethodAccessor |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
37 |
// instead. In this way both sets of Reflection classes are tested. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
38 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
39 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
40 |
public class TestReflectionHierarchy { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
41 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
42 |
static class NestedA extends ExternalSuper { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
43 |
static final String ID = "NestedA::priv_invoke"; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
44 |
private String priv_invoke() { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
45 |
return ID; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
46 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
47 |
static void checkA(NestedA a) throws Throwable { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
48 |
verifyEquals((String)NestedA.class. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
49 |
getDeclaredMethod("priv_invoke", |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
50 |
new Class<?>[0]). |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
51 |
invoke(a, new Object[0]), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
52 |
NestedA.ID); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
53 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
54 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
55 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
56 |
static class NestedB extends NestedA { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
57 |
static final String ID = "NestedB::priv_invoke"; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
58 |
private String priv_invoke() { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
59 |
return ID; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
60 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
61 |
static void checkA(NestedA a) throws Throwable { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
62 |
verifyEquals((String)NestedA.class. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
63 |
getDeclaredMethod("priv_invoke", |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
64 |
new Class<?>[0]). |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
65 |
invoke(a, new Object[0]), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
66 |
NestedA.ID); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
67 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
68 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
69 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
70 |
static class NestedC extends NestedB { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
71 |
static final String ID = "NestedC::priv_invoke"; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
72 |
private String priv_invoke() { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
73 |
return ID; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
74 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
75 |
static void checkA(NestedA a) throws Throwable { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
76 |
verifyEquals((String)NestedA.class. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
77 |
getDeclaredMethod("priv_invoke", |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
78 |
new Class<?>[0]). |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
79 |
invoke(a, new Object[0]), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
80 |
NestedA.ID); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
81 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
82 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
83 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
84 |
static void checkA(NestedA a) throws Throwable { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
85 |
verifyEquals((String)NestedA.class. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
86 |
getDeclaredMethod("priv_invoke", |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
87 |
new Class<?>[0]). |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
88 |
invoke(a, new Object[0]), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
89 |
NestedA.ID); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
90 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
91 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
92 |
static void checkB(NestedB b) throws Throwable { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
93 |
verifyEquals((String)NestedB.class. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
94 |
getDeclaredMethod("priv_invoke", |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
95 |
new Class<?>[0]). |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
96 |
invoke(b, new Object[0]), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
97 |
NestedB.ID); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
98 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
99 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
100 |
static void checkC(NestedC c) throws Throwable { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
101 |
verifyEquals((String)NestedC.class. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
102 |
getDeclaredMethod("priv_invoke", |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
103 |
new Class<?>[0]). |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
104 |
invoke(c, new Object[0]), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
105 |
NestedC.ID); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
106 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
107 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
108 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
109 |
// Access to private members of classes outside the nest is |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
110 |
// not permitted. These tests should throw IllegalAccessException |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
111 |
// at runtime. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
112 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
113 |
static void checkExternalSuper(ExternalSuper s) throws Throwable { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
114 |
try { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
115 |
ExternalSuper.class. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
116 |
getDeclaredMethod("priv_invoke", new Class<?>[0]). |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
117 |
invoke(s, new Object[0]); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
118 |
throw new Error("Unexpected access to ExternalSuper.priv_invoke"); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
119 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
120 |
catch (IllegalAccessException iae) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
121 |
System.out.println("Got expected exception accessing ExternalSuper.priv_invoke:" + iae); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
122 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
123 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
124 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
125 |
static void checkExternalSub(ExternalSub s) throws Throwable { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
126 |
try { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
127 |
ExternalSub.class. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
128 |
getDeclaredMethod("priv_invoke", new Class<?>[0]). |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
129 |
invoke(s, new Object[0]); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
130 |
throw new Error("Unexpected access to ExternalSub.priv_invoke"); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
131 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
132 |
catch (IllegalAccessException iae) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
133 |
System.out.println("Got expected exception accessing ExternalSub.priv_invoke:" + iae); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
134 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
135 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
136 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
137 |
static void verifyEquals(String actual, String expected) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
138 |
if (!actual.equals(expected)) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
139 |
throw new Error("Expected " + expected + " but got " + actual); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
140 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
141 |
System.out.println("Check passed for " + expected); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
142 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
143 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
144 |
public static void main(String[] args) throws Throwable { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
145 |
NestedA a = new NestedA(); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
146 |
NestedB b = new NestedB(); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
147 |
NestedC c = new NestedC(); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
148 |
ExternalSub sub = new ExternalSub(); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
149 |
ExternalSuper sup = new ExternalSuper(); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
150 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
151 |
checkExternalSuper(sup); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
152 |
checkExternalSuper(a); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
153 |
checkExternalSuper(b); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
154 |
checkExternalSuper(c); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
155 |
checkExternalSuper(sub); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
156 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
157 |
checkA(a); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
158 |
checkA(b); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
159 |
checkA(c); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
160 |
checkA(sub); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
161 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
162 |
NestedA.checkA(a); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
163 |
NestedA.checkA(b); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
164 |
NestedA.checkA(c); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
165 |
NestedA.checkA(sub); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
166 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
167 |
NestedB.checkA(a); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
168 |
NestedB.checkA(b); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
169 |
NestedB.checkA(c); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
170 |
NestedB.checkA(sub); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
171 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
172 |
NestedC.checkA(a); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
173 |
NestedC.checkA(b); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
174 |
NestedC.checkA(c); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
175 |
NestedC.checkA(sub); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
176 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
177 |
checkB(b); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
178 |
checkB(c); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
179 |
checkB(sub); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
180 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
181 |
checkC(c); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
182 |
checkC(sub); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
183 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
184 |
checkExternalSub(sub); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
185 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
186 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
187 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
188 |
// Classes that are not part of the nest. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
189 |
// Being non-public allows us to declare them in this file. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
190 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
191 |
class ExternalSuper { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
192 |
static final String ID = "ExternalSuper::priv_invoke"; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
193 |
private String priv_invoke() { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
194 |
return ID; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
195 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
196 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
197 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
198 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
199 |
class ExternalSub extends TestReflectionHierarchy.NestedC { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
200 |
static final String ID = "ExternalSub::priv_invoke"; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
201 |
private String priv_invoke() { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
202 |
return ID; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
203 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff
changeset
|
204 |
} |