author | hseigel |
Wed, 26 Jun 2019 09:06:32 -0400 | |
changeset 55497 | d3a33953b936 |
permissions | -rw-r--r-- |
55497
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
1 |
/* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
2 |
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
4 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
8 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
13 |
* accompanied this code). |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
14 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
18 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
21 |
* questions. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
22 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
23 |
*/ |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
24 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
25 |
/* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
26 |
* INVOKESPECIAL EXPECTED RESULTS |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
27 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
28 |
* From JVMS 3rd edition: invokespecial instruction: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
29 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
30 |
* Invoke instance method; special handling for superclass, private, and instance |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
31 |
* initialization method invocations |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
32 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
33 |
* The named method is resolved (5.4.3.3). Finally, if the resolved method is |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
34 |
* protected (4.7), and it is a member of a superclass of the current class, and |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
35 |
* the method is not declared in the same run-time package (5.3) as the current |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
36 |
* class, then the class of objectref must be either the current class or a |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
37 |
* subclass of the current class. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
38 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
39 |
* Next, the resolved method is selected for invocation unless all of the |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
40 |
* following conditions are true: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
41 |
* * The ACC_SUPER flag (see Table 4.1, "Class access and property modifiers") is set for the current class. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
42 |
* * The class of the resolved method is a superclass of the current class. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
43 |
* * The resolved method is not an instance initialization method (3.9). |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
44 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
45 |
* If the above conditions are true, the actual method to be invoked is selected |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
46 |
* by the following lookup procedure. Let C be the direct superclass of the |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
47 |
* current class: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
48 |
* * If C contains a declaration for an instance method with the same name and |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
49 |
* descriptor as the resolved method, then this method will be invoked. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
50 |
* The lookup procedure terminates. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
51 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
52 |
* * Otherwise, if C has a superclass, this same lookup procedure is performed |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
53 |
* recursively using the direct superclass of C. The method to be invoked is |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
54 |
* the result of the recursive invocation of this lookup procedure. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
55 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
56 |
* * Otherwise, an AbstractMethodError? is raised. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
57 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
58 |
* During resolution of the symbolic reference to the method, any of the |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
59 |
* exceptions pertaining to method resolution documented in Section 5.4.3.3 can be |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
60 |
* thrown. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
61 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
62 |
* Otherwise, if the resolved method is an instance initialization method, and the |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
63 |
* class in which it is declared is not the class symbolically referenced by the |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
64 |
* instruction, a NoSuchMethodError? is thrown. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
65 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
66 |
* Otherwise, if the resolved method is a class (static) method, the invokespecial |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
67 |
* instruction throws an IncompatibleClassChangeError?. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
68 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
69 |
* Otherwise, if no method matching the resolved name and descriptor is selected, |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
70 |
* invokespecial throws an AbstractMethodError?. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
71 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
72 |
* Otherwise, if the selected method is abstract, invokespecial throws an |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
73 |
* AbstractMethodError?. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
74 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
75 |
* RUNTIME EXCEPTIONS |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
76 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
77 |
* Otherwise, if objectref is null, the invokespecial instruction throws a NullPointerException?. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
78 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
79 |
* Otherwise, if the selected method is native and the code that implements the |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
80 |
* method cannot be bound, invokespecial throws an UnsatisfiedLinkError?. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
81 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
82 |
* NOTES |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
83 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
84 |
* The difference between the invokespecial and the invokevirtual instructions is |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
85 |
* that invokevirtual invokes a method based on the class of the object. The |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
86 |
* invokespecial instruction is used to invoke instance initialization methods |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
87 |
* (3.9) as well as private methods and methods of a superclass of the current |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
88 |
* class. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
89 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
90 |
* ACC_SUPER: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
91 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
92 |
* The setting of the ACC_SUPER flag indicates which of two alternative semantics |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
93 |
* for its invokespecial instruction the Java virtual machine is to express; the |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
94 |
* ACC_SUPER flag exists for backward compatibility for code compiled by Sun's |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
95 |
* older compilers for the Java programming language. All new implementations of |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
96 |
* the Java virtual machine should implement the semantics for invokespecial |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
97 |
* documented in this specification. All new compilers to the instruction set of |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
98 |
* the Java virtual machine should set the ACC_SUPER flag. Sun's older compilers |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
99 |
* generated ClassFile? flags with ACC_SUPER unset. Sun's older Java virtual |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
100 |
* machine implementations ignore the flag if it is set. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
101 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
102 |
* ACC_SUPER 0x0020 Treat superclass methods specially when invoked by the |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
103 |
* invokespecial instruction. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
104 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
105 |
* My Translation: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
106 |
* 1. compile-time resolved class B |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
107 |
* 2. A,B,C direct superclass relationships |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
108 |
* 3. If B.m is protected |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
109 |
* - if the caller is in B |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
110 |
* then runtime resolved class must be in B or C |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
111 |
* - if the caller is in C |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
112 |
* then runtime resolved class must be in C |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
113 |
* TODO: otherwise what is thrown? <noWikiWord>AbstractMethodError? |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
114 |
* 4. If B.m is an instance initialization method, |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
115 |
* invoke B.m |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
116 |
* 5. If backward compatible caller does not set ACC_SUPER, |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
117 |
* invoke B.m |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
118 |
* 6. If B is not a superclass of the caller, e.g. A is caller, or unrelated X |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
119 |
* is the caller, invoke B.m |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
120 |
* 7. Otherwise: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
121 |
* If superclass of caller contains name/sig match, use it |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
122 |
* Else, recursively through that superclass |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
123 |
* 8. If none found, throw AbstractMethodError |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
124 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
125 |
* Note: there is NO mention of overriding or accessibility in determining |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
126 |
* resolved method, except for if the compile-time type is protected. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
127 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
128 |
* Case 1: B.m is protected |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
129 |
* Caller in A: if runtime resolved class in A.m, AbstractMethodError |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
130 |
* Caller in B: if runtime resolved class in A.m, AbstractMethodError |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
131 |
* Case 2: B.m is an instance initialization method |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
132 |
* Always invoke B.m |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
133 |
* Case 3: older javac, caller does not set ACC_SUPER |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
134 |
* Always invoke B.m |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
135 |
* Case 4: A or X (not in hierarchy) calls invokespecial on B.m, invoke B.m |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
136 |
* Case 5: Caller in B: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
137 |
* if A.m exists, call it, else <noWikiWord>AbstractMethodError |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
138 |
* Caller in C: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
139 |
* if B.m exists, call it |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
140 |
* if B.m does not exist, and A.m exists, call it |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
141 |
*/ |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
142 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
143 |
// TODO: classes without ACC_SUPER attribute |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
144 |
// TODO: B.m is an instance initialization method |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
145 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
146 |
/* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
147 |
* invokespecial <method-spec> |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
148 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
149 |
* invokespecial is used in certain special cases to invoke a method |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
150 |
* Specifically, invokespecial is used to invoke: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
151 |
* - the instance initialization method, <init> |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
152 |
* - a private method of this |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
153 |
* - a method in a superclass of this |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
154 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
155 |
* The main use of invokespecial is to invoke an object's instance |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
156 |
* initialization method, <init>, during the construction phase for a new object. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
157 |
* For example, when you write in Java: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
158 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
159 |
* new StringBuffer() |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
160 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
161 |
* code like the following is generated: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
162 |
* new java/lang/StringBuffer ; create a new StringBuffer |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
163 |
* dup ; make an extra reference to the new instance |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
164 |
* ; now call an instance initialization method |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
165 |
* invokespecial java/lang/StringBuffer/<init>()V |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
166 |
* ; stack now contains an initialized StringBuffer. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
167 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
168 |
* invokespecial is also used by the Java language by the 'super' keyword to |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
169 |
* access a superclass's version of a method. For example, in the class: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
170 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
171 |
* class Example { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
172 |
* // override equals |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
173 |
* public boolean equals(Object x) { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
174 |
* // call Object's version of equals |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
175 |
* return super.equals(x); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
176 |
* } |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
177 |
* } |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
178 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
179 |
* the 'super.equals(x)' expression is compiled to: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
180 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
181 |
* aload_0 ; push 'this' onto the stack |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
182 |
* aload_1 ; push the first argument (i.e. x) onto the stack |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
183 |
* ; now invoke Object's equals() method. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
184 |
* invokespecial java/lang/Object/equals(Ljava/lang/Object;)Z |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
185 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
186 |
* Finally, invokespecial is used to invoke a private method. Remember that |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
187 |
* private methods are only visible to other methods belonging the same class as |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
188 |
* the private method. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
189 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
190 |
* Before performing the method invocation, the class and the method identified |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
191 |
* by <method-spec> are resolved. See Chapter 9 for a description of how methods |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
192 |
* are resolved. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
193 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
194 |
* invokespecial first looks at the descriptor given in <method-spec>, and |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
195 |
* determines how many argument words the method takes (this may be zero). It |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
196 |
* pops these arguments off the operand stack. Next it pops objectref (a |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
197 |
* reference to an object) off the operand stack. objectref must be an instance |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
198 |
* of the class named in <method-spec>, or one of its subclasses. The interpreter |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
199 |
* searches the list of methods defined by the class named in <method-spec>, |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
200 |
* looking for a method called methodname whose descriptor is descriptor. This |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
201 |
* search is not based on the runtime type of objectref, but on the compile time |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
202 |
* type given in <method-spec>. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
203 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
204 |
* Once a method has been located, invokespecial calls the method. First, if |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
205 |
* the method is marked as synchronized, the monitor associated with objectref is |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
206 |
* entered. Next, a new stack frame structure is established on the call stack. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
207 |
* Then the arguments for the method (which were popped off the current method's |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
208 |
* operand stack) are placed in local variables of the new stack frame structure. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
209 |
* arg1 is stored in local variable 1, arg2 is stored in local variable 2 and so |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
210 |
* on. objectref is stored in local variable 0 (the local variable used for the |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
211 |
* special Java variable this). Finally, execution continues at the first |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
212 |
*instruction in the bytecode of the new method. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
213 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
214 |
* Methods marked as native are handled slightly differently. For native |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
215 |
* methods, the runtime system locates the platform-specific code for the method, |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
216 |
* loading it and linking it into the JVM if necessary. Then the native method |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
217 |
* code is executed with the arguments popped from the operand stack. The exact |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
218 |
* mechanism used to invoke native methods is implementation-specific. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
219 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
220 |
* When the method called by invokespecial returns, any single (or double) word |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
221 |
* return result is placed on the operand stack of the current method. If the |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
222 |
* invoked method was marked as synchronized, the monitor associated with |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
223 |
* objectref is exited. Execution continues at the instruction that follows |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
224 |
* invokespecial in the bytecode. |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
225 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
226 |
* Notes |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
227 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
228 |
* 1. In Java Virtual Machine implementations prior to version JDK 1.02, this |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
229 |
* instruction was called invokenonvirtual, and was less restrictive than |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
230 |
* invokespecial - it wasn't limited to invoking only superclass, private or |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
231 |
* <init> methods. The class access flag ACC_SUPER (see Chapter 4) is used to |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
232 |
* indicate which semantics are used by a class. In older class files, the |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
233 |
* ACC_SUPER flag is unset. In all new classes, the ACC_SUPER flag should be set, |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
234 |
* indicating that the restrictions enforced by invokespecial are obeyed. (In |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
235 |
* practice, all the common uses of invokenonvirtual continue to be supported |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
236 |
* by invokespecial, so this change should have little impact on JVM users). |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
237 |
* |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
238 |
*/ |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
239 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
240 |
package invokespecial; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
241 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
242 |
import static jdk.internal.org.objectweb.asm.Opcodes.*; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
243 |
import shared.AbstractGenerator; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
244 |
import shared.AccessType; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
245 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
246 |
import java.util.HashMap; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
247 |
import java.util.Map; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
248 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
249 |
public class Generator extends AbstractGenerator { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
250 |
public static void main (String[] args) throws Exception { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
251 |
new Generator(args).run(); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
252 |
} |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
253 |
public Generator(String[] args) { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
254 |
super(args); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
255 |
} |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
256 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
257 |
protected Checker getChecker(Class paramClass, Class targetClass) { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
258 |
return new Checker(paramClass, targetClass); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
259 |
} |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
260 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
261 |
public void run() throws Exception { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
262 |
// Specify package names |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
263 |
String pkg1 = "a."; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
264 |
String pkg2 = "b."; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
265 |
String[] packages = new String[] { "", pkg1, pkg2 }; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
266 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
267 |
boolean isPassed = true; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
268 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
269 |
// HIERARCHIES |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
270 |
// The following triples will be used during further |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
271 |
// hierarchy construction and will specify packages for A, B and C |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
272 |
String[][] packageSets = new String[][] { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
273 |
{ "", "", "" } |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
274 |
, { "", pkg1, pkg1 } |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
275 |
, { "", pkg1, pkg2 } |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
276 |
, { pkg1, "", pkg1 } |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
277 |
, { pkg1, "", pkg2 } |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
278 |
, { pkg1, pkg1, "" } |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
279 |
, { pkg1, pkg2, "" } |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
280 |
, { pkg1, pkg1, pkg1 } |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
281 |
, { pkg1, pkg1, pkg2 } |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
282 |
, { pkg1, pkg2, pkg1 } |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
283 |
, { pkg1, pkg2, pkg2 } |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
284 |
}; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
285 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
286 |
String [] header = new String[] { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
287 |
String.format("%30s %35s", "Method access modifiers", "Call site location") |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
288 |
, String.format("%4s %-10s %-10s %-10s %7s %7s %7s %7s %7s %7s %7s" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
289 |
, " # " |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
290 |
, "A.m()" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
291 |
, "B.m()" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
292 |
, "C.m()" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
293 |
, " A " |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
294 |
, "pkgA" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
295 |
, " B " |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
296 |
, " pkgB" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
297 |
, " C " |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
298 |
, "pkgC " |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
299 |
, " X " |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
300 |
) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
301 |
, "-----------------------------------------------------------------------------------------------------------" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
302 |
}; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
303 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
304 |
// Print header |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
305 |
for (String str : header) { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
306 |
System.out.println(str); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
307 |
} |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
308 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
309 |
// Iterate over all interesting package combinations |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
310 |
for (String[] pkgSet : packageSets) { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
311 |
String packageA = pkgSet[0]; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
312 |
String packageB = pkgSet[1]; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
313 |
String packageC = pkgSet[2]; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
314 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
315 |
String classNameA = packageA + "A"; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
316 |
String classNameB = packageB + "B"; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
317 |
String classNameC = packageC + "C"; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
318 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
319 |
// For all possible access modifier combinations |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
320 |
for (AccessType accessFlagA : AccessType.values()) { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
321 |
for (AccessType accessFlagB : AccessType.values()) { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
322 |
for (AccessType accessFlagC : AccessType.values()) { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
323 |
Map<String, byte[]> classes = new HashMap<String, byte[]>(); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
324 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
325 |
String calleeClassName = classNameB; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
326 |
int classFlags = ACC_PUBLIC; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
327 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
328 |
// The following hierarhcy is created: |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
329 |
// c.C extends b.B extends a.A extends Object - base hierarchy |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
330 |
// X extends Object - external caller |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
331 |
// c.Caller, b.Caller, a.Caller extends Object - package callers |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
332 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
333 |
// Generate result storage |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
334 |
classes.put( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
335 |
"Result" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
336 |
, new ClassGenerator( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
337 |
"Result" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
338 |
, "java.lang.Object" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
339 |
, ACC_PUBLIC |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
340 |
) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
341 |
.addField( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
342 |
ACC_PUBLIC | ACC_STATIC |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
343 |
, "value" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
344 |
, "java.lang.String" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
345 |
) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
346 |
.getClassFile() |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
347 |
); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
348 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
349 |
// Generate class A |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
350 |
classes.put( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
351 |
classNameA |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
352 |
, new ClassGenerator( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
353 |
classNameA |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
354 |
, "java.lang.Object" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
355 |
, classFlags |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
356 |
) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
357 |
.addTargetConstructor(accessFlagA) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
358 |
.addTargetMethod(accessFlagA) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
359 |
.addCaller(calleeClassName) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
360 |
.getClassFile() |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
361 |
); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
362 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
363 |
// Generate class B |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
364 |
classes.put( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
365 |
classNameB |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
366 |
, new ClassGenerator( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
367 |
classNameB |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
368 |
, classNameA |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
369 |
, classFlags |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
370 |
) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
371 |
.addTargetConstructor(accessFlagB) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
372 |
.addTargetMethod(accessFlagB) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
373 |
.addCaller(calleeClassName) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
374 |
.getClassFile() |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
375 |
); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
376 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
377 |
// Generate class C |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
378 |
classes.put( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
379 |
classNameC |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
380 |
, new ClassGenerator( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
381 |
classNameC |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
382 |
, classNameB |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
383 |
, classFlags |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
384 |
) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
385 |
.addTargetConstructor(accessFlagC) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
386 |
.addTargetMethod(accessFlagC) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
387 |
.addCaller(calleeClassName) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
388 |
.getClassFile() |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
389 |
); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
390 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
391 |
// Generate class X |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
392 |
String classNameX = "x.X"; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
393 |
classes.put( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
394 |
classNameX |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
395 |
, new ClassGenerator( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
396 |
classNameX |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
397 |
, "java.lang.Object" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
398 |
, classFlags |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
399 |
) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
400 |
.addTargetMethod(accessFlagC) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
401 |
.addCaller(calleeClassName) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
402 |
.getClassFile() |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
403 |
); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
404 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
405 |
// Generate package callers |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
406 |
for (String pkg : packages) { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
407 |
classes.put( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
408 |
pkg+"Caller" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
409 |
, new ClassGenerator( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
410 |
pkg+"Caller" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
411 |
, "java.lang.Object" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
412 |
, classFlags |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
413 |
) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
414 |
.addCaller(calleeClassName) |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
415 |
.getClassFile() |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
416 |
); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
417 |
} |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
418 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
419 |
String[] callSites = new String[] { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
420 |
classNameA |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
421 |
, packageA+"Caller" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
422 |
, classNameB |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
423 |
, packageB+"Caller" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
424 |
, classNameC |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
425 |
, packageC+"Caller" |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
426 |
, classNameX |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
427 |
}; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
428 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
429 |
String caseDescription = String.format( |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
430 |
"%-10s %-10s %-10s| " |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
431 |
, classNameA + " " + accessFlagA |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
432 |
, classNameB + " " + accessFlagB |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
433 |
, classNameC + " " + accessFlagC |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
434 |
); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
435 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
436 |
boolean result = exec(classes, caseDescription, calleeClassName, classNameC, callSites); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
437 |
isPassed = isPassed && result; |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
438 |
} |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
439 |
} |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
440 |
} |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
441 |
} |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
442 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
443 |
// Print footer |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
444 |
for (int i = header.length-1; i >= 0; i--) { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
445 |
System.out.println(header[i]); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
446 |
} |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
447 |
|
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
448 |
if (executeTests) { |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
449 |
System.out.printf("\nEXECUTION STATUS: %s\n", (isPassed? "PASSED" : "FAILED")); |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
450 |
} |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
451 |
} |
d3a33953b936
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff
changeset
|
452 |
} |