author | alanb |
Fri, 10 Feb 2017 09:03:55 +0000 | |
changeset 43665 | 4bb003cad9b9 |
parent 36508 | 5f9eee6b383b |
child 44520 | 0553e129e0ec |
permissions | -rw-r--r-- |
36508 | 1 |
/* |
43665
4bb003cad9b9
8173393: Module system implementation refresh (2/2017)
alanb
parents:
36508
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
36508 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* package p3; |
|
26 |
* import java.lang.reflect.*; |
|
27 |
* import myloaders.MyDiffClassLoader; |
|
28 |
* |
|
29 |
* public class c3ReadEdgeDiffLoader { |
|
30 |
* public c3ReadEdgeDiffLoader() { |
|
43665
4bb003cad9b9
8173393: Module system implementation refresh (2/2017)
alanb
parents:
36508
diff
changeset
|
31 |
* // The goal is to establish a read edge between module m1x |
36508 | 32 |
* // which is the module where p3.c3ReadEdgeDiffLoader is defined, |
33 |
* // and the unnamed module that defines c4. This must be |
|
34 |
* // done in 2 steps: |
|
35 |
* // |
|
43665
4bb003cad9b9
8173393: Module system implementation refresh (2/2017)
alanb
parents:
36508
diff
changeset
|
36 |
* // Step #1: Establish a read edge between m1x, where c3ReadEdgeDiffLoader |
36508 | 37 |
* // is defined, and the System ClassLoader's unnamed module, |
38 |
* // where MyDiffClassLoader is defined. This read edge |
|
39 |
* // is needed before we can obtain MyDiffClassLoader.loader2's unnamed module. |
|
40 |
* // |
|
43665
4bb003cad9b9
8173393: Module system implementation refresh (2/2017)
alanb
parents:
36508
diff
changeset
|
41 |
* // Step #2: Establish a read edge between m1x, where c3ReadEdgeDiffLoader |
36508 | 42 |
* // is defined, and the MyDiffClassLoader.loader2's unnamed module, |
43 |
* // where c4 will be defined. |
|
44 |
* |
|
43665
4bb003cad9b9
8173393: Module system implementation refresh (2/2017)
alanb
parents:
36508
diff
changeset
|
45 |
* // Step #1: read edge m1x -> System ClassLoader's unnamed module |
4bb003cad9b9
8173393: Module system implementation refresh (2/2017)
alanb
parents:
36508
diff
changeset
|
46 |
* Module m1x = c3ReadEdgeDiffLoader.class.getModule(); |
36508 | 47 |
* ClassLoader system_loader = ClassLoader.getSystemClassLoader(); |
43665
4bb003cad9b9
8173393: Module system implementation refresh (2/2017)
alanb
parents:
36508
diff
changeset
|
48 |
* Module unnamed_module_one = system_loader.getUnnamedModule(); |
4bb003cad9b9
8173393: Module system implementation refresh (2/2017)
alanb
parents:
36508
diff
changeset
|
49 |
* m1x.addReads(unnamed_module_one); |
36508 | 50 |
* |
43665
4bb003cad9b9
8173393: Module system implementation refresh (2/2017)
alanb
parents:
36508
diff
changeset
|
51 |
* // Step #2: read edge m1x -> MyDiffClassLoader.loader2's unnamed module |
36508 | 52 |
* ClassLoader loader2 = MyDiffClassLoader.loader2; |
43665
4bb003cad9b9
8173393: Module system implementation refresh (2/2017)
alanb
parents:
36508
diff
changeset
|
53 |
* Module unnamed_module_two = loader2.getUnnamedModule(); |
4bb003cad9b9
8173393: Module system implementation refresh (2/2017)
alanb
parents:
36508
diff
changeset
|
54 |
* m1x.addReads(unnamed_module_two); |
36508 | 55 |
* |
43665
4bb003cad9b9
8173393: Module system implementation refresh (2/2017)
alanb
parents:
36508
diff
changeset
|
56 |
* // Attempt access - should succeed since m1x can read |
36508 | 57 |
* // MyDiffClassLoader.loader2's unnamed module |
58 |
* c4 c4_obj = new c4(); |
|
59 |
* c4_obj.method4(); |
|
60 |
* } |
|
61 |
* } |
|
62 |
*/ |
|
63 |
||
64 |
class p3/c3ReadEdgeDiffLoader { |
|
65 |
0xCAFEBABE; |
|
66 |
0; // minor version |
|
67 |
52; // version |
|
68 |
[46] { // Constant Pool |
|
69 |
; // first element is empty |
|
70 |
Method #11 #18; // #1 at 0x0A |
|
71 |
class #19; // #2 at 0x0F |
|
72 |
Method #20 #21; // #3 at 0x12 |
|
73 |
Method #22 #23; // #4 at 0x17 |
|
74 |
Method #22 #24; // #5 at 0x1C |
|
75 |
Method #25 #26; // #6 at 0x21 |
|
76 |
Field #27 #28; // #7 at 0x26 |
|
77 |
class #29; // #8 at 0x2B |
|
78 |
Method #8 #18; // #9 at 0x2E |
|
79 |
Method #8 #30; // #10 at 0x33 |
|
80 |
class #31; // #11 at 0x38 |
|
81 |
Utf8 "<init>"; // #12 at 0x3B |
|
82 |
Utf8 "()V"; // #13 at 0x44 |
|
83 |
Utf8 "Code"; // #14 at 0x4A |
|
84 |
Utf8 "LineNumberTable"; // #15 at 0x51 |
|
85 |
Utf8 "SourceFile"; // #16 at 0x63 |
|
86 |
Utf8 "c3ReadEdgeDiffLoader.java"; // #17 at 0x70 |
|
87 |
NameAndType #12 #13; // #18 at 0x8C |
|
88 |
Utf8 "p3/c3ReadEdgeDiffLoader"; // #19 at 0x91 |
|
89 |
class #32; // #20 at 0xAB |
|
90 |
NameAndType #33 #34; // #21 at 0xAE |
|
91 |
class #35; // #22 at 0xB3 |
|
92 |
NameAndType #36 #37; // #23 at 0xB6 |
|
93 |
NameAndType #38 #34; // #24 at 0xBB |
|
94 |
class #39; // #25 at 0xC0 |
|
95 |
NameAndType #40 #41; // #26 at 0xC3 |
|
96 |
class #42; // #27 at 0xC8 |
|
97 |
NameAndType #43 #44; // #28 at 0xCB |
|
98 |
Utf8 "c4"; // #29 at 0xD0 |
|
99 |
NameAndType #45 #13; // #30 at 0xD8 |
|
100 |
Utf8 "java/lang/Object"; // #31 at 0xDD |
|
101 |
Utf8 "java/lang/Class"; // #32 at 0xF0 |
|
102 |
Utf8 "getModule"; // #33 at 0x0102 |
|
103 |
Utf8 "()Ljava/lang/reflect/Module;"; // #34 at 0x010E |
|
104 |
Utf8 "java/lang/ClassLoader"; // #35 at 0x012D |
|
105 |
Utf8 "getSystemClassLoader"; // #36 at 0x0145 |
|
106 |
Utf8 "()Ljava/lang/ClassLoader;"; // #37 at 0x015C |
|
107 |
Utf8 "getUnnamedModule"; // #38 at 0x0178 |
|
108 |
Utf8 "java/lang/reflect/Module"; // #39 at 0x018B |
|
109 |
Utf8 "addReads"; // #40 at 0x01A6 |
|
110 |
Utf8 "(Ljava/lang/reflect/Module;)Ljava/lang/reflect/Module;"; // #41 at 0x01B1 |
|
111 |
Utf8 "myloaders/MyDiffClassLoader"; // #42 at 0x01EA |
|
112 |
Utf8 "loader2"; // #43 at 0x0208 |
|
113 |
Utf8 "Lmyloaders/MyDiffClassLoader;"; // #44 at 0x0212 |
|
114 |
Utf8 "method4"; // #45 at 0x0232 |
|
115 |
} // Constant Pool |
|
116 |
||
117 |
0x0021; // access |
|
118 |
#2;// this_cpx |
|
119 |
#11;// super_cpx |
|
120 |
||
121 |
[0] { // Interfaces |
|
122 |
} // Interfaces |
|
123 |
||
124 |
[0] { // fields |
|
125 |
} // fields |
|
126 |
||
127 |
[1] { // methods |
|
128 |
{ // Member at 0x0248 |
|
129 |
0x0001; // access |
|
130 |
#12; // name_cpx |
|
131 |
#13; // sig_cpx |
|
132 |
[1] { // Attributes |
|
133 |
Attr(#14, 123) { // Code at 0x0250 |
|
134 |
2; // max_stack |
|
135 |
7; // max_locals |
|
136 |
Bytes[59]{ |
|
137 |
0x2AB700011202B600; |
|
138 |
0x034CB800044D2CB6; |
|
139 |
0x00054E2B2DB60006; |
|
140 |
0x57B200073A041904; |
|
141 |
0xB600053A052B1905; |
|
142 |
0xB6000657BB000859; |
|
143 |
0xB700093A061906B6; |
|
144 |
0x000AB1; |
|
145 |
}; |
|
146 |
[0] { // Traps |
|
147 |
} // end Traps |
|
148 |
[1] { // Attributes |
|
149 |
Attr(#15, 46) { // LineNumberTable at 0x029D |
|
150 |
[11] { // LineNumberTable |
|
151 |
0 33; // at 0x02A9 |
|
152 |
4 34; // at 0x02AD |
|
153 |
10 36; // at 0x02B1 |
|
154 |
14 37; // at 0x02B5 |
|
155 |
19 39; // at 0x02B9 |
|
156 |
25 41; // at 0x02BD |
|
157 |
30 42; // at 0x02C1 |
|
158 |
37 46; // at 0x02C5 |
|
159 |
44 49; // at 0x02C9 |
|
160 |
53 50; // at 0x02CD |
|
161 |
58 51; // at 0x02D1 |
|
162 |
} |
|
163 |
} // end LineNumberTable |
|
164 |
} // Attributes |
|
165 |
} // end Code |
|
166 |
} // Attributes |
|
167 |
} // Member |
|
168 |
} // methods |
|
169 |
||
170 |
[1] { // Attributes |
|
171 |
Attr(#16, 2) { // SourceFile at 0x02D3 |
|
172 |
#17; |
|
173 |
} // end SourceFile |
|
174 |
} // Attributes |
|
175 |
} // end class p3/c3ReadEdgeDiffLoader |