author | coleenp |
Fri, 04 Jan 2019 15:06:01 -0500 | |
changeset 53149 | 259c36ef27df |
parent 51444 | 3e5d28e6de32 |
child 53432 | 1ec56532ae0c |
permissions | -rw-r--r-- |
14385 | 1 |
/* |
49677 | 2 |
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. |
14385 | 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 |
#include "precompiled.hpp" |
|
26 |
#include "classfile/bytecodeAssembler.hpp" |
|
27 |
#include "classfile/defaultMethods.hpp" |
|
28 |
#include "classfile/symbolTable.hpp" |
|
48463
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
29 |
#include "classfile/systemDictionary.hpp" |
33736
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
30 |
#include "logging/log.hpp" |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
31 |
#include "logging/logStream.hpp" |
14385 | 32 |
#include "memory/allocation.hpp" |
33 |
#include "memory/metadataFactory.hpp" |
|
34 |
#include "memory/resourceArea.hpp" |
|
34666 | 35 |
#include "runtime/handles.inline.hpp" |
14385 | 36 |
#include "runtime/signature.hpp" |
37 |
#include "runtime/thread.hpp" |
|
38 |
#include "oops/instanceKlass.hpp" |
|
39 |
#include "oops/klass.hpp" |
|
40 |
#include "oops/method.hpp" |
|
41 |
#include "utilities/accessFlags.hpp" |
|
42 |
#include "utilities/exceptions.hpp" |
|
43 |
#include "utilities/ostream.hpp" |
|
44 |
#include "utilities/pair.hpp" |
|
45 |
#include "utilities/resourceHash.hpp" |
|
46 |
||
47 |
typedef enum { QUALIFIED, DISQUALIFIED } QualifiedState; |
|
48 |
||
49 |
// Because we use an iterative algorithm when iterating over the type |
|
50 |
// hierarchy, we can't use traditional scoped objects which automatically do |
|
51 |
// cleanup in the destructor when the scope is exited. PseudoScope (and |
|
52 |
// PseudoScopeMark) provides a similar functionality, but for when you want a |
|
53 |
// scoped object in non-stack memory (such as in resource memory, as we do |
|
54 |
// here). You've just got to remember to call 'destroy()' on the scope when |
|
55 |
// leaving it (and marks have to be explicitly added). |
|
56 |
class PseudoScopeMark : public ResourceObj { |
|
57 |
public: |
|
58 |
virtual void destroy() = 0; |
|
59 |
}; |
|
60 |
||
61 |
class PseudoScope : public ResourceObj { |
|
62 |
private: |
|
63 |
GrowableArray<PseudoScopeMark*> _marks; |
|
64 |
public: |
|
65 |
||
66 |
static PseudoScope* cast(void* data) { |
|
67 |
return static_cast<PseudoScope*>(data); |
|
68 |
} |
|
69 |
||
70 |
void add_mark(PseudoScopeMark* psm) { |
|
71 |
_marks.append(psm); |
|
72 |
} |
|
73 |
||
74 |
void destroy() { |
|
75 |
for (int i = 0; i < _marks.length(); ++i) { |
|
76 |
_marks.at(i)->destroy(); |
|
77 |
} |
|
78 |
} |
|
79 |
}; |
|
80 |
||
81 |
static void print_slot(outputStream* str, Symbol* name, Symbol* signature) { |
|
82 |
str->print("%s%s", name->as_C_string(), signature->as_C_string()); |
|
83 |
} |
|
84 |
||
85 |
static void print_method(outputStream* str, Method* mo, bool with_class=true) { |
|
86 |
if (with_class) { |
|
87 |
str->print("%s.", mo->klass_name()->as_C_string()); |
|
88 |
} |
|
89 |
print_slot(str, mo->name(), mo->signature()); |
|
90 |
} |
|
91 |
||
92 |
/** |
|
93 |
* Perform a depth-first iteration over the class hierarchy, applying |
|
94 |
* algorithmic logic as it goes. |
|
95 |
* |
|
96 |
* This class is one half of the inheritance hierarchy analysis mechanism. |
|
97 |
* It is meant to be used in conjunction with another class, the algorithm, |
|
98 |
* which is indicated by the ALGO template parameter. This class can be |
|
99 |
* paired with any algorithm class that provides the required methods. |
|
100 |
* |
|
101 |
* This class contains all the mechanics for iterating over the class hierarchy |
|
102 |
* starting at a particular root, without recursing (thus limiting stack growth |
|
103 |
* from this point). It visits each superclass (if present) and superinterface |
|
104 |
* in a depth-first manner, with callbacks to the ALGO class as each class is |
|
105 |
* encountered (visit()), The algorithm can cut-off further exploration of a |
|
106 |
* particular branch by returning 'false' from a visit() call. |
|
107 |
* |
|
108 |
* The ALGO class, must provide a visit() method, which each of which will be |
|
109 |
* called once for each node in the inheritance tree during the iteration. In |
|
110 |
* addition, it can provide a memory block via new_node_data(InstanceKlass*), |
|
111 |
* which it can use for node-specific storage (and access via the |
|
112 |
* current_data() and data_at_depth(int) methods). |
|
113 |
* |
|
114 |
* Bare minimum needed to be an ALGO class: |
|
115 |
* class Algo : public HierarchyVisitor<Algo> { |
|
116 |
* void* new_node_data(InstanceKlass* cls) { return NULL; } |
|
117 |
* void free_node_data(void* data) { return; } |
|
118 |
* bool visit() { return true; } |
|
119 |
* }; |
|
120 |
*/ |
|
121 |
template <class ALGO> |
|
122 |
class HierarchyVisitor : StackObj { |
|
123 |
private: |
|
124 |
||
125 |
class Node : public ResourceObj { |
|
126 |
public: |
|
127 |
InstanceKlass* _class; |
|
128 |
bool _super_was_visited; |
|
129 |
int _interface_index; |
|
130 |
void* _algorithm_data; |
|
131 |
||
132 |
Node(InstanceKlass* cls, void* data, bool visit_super) |
|
133 |
: _class(cls), _super_was_visited(!visit_super), |
|
134 |
_interface_index(0), _algorithm_data(data) {} |
|
135 |
||
136 |
int number_of_interfaces() { return _class->local_interfaces()->length(); } |
|
137 |
int interface_index() { return _interface_index; } |
|
138 |
void set_super_visited() { _super_was_visited = true; } |
|
139 |
void increment_visited_interface() { ++_interface_index; } |
|
140 |
void set_all_interfaces_visited() { |
|
141 |
_interface_index = number_of_interfaces(); |
|
142 |
} |
|
143 |
bool has_visited_super() { return _super_was_visited; } |
|
144 |
bool has_visited_all_interfaces() { |
|
145 |
return interface_index() >= number_of_interfaces(); |
|
146 |
} |
|
147 |
InstanceKlass* interface_at(int index) { |
|
148 |
return InstanceKlass::cast(_class->local_interfaces()->at(index)); |
|
149 |
} |
|
150 |
InstanceKlass* next_super() { return _class->java_super(); } |
|
151 |
InstanceKlass* next_interface() { |
|
152 |
return interface_at(interface_index()); |
|
153 |
} |
|
154 |
}; |
|
155 |
||
156 |
bool _cancelled; |
|
157 |
GrowableArray<Node*> _path; |
|
158 |
||
159 |
Node* current_top() const { return _path.top(); } |
|
160 |
bool has_more_nodes() const { return !_path.is_empty(); } |
|
161 |
void push(InstanceKlass* cls, void* data) { |
|
162 |
assert(cls != NULL, "Requires a valid instance class"); |
|
163 |
Node* node = new Node(cls, data, has_super(cls)); |
|
164 |
_path.push(node); |
|
165 |
} |
|
166 |
void pop() { _path.pop(); } |
|
167 |
||
168 |
void reset_iteration() { |
|
169 |
_cancelled = false; |
|
170 |
_path.clear(); |
|
171 |
} |
|
172 |
bool is_cancelled() const { return _cancelled; } |
|
173 |
||
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
174 |
// This code used to skip interface classes because their only |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
175 |
// superclass was j.l.Object which would be also covered by class |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
176 |
// superclass hierarchy walks. Now that the starting point can be |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
177 |
// an interface, we must ensure we catch j.l.Object as the super. |
14385 | 178 |
static bool has_super(InstanceKlass* cls) { |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
179 |
return cls->super() != NULL; |
14385 | 180 |
} |
181 |
||
182 |
Node* node_at_depth(int i) const { |
|
183 |
return (i >= _path.length()) ? NULL : _path.at(_path.length() - i - 1); |
|
184 |
} |
|
185 |
||
186 |
protected: |
|
187 |
||
188 |
// Accessors available to the algorithm |
|
189 |
int current_depth() const { return _path.length() - 1; } |
|
190 |
||
191 |
InstanceKlass* class_at_depth(int i) { |
|
192 |
Node* n = node_at_depth(i); |
|
193 |
return n == NULL ? NULL : n->_class; |
|
194 |
} |
|
195 |
InstanceKlass* current_class() { return class_at_depth(0); } |
|
196 |
||
197 |
void* data_at_depth(int i) { |
|
198 |
Node* n = node_at_depth(i); |
|
199 |
return n == NULL ? NULL : n->_algorithm_data; |
|
200 |
} |
|
201 |
void* current_data() { return data_at_depth(0); } |
|
202 |
||
203 |
void cancel_iteration() { _cancelled = true; } |
|
204 |
||
205 |
public: |
|
206 |
||
207 |
void run(InstanceKlass* root) { |
|
208 |
ALGO* algo = static_cast<ALGO*>(this); |
|
209 |
||
210 |
reset_iteration(); |
|
211 |
||
212 |
void* algo_data = algo->new_node_data(root); |
|
213 |
push(root, algo_data); |
|
214 |
bool top_needs_visit = true; |
|
215 |
||
216 |
do { |
|
217 |
Node* top = current_top(); |
|
218 |
if (top_needs_visit) { |
|
219 |
if (algo->visit() == false) { |
|
220 |
// algorithm does not want to continue along this path. Arrange |
|
221 |
// it so that this state is immediately popped off the stack |
|
222 |
top->set_super_visited(); |
|
223 |
top->set_all_interfaces_visited(); |
|
224 |
} |
|
225 |
top_needs_visit = false; |
|
226 |
} |
|
227 |
||
228 |
if (top->has_visited_super() && top->has_visited_all_interfaces()) { |
|
229 |
algo->free_node_data(top->_algorithm_data); |
|
230 |
pop(); |
|
231 |
} else { |
|
232 |
InstanceKlass* next = NULL; |
|
233 |
if (top->has_visited_super() == false) { |
|
234 |
next = top->next_super(); |
|
235 |
top->set_super_visited(); |
|
236 |
} else { |
|
237 |
next = top->next_interface(); |
|
238 |
top->increment_visited_interface(); |
|
239 |
} |
|
240 |
assert(next != NULL, "Otherwise we shouldn't be here"); |
|
241 |
algo_data = algo->new_node_data(next); |
|
242 |
push(next, algo_data); |
|
243 |
top_needs_visit = true; |
|
244 |
} |
|
245 |
} while (!is_cancelled() && has_more_nodes()); |
|
246 |
} |
|
247 |
}; |
|
248 |
||
249 |
class PrintHierarchy : public HierarchyVisitor<PrintHierarchy> { |
|
33736
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
250 |
private: |
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
251 |
outputStream* _st; |
14385 | 252 |
public: |
253 |
bool visit() { |
|
254 |
InstanceKlass* cls = current_class(); |
|
33736
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
255 |
streamIndentor si(_st, current_depth() * 2); |
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
256 |
_st->indent().print_cr("%s", cls->name()->as_C_string()); |
14385 | 257 |
return true; |
258 |
} |
|
259 |
||
260 |
void* new_node_data(InstanceKlass* cls) { return NULL; } |
|
261 |
void free_node_data(void* data) { return; } |
|
33736
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
262 |
|
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
263 |
PrintHierarchy(outputStream* st = tty) : _st(st) {} |
14385 | 264 |
}; |
265 |
||
266 |
// Used to register InstanceKlass objects and all related metadata structures |
|
267 |
// (Methods, ConstantPools) as "in-use" by the current thread so that they can't |
|
268 |
// be deallocated by class redefinition while we're using them. The classes are |
|
269 |
// de-registered when this goes out of scope. |
|
270 |
// |
|
271 |
// Once a class is registered, we need not bother with methodHandles or |
|
272 |
// constantPoolHandles for it's associated metadata. |
|
273 |
class KeepAliveRegistrar : public StackObj { |
|
274 |
private: |
|
275 |
Thread* _thread; |
|
276 |
GrowableArray<ConstantPool*> _keep_alive; |
|
277 |
||
278 |
public: |
|
279 |
KeepAliveRegistrar(Thread* thread) : _thread(thread), _keep_alive(20) { |
|
280 |
assert(thread == Thread::current(), "Must be current thread"); |
|
281 |
} |
|
282 |
||
283 |
~KeepAliveRegistrar() { |
|
284 |
for (int i = _keep_alive.length() - 1; i >= 0; --i) { |
|
285 |
ConstantPool* cp = _keep_alive.at(i); |
|
286 |
int idx = _thread->metadata_handles()->find_from_end(cp); |
|
287 |
assert(idx > 0, "Must be in the list"); |
|
288 |
_thread->metadata_handles()->remove_at(idx); |
|
289 |
} |
|
290 |
} |
|
291 |
||
292 |
// Register a class as 'in-use' by the thread. It's fine to register a class |
|
293 |
// multiple times (though perhaps inefficient) |
|
294 |
void register_class(InstanceKlass* ik) { |
|
295 |
ConstantPool* cp = ik->constants(); |
|
296 |
_keep_alive.push(cp); |
|
297 |
_thread->metadata_handles()->push(cp); |
|
298 |
} |
|
299 |
}; |
|
300 |
||
301 |
class KeepAliveVisitor : public HierarchyVisitor<KeepAliveVisitor> { |
|
302 |
private: |
|
303 |
KeepAliveRegistrar* _registrar; |
|
304 |
||
305 |
public: |
|
306 |
KeepAliveVisitor(KeepAliveRegistrar* registrar) : _registrar(registrar) {} |
|
307 |
||
308 |
void* new_node_data(InstanceKlass* cls) { return NULL; } |
|
309 |
void free_node_data(void* data) { return; } |
|
310 |
||
311 |
bool visit() { |
|
312 |
_registrar->register_class(current_class()); |
|
313 |
return true; |
|
314 |
} |
|
315 |
}; |
|
316 |
||
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
317 |
|
14385 | 318 |
// A method family contains a set of all methods that implement a single |
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
319 |
// erased method. As members of the set are collected while walking over the |
14385 | 320 |
// hierarchy, they are tagged with a qualification state. The qualification |
321 |
// state for an erased method is set to disqualified if there exists a path |
|
322 |
// from the root of hierarchy to the method that contains an interleaving |
|
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
323 |
// erased method defined in an interface. |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
324 |
|
14385 | 325 |
class MethodFamily : public ResourceObj { |
326 |
private: |
|
327 |
||
328 |
GrowableArray<Pair<Method*,QualifiedState> > _members; |
|
329 |
ResourceHashtable<Method*, int> _member_index; |
|
330 |
||
331 |
Method* _selected_target; // Filled in later, if a unique target exists |
|
332 |
Symbol* _exception_message; // If no unique target is found |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
19966
diff
changeset
|
333 |
Symbol* _exception_name; // If no unique target is found |
14385 | 334 |
|
335 |
bool contains_method(Method* method) { |
|
336 |
int* lookup = _member_index.get(method); |
|
337 |
return lookup != NULL; |
|
338 |
} |
|
339 |
||
340 |
void add_method(Method* method, QualifiedState state) { |
|
341 |
Pair<Method*,QualifiedState> entry(method, state); |
|
342 |
_member_index.put(method, _members.length()); |
|
343 |
_members.append(entry); |
|
344 |
} |
|
345 |
||
346 |
void disqualify_method(Method* method) { |
|
347 |
int* index = _member_index.get(method); |
|
16379
02ed75a9a421
8009578: [parfait] Null pointer deference in hotspot/src/share/vm/classfile/defaultMethods.cpp
morris
parents:
15601
diff
changeset
|
348 |
guarantee(index != NULL && *index >= 0 && *index < _members.length(), "bad index"); |
14385 | 349 |
_members.at(*index).second = DISQUALIFIED; |
350 |
} |
|
351 |
||
352 |
Symbol* generate_no_defaults_message(TRAPS) const; |
|
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
353 |
Symbol* generate_method_message(Symbol *klass_name, Method* method, TRAPS) const; |
14385 | 354 |
Symbol* generate_conflicts_message(GrowableArray<Method*>* methods, TRAPS) const; |
355 |
||
356 |
public: |
|
357 |
||
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
358 |
MethodFamily() |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
19966
diff
changeset
|
359 |
: _selected_target(NULL), _exception_message(NULL), _exception_name(NULL) {} |
14385 | 360 |
|
361 |
void set_target_if_empty(Method* m) { |
|
362 |
if (_selected_target == NULL && !m->is_overpass()) { |
|
363 |
_selected_target = m; |
|
364 |
} |
|
365 |
} |
|
366 |
||
367 |
void record_qualified_method(Method* m) { |
|
368 |
// If the method already exists in the set as qualified, this operation is |
|
369 |
// redundant. If it already exists as disqualified, then we leave it as |
|
370 |
// disqualfied. Thus we only add to the set if it's not already in the |
|
371 |
// set. |
|
372 |
if (!contains_method(m)) { |
|
373 |
add_method(m, QUALIFIED); |
|
374 |
} |
|
375 |
} |
|
376 |
||
377 |
void record_disqualified_method(Method* m) { |
|
378 |
// If not in the set, add it as disqualified. If it's already in the set, |
|
379 |
// then set the state to disqualified no matter what the previous state was. |
|
380 |
if (!contains_method(m)) { |
|
381 |
add_method(m, DISQUALIFIED); |
|
382 |
} else { |
|
383 |
disqualify_method(m); |
|
384 |
} |
|
385 |
} |
|
386 |
||
387 |
bool has_target() const { return _selected_target != NULL; } |
|
388 |
bool throws_exception() { return _exception_message != NULL; } |
|
389 |
||
390 |
Method* get_selected_target() { return _selected_target; } |
|
391 |
Symbol* get_exception_message() { return _exception_message; } |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
19966
diff
changeset
|
392 |
Symbol* get_exception_name() { return _exception_name; } |
14385 | 393 |
|
394 |
// Either sets the target or the exception error message |
|
395 |
void determine_target(InstanceKlass* root, TRAPS) { |
|
396 |
if (has_target() || throws_exception()) { |
|
397 |
return; |
|
398 |
} |
|
399 |
||
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
400 |
// Qualified methods are maximally-specific methods |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
401 |
// These include public, instance concrete (=default) and abstract methods |
14385 | 402 |
GrowableArray<Method*> qualified_methods; |
21516
8fa5308ab970
8027304: Lambda: inheriting abstract + 1 default -> default, not ICCE
acorn
parents:
20710
diff
changeset
|
403 |
int num_defaults = 0; |
8fa5308ab970
8027304: Lambda: inheriting abstract + 1 default -> default, not ICCE
acorn
parents:
20710
diff
changeset
|
404 |
int default_index = -1; |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
405 |
int qualified_index = -1; |
14385 | 406 |
for (int i = 0; i < _members.length(); ++i) { |
407 |
Pair<Method*,QualifiedState> entry = _members.at(i); |
|
408 |
if (entry.second == QUALIFIED) { |
|
409 |
qualified_methods.append(entry.first); |
|
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
410 |
qualified_index++; |
21516
8fa5308ab970
8027304: Lambda: inheriting abstract + 1 default -> default, not ICCE
acorn
parents:
20710
diff
changeset
|
411 |
if (entry.first->is_default_method()) { |
8fa5308ab970
8027304: Lambda: inheriting abstract + 1 default -> default, not ICCE
acorn
parents:
20710
diff
changeset
|
412 |
num_defaults++; |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
413 |
default_index = qualified_index; |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
414 |
|
21516
8fa5308ab970
8027304: Lambda: inheriting abstract + 1 default -> default, not ICCE
acorn
parents:
20710
diff
changeset
|
415 |
} |
14385 | 416 |
} |
417 |
} |
|
418 |
||
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
419 |
if (num_defaults == 0) { |
22493
af3de4cee5e5
8031059: invokestatic: ICCE trying to invoke static method when it clashes with an abstract method inherited from an interface
hseigel
parents:
22233
diff
changeset
|
420 |
// If the root klass has a static method with matching name and signature |
af3de4cee5e5
8031059: invokestatic: ICCE trying to invoke static method when it clashes with an abstract method inherited from an interface
hseigel
parents:
22233
diff
changeset
|
421 |
// then do not generate an overpass method because it will hide the |
af3de4cee5e5
8031059: invokestatic: ICCE trying to invoke static method when it clashes with an abstract method inherited from an interface
hseigel
parents:
22233
diff
changeset
|
422 |
// static method during resolution. |
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22493
diff
changeset
|
423 |
if (qualified_methods.length() == 0) { |
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22493
diff
changeset
|
424 |
_exception_message = generate_no_defaults_message(CHECK); |
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22493
diff
changeset
|
425 |
} else { |
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22493
diff
changeset
|
426 |
assert(root != NULL, "Null root class"); |
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22493
diff
changeset
|
427 |
_exception_message = generate_method_message(root->name(), qualified_methods.at(0), CHECK); |
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
428 |
} |
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22493
diff
changeset
|
429 |
_exception_name = vmSymbols::java_lang_AbstractMethodError(); |
22493
af3de4cee5e5
8031059: invokestatic: ICCE trying to invoke static method when it clashes with an abstract method inherited from an interface
hseigel
parents:
22233
diff
changeset
|
430 |
|
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
431 |
// If only one qualified method is default, select that |
21516
8fa5308ab970
8027304: Lambda: inheriting abstract + 1 default -> default, not ICCE
acorn
parents:
20710
diff
changeset
|
432 |
} else if (num_defaults == 1) { |
8fa5308ab970
8027304: Lambda: inheriting abstract + 1 default -> default, not ICCE
acorn
parents:
20710
diff
changeset
|
433 |
_selected_target = qualified_methods.at(default_index); |
22493
af3de4cee5e5
8031059: invokestatic: ICCE trying to invoke static method when it clashes with an abstract method inherited from an interface
hseigel
parents:
22233
diff
changeset
|
434 |
|
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22493
diff
changeset
|
435 |
} else if (num_defaults > 1) { |
22493
af3de4cee5e5
8031059: invokestatic: ICCE trying to invoke static method when it clashes with an abstract method inherited from an interface
hseigel
parents:
22233
diff
changeset
|
436 |
_exception_message = generate_conflicts_message(&qualified_methods,CHECK); |
af3de4cee5e5
8031059: invokestatic: ICCE trying to invoke static method when it clashes with an abstract method inherited from an interface
hseigel
parents:
22233
diff
changeset
|
437 |
_exception_name = vmSymbols::java_lang_IncompatibleClassChangeError(); |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
438 |
LogTarget(Debug, defaultmethods) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
439 |
if (lt.is_enabled()) { |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
440 |
LogStream ls(lt); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
441 |
_exception_message->print_value_on(&ls); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
442 |
ls.cr(); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
443 |
} |
14385 | 444 |
} |
445 |
} |
|
446 |
||
447 |
bool contains_signature(Symbol* query) { |
|
448 |
for (int i = 0; i < _members.length(); ++i) { |
|
449 |
if (query == _members.at(i).first->signature()) { |
|
450 |
return true; |
|
451 |
} |
|
452 |
} |
|
453 |
return false; |
|
454 |
} |
|
455 |
||
456 |
void print_selected(outputStream* str, int indent) const { |
|
457 |
assert(has_target(), "Should be called otherwise"); |
|
458 |
streamIndentor si(str, indent * 2); |
|
459 |
str->indent().print("Selected method: "); |
|
460 |
print_method(str, _selected_target); |
|
19966
64732b96b5f5
8024647: Default method resolution with private superclass method
acorn
parents:
19690
diff
changeset
|
461 |
Klass* method_holder = _selected_target->method_holder(); |
64732b96b5f5
8024647: Default method resolution with private superclass method
acorn
parents:
19690
diff
changeset
|
462 |
if (!method_holder->is_interface()) { |
33736
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
463 |
str->print(" : in superclass"); |
19966
64732b96b5f5
8024647: Default method resolution with private superclass method
acorn
parents:
19690
diff
changeset
|
464 |
} |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23999
diff
changeset
|
465 |
str->cr(); |
14385 | 466 |
} |
467 |
||
468 |
void print_exception(outputStream* str, int indent) { |
|
469 |
assert(throws_exception(), "Should be called otherwise"); |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
19966
diff
changeset
|
470 |
assert(_exception_name != NULL, "exception_name should be set"); |
14385 | 471 |
streamIndentor si(str, indent * 2); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
19966
diff
changeset
|
472 |
str->indent().print_cr("%s: %s", _exception_name->as_C_string(), _exception_message->as_C_string()); |
14385 | 473 |
} |
474 |
}; |
|
475 |
||
476 |
Symbol* MethodFamily::generate_no_defaults_message(TRAPS) const { |
|
27680
8ecc0871c18e
8064811: Use THREAD instead of CHECK_NULL in return statements
stefank
parents:
27677
diff
changeset
|
477 |
return SymbolTable::new_symbol("No qualifying defaults found", THREAD); |
14385 | 478 |
} |
479 |
||
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
480 |
Symbol* MethodFamily::generate_method_message(Symbol *klass_name, Method* method, TRAPS) const { |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
481 |
stringStream ss; |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
482 |
ss.print("Method "); |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
483 |
Symbol* name = method->name(); |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
484 |
Symbol* signature = method->signature(); |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
485 |
ss.write((const char*)klass_name->bytes(), klass_name->utf8_length()); |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
486 |
ss.print("."); |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
487 |
ss.write((const char*)name->bytes(), name->utf8_length()); |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
488 |
ss.write((const char*)signature->bytes(), signature->utf8_length()); |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
489 |
ss.print(" is abstract"); |
27677 | 490 |
return SymbolTable::new_symbol(ss.base(), (int)ss.size(), THREAD); |
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
491 |
} |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
21913
diff
changeset
|
492 |
|
14385 | 493 |
Symbol* MethodFamily::generate_conflicts_message(GrowableArray<Method*>* methods, TRAPS) const { |
494 |
stringStream ss; |
|
495 |
ss.print("Conflicting default methods:"); |
|
496 |
for (int i = 0; i < methods->length(); ++i) { |
|
497 |
Method* method = methods->at(i); |
|
498 |
Symbol* klass = method->klass_name(); |
|
499 |
Symbol* name = method->name(); |
|
500 |
ss.print(" "); |
|
501 |
ss.write((const char*)klass->bytes(), klass->utf8_length()); |
|
502 |
ss.print("."); |
|
503 |
ss.write((const char*)name->bytes(), name->utf8_length()); |
|
504 |
} |
|
27677 | 505 |
return SymbolTable::new_symbol(ss.base(), (int)ss.size(), THREAD); |
14385 | 506 |
} |
507 |
||
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
508 |
|
14385 | 509 |
class StateRestorer; |
510 |
||
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
511 |
// StatefulMethodFamily is a wrapper around a MethodFamily that maintains the |
14385 | 512 |
// qualification state during hierarchy visitation, and applies that state |
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
513 |
// when adding members to the MethodFamily |
14385 | 514 |
class StatefulMethodFamily : public ResourceObj { |
515 |
friend class StateRestorer; |
|
516 |
private: |
|
517 |
QualifiedState _qualification_state; |
|
518 |
||
519 |
void set_qualification_state(QualifiedState state) { |
|
520 |
_qualification_state = state; |
|
521 |
} |
|
522 |
||
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
523 |
protected: |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
524 |
MethodFamily* _method_family; |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
525 |
|
14385 | 526 |
public: |
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
527 |
StatefulMethodFamily() { |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
528 |
_method_family = new MethodFamily(); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
529 |
_qualification_state = QUALIFIED; |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
530 |
} |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
531 |
|
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
532 |
StatefulMethodFamily(MethodFamily* mf) { |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
533 |
_method_family = mf; |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
534 |
_qualification_state = QUALIFIED; |
14385 | 535 |
} |
536 |
||
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
537 |
void set_target_if_empty(Method* m) { _method_family->set_target_if_empty(m); } |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
538 |
|
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
539 |
MethodFamily* get_method_family() { return _method_family; } |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
540 |
|
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
541 |
StateRestorer* record_method_and_dq_further(Method* mo); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
542 |
}; |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
543 |
|
14385 | 544 |
class StateRestorer : public PseudoScopeMark { |
545 |
private: |
|
546 |
StatefulMethodFamily* _method; |
|
547 |
QualifiedState _state_to_restore; |
|
548 |
public: |
|
549 |
StateRestorer(StatefulMethodFamily* dm, QualifiedState state) |
|
550 |
: _method(dm), _state_to_restore(state) {} |
|
551 |
~StateRestorer() { destroy(); } |
|
552 |
void restore_state() { _method->set_qualification_state(_state_to_restore); } |
|
553 |
virtual void destroy() { restore_state(); } |
|
554 |
}; |
|
555 |
||
556 |
StateRestorer* StatefulMethodFamily::record_method_and_dq_further(Method* mo) { |
|
557 |
StateRestorer* mark = new StateRestorer(this, _qualification_state); |
|
558 |
if (_qualification_state == QUALIFIED) { |
|
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
559 |
_method_family->record_qualified_method(mo); |
14385 | 560 |
} else { |
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
561 |
_method_family->record_disqualified_method(mo); |
14385 | 562 |
} |
563 |
// Everything found "above"??? this method in the hierarchy walk is set to |
|
564 |
// disqualified |
|
565 |
set_qualification_state(DISQUALIFIED); |
|
566 |
return mark; |
|
567 |
} |
|
568 |
||
569 |
// Represents a location corresponding to a vtable slot for methods that |
|
570 |
// neither the class nor any of it's ancestors provide an implementaion. |
|
571 |
// Default methods may be present to fill this slot. |
|
572 |
class EmptyVtableSlot : public ResourceObj { |
|
573 |
private: |
|
574 |
Symbol* _name; |
|
575 |
Symbol* _signature; |
|
576 |
int _size_of_parameters; |
|
577 |
MethodFamily* _binding; |
|
578 |
||
579 |
public: |
|
580 |
EmptyVtableSlot(Method* method) |
|
581 |
: _name(method->name()), _signature(method->signature()), |
|
582 |
_size_of_parameters(method->size_of_parameters()), _binding(NULL) {} |
|
583 |
||
584 |
Symbol* name() const { return _name; } |
|
585 |
Symbol* signature() const { return _signature; } |
|
586 |
int size_of_parameters() const { return _size_of_parameters; } |
|
587 |
||
588 |
void bind_family(MethodFamily* lm) { _binding = lm; } |
|
589 |
bool is_bound() { return _binding != NULL; } |
|
590 |
MethodFamily* get_binding() { return _binding; } |
|
591 |
||
592 |
void print_on(outputStream* str) const { |
|
593 |
print_slot(str, name(), signature()); |
|
594 |
} |
|
595 |
}; |
|
596 |
||
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
597 |
static bool already_in_vtable_slots(GrowableArray<EmptyVtableSlot*>* slots, Method* m) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
598 |
bool found = false; |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
599 |
for (int j = 0; j < slots->length(); ++j) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
600 |
if (slots->at(j)->name() == m->name() && |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
601 |
slots->at(j)->signature() == m->signature() ) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
602 |
found = true; |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
603 |
break; |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
604 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
605 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
606 |
return found; |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
607 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
608 |
|
14385 | 609 |
static GrowableArray<EmptyVtableSlot*>* find_empty_vtable_slots( |
34666 | 610 |
InstanceKlass* klass, const GrowableArray<Method*>* mirandas, TRAPS) { |
14385 | 611 |
|
612 |
assert(klass != NULL, "Must be valid class"); |
|
613 |
||
614 |
GrowableArray<EmptyVtableSlot*>* slots = new GrowableArray<EmptyVtableSlot*>(); |
|
615 |
||
616 |
// All miranda methods are obvious candidates |
|
617 |
for (int i = 0; i < mirandas->length(); ++i) { |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
618 |
Method* m = mirandas->at(i); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
619 |
if (!already_in_vtable_slots(slots, m)) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
620 |
slots->append(new EmptyVtableSlot(m)); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
621 |
} |
14385 | 622 |
} |
623 |
||
624 |
// Also any overpasses in our superclasses, that we haven't implemented. |
|
625 |
// (can't use the vtable because it is not guaranteed to be initialized yet) |
|
626 |
InstanceKlass* super = klass->java_super(); |
|
627 |
while (super != NULL) { |
|
628 |
for (int i = 0; i < super->methods()->length(); ++i) { |
|
629 |
Method* m = super->methods()->at(i); |
|
21913
0e2fd7282ac6
8028438: static superclass method masks default methods
acorn
parents:
21556
diff
changeset
|
630 |
if (m->is_overpass() || m->is_static()) { |
14385 | 631 |
// m is a method that would have been a miranda if not for the |
632 |
// default method processing that occurred on behalf of our superclass, |
|
633 |
// so it's a method we want to re-examine in this new context. That is, |
|
634 |
// unless we have a real implementation of it in the current class. |
|
635 |
Method* impl = klass->lookup_method(m->name(), m->signature()); |
|
21913
0e2fd7282ac6
8028438: static superclass method masks default methods
acorn
parents:
21556
diff
changeset
|
636 |
if (impl == NULL || impl->is_overpass() || impl->is_static()) { |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
637 |
if (!already_in_vtable_slots(slots, m)) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
638 |
slots->append(new EmptyVtableSlot(m)); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
639 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
640 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
641 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
642 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
643 |
|
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
644 |
// also any default methods in our superclasses |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
645 |
if (super->default_methods() != NULL) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
646 |
for (int i = 0; i < super->default_methods()->length(); ++i) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
647 |
Method* m = super->default_methods()->at(i); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
648 |
// m is a method that would have been a miranda if not for the |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
649 |
// default method processing that occurred on behalf of our superclass, |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
650 |
// so it's a method we want to re-examine in this new context. That is, |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
651 |
// unless we have a real implementation of it in the current class. |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
652 |
Method* impl = klass->lookup_method(m->name(), m->signature()); |
21913
0e2fd7282ac6
8028438: static superclass method masks default methods
acorn
parents:
21556
diff
changeset
|
653 |
if (impl == NULL || impl->is_overpass() || impl->is_static()) { |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
654 |
if (!already_in_vtable_slots(slots, m)) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
655 |
slots->append(new EmptyVtableSlot(m)); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
656 |
} |
14385 | 657 |
} |
658 |
} |
|
659 |
} |
|
660 |
super = super->java_super(); |
|
661 |
} |
|
662 |
||
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
663 |
LogTarget(Debug, defaultmethods) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
664 |
if (lt.is_enabled()) { |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
665 |
lt.print("Slots that need filling:"); |
33736
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
666 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
667 |
LogStream ls(lt); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
668 |
streamIndentor si(&ls); |
14385 | 669 |
for (int i = 0; i < slots->length(); ++i) { |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
670 |
ls.indent(); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
671 |
slots->at(i)->print_on(&ls); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
672 |
ls.cr(); |
14385 | 673 |
} |
674 |
} |
|
33736
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
675 |
|
14385 | 676 |
return slots; |
677 |
} |
|
678 |
||
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
679 |
// Iterates over the superinterface type hierarchy looking for all methods |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
680 |
// with a specific erased signature. |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
681 |
class FindMethodsByErasedSig : public HierarchyVisitor<FindMethodsByErasedSig> { |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
682 |
private: |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
683 |
// Context data |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
684 |
Symbol* _method_name; |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
685 |
Symbol* _method_signature; |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
686 |
StatefulMethodFamily* _family; |
48463
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
687 |
bool _cur_class_is_interface; |
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
688 |
|
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
689 |
public: |
48463
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
690 |
FindMethodsByErasedSig(Symbol* name, Symbol* signature, bool is_interf) : |
51334
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
49677
diff
changeset
|
691 |
_method_name(name), _method_signature(signature), _family(NULL), |
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
49677
diff
changeset
|
692 |
_cur_class_is_interface(is_interf) {} |
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
693 |
|
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
694 |
void get_discovered_family(MethodFamily** family) { |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
695 |
if (_family != NULL) { |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
696 |
*family = _family->get_method_family(); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
697 |
} else { |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
698 |
*family = NULL; |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
699 |
} |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
700 |
} |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
701 |
|
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
702 |
void* new_node_data(InstanceKlass* cls) { return new PseudoScope(); } |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
703 |
void free_node_data(void* node_data) { |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
704 |
PseudoScope::cast(node_data)->destroy(); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
705 |
} |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
706 |
|
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
707 |
// Find all methods on this hierarchy that match this |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
708 |
// method's erased (name, signature) |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
709 |
bool visit() { |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
710 |
PseudoScope* scope = PseudoScope::cast(current_data()); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
711 |
InstanceKlass* iklass = current_class(); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
712 |
|
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
713 |
Method* m = iklass->find_method(_method_name, _method_signature); |
48463
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
714 |
// Private interface methods are not candidates for default methods. |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
715 |
// invokespecial to private interface methods doesn't use default method logic. |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
716 |
// Private class methods are not candidates for default methods. |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
717 |
// Private methods do not override default methods, so need to perform |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
718 |
// default method inheritance without including private methods. |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
719 |
// The overpasses are your supertypes' errors, we do not include them. |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
720 |
// Non-public methods in java.lang.Object are not candidates for default |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
721 |
// methods. |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
722 |
// Future: take access controls into account for superclass methods |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
723 |
if (m != NULL && !m->is_static() && !m->is_overpass() && !m->is_private() && |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
724 |
(!_cur_class_is_interface || !SystemDictionary::is_nonpublic_Object_method(m))) { |
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
725 |
if (_family == NULL) { |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
726 |
_family = new StatefulMethodFamily(); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
727 |
} |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
728 |
|
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
729 |
if (iklass->is_interface()) { |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
730 |
StateRestorer* restorer = _family->record_method_and_dq_further(m); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
731 |
scope->add_mark(restorer); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
732 |
} else { |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
733 |
// This is the rule that methods in classes "win" (bad word) over |
48463
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
734 |
// methods in interfaces. This works because of single inheritance. |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
735 |
// Private methods in classes do not "win", they will be found |
29871 | 736 |
// first on searching, but overriding for invokevirtual needs |
737 |
// to find default method candidates for the same signature |
|
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
738 |
_family->set_target_if_empty(m); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
739 |
} |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
740 |
} |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
741 |
return true; |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
742 |
} |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
743 |
|
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
744 |
}; |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
745 |
|
14385 | 746 |
|
747 |
||
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
748 |
static void create_defaults_and_exceptions( |
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
749 |
GrowableArray<EmptyVtableSlot*>* slots, InstanceKlass* klass, TRAPS); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
750 |
|
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
751 |
static void generate_erased_defaults( |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
752 |
InstanceKlass* klass, GrowableArray<EmptyVtableSlot*>* empty_slots, |
48463
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
753 |
EmptyVtableSlot* slot, bool is_intf, TRAPS) { |
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
754 |
|
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
755 |
// sets up a set of methods with the same exact erased signature |
48463
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
756 |
FindMethodsByErasedSig visitor(slot->name(), slot->signature(), is_intf); |
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
757 |
visitor.run(klass); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
758 |
|
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
759 |
MethodFamily* family; |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
760 |
visitor.get_discovered_family(&family); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
761 |
if (family != NULL) { |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
762 |
family->determine_target(klass, CHECK); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
763 |
slot->bind_family(family); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
764 |
} |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
765 |
} |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
766 |
|
14385 | 767 |
static void merge_in_new_methods(InstanceKlass* klass, |
768 |
GrowableArray<Method*>* new_methods, TRAPS); |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
769 |
static void create_default_methods( InstanceKlass* klass, |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
770 |
GrowableArray<Method*>* new_methods, TRAPS); |
14385 | 771 |
|
772 |
// This is the guts of the default methods implementation. This is called just |
|
773 |
// after the classfile has been parsed if some ancestor has default methods. |
|
774 |
// |
|
47554
bc112140e089
8186092: Unnecessary loader constraints produced when there are multiple defaults
hseigel
parents:
47216
diff
changeset
|
775 |
// First it finds any name/signature slots that need any implementation (either |
14385 | 776 |
// because they are miranda or a superclass's implementation is an overpass |
19681
1b35da7b1d85
8012294: remove generic handling for default methods
acorn
parents:
18695
diff
changeset
|
777 |
// itself). For each slot, iterate over the hierarchy, to see if they contain a |
1b35da7b1d85
8012294: remove generic handling for default methods
acorn
parents:
18695
diff
changeset
|
778 |
// signature that matches the slot we are looking at. |
14385 | 779 |
// |
47554
bc112140e089
8186092: Unnecessary loader constraints produced when there are multiple defaults
hseigel
parents:
47216
diff
changeset
|
780 |
// For each slot filled, we either record the default method candidate in the |
bc112140e089
8186092: Unnecessary loader constraints produced when there are multiple defaults
hseigel
parents:
47216
diff
changeset
|
781 |
// klass default_methods list or, only to handle exception cases, we create an |
bc112140e089
8186092: Unnecessary loader constraints produced when there are multiple defaults
hseigel
parents:
47216
diff
changeset
|
782 |
// overpass method that throws an exception and add it to the klass methods list. |
19681
1b35da7b1d85
8012294: remove generic handling for default methods
acorn
parents:
18695
diff
changeset
|
783 |
// The JVM does not create bridges nor handle generic signatures here. |
14385 | 784 |
void DefaultMethods::generate_default_methods( |
34666 | 785 |
InstanceKlass* klass, const GrowableArray<Method*>* mirandas, TRAPS) { |
786 |
assert(klass != NULL, "invariant"); |
|
14385 | 787 |
|
788 |
// This resource mark is the bound for all memory allocation that takes |
|
789 |
// place during default method processing. After this goes out of scope, |
|
790 |
// all (Resource) objects' memory will be reclaimed. Be careful if adding an |
|
791 |
// embedded resource mark under here as that memory can't be used outside |
|
792 |
// whatever scope it's in. |
|
793 |
ResourceMark rm(THREAD); |
|
794 |
||
795 |
// Keep entire hierarchy alive for the duration of the computation |
|
34666 | 796 |
constantPoolHandle cp(THREAD, klass->constants()); |
14385 | 797 |
KeepAliveRegistrar keepAlive(THREAD); |
798 |
KeepAliveVisitor loadKeepAlive(&keepAlive); |
|
799 |
loadKeepAlive.run(klass); |
|
800 |
||
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
801 |
LogTarget(Debug, defaultmethods) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
802 |
if (lt.is_enabled()) { |
33736
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
803 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
804 |
lt.print("%s %s requires default method processing", |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
805 |
klass->is_interface() ? "Interface" : "Class", |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
806 |
klass->name()->as_klass_external_name()); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
807 |
LogStream ls(lt); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
808 |
PrintHierarchy printer(&ls); |
14385 | 809 |
printer.run(klass); |
810 |
} |
|
811 |
||
812 |
GrowableArray<EmptyVtableSlot*>* empty_slots = |
|
813 |
find_empty_vtable_slots(klass, mirandas, CHECK); |
|
814 |
||
815 |
for (int i = 0; i < empty_slots->length(); ++i) { |
|
816 |
EmptyVtableSlot* slot = empty_slots->at(i); |
|
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
817 |
LogTarget(Debug, defaultmethods) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
818 |
if (lt.is_enabled()) { |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
819 |
LogStream ls(lt); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
820 |
streamIndentor si(&ls, 2); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
821 |
ls.indent().print("Looking for default methods for slot "); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
822 |
slot->print_on(&ls); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
823 |
ls.cr(); |
14385 | 824 |
} |
48463
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
47554
diff
changeset
|
825 |
generate_erased_defaults(klass, empty_slots, slot, klass->is_interface(), CHECK); |
14385 | 826 |
} |
33736
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
827 |
log_debug(defaultmethods)("Creating defaults and overpasses..."); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
828 |
create_defaults_and_exceptions(empty_slots, klass, CHECK); |
33736
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
829 |
log_debug(defaultmethods)("Default method processing complete"); |
14385 | 830 |
} |
831 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
19966
diff
changeset
|
832 |
static int assemble_method_error( |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
19966
diff
changeset
|
833 |
BytecodeConstantPool* cp, BytecodeBuffer* buffer, Symbol* errorName, Symbol* message, TRAPS) { |
14385 | 834 |
|
835 |
Symbol* init = vmSymbols::object_initializer_name(); |
|
836 |
Symbol* sig = vmSymbols::string_void_signature(); |
|
837 |
||
838 |
BytecodeAssembler assem(buffer, cp); |
|
839 |
||
840 |
assem._new(errorName); |
|
841 |
assem.dup(); |
|
842 |
assem.load_string(message); |
|
843 |
assem.invokespecial(errorName, init, sig); |
|
844 |
assem.athrow(); |
|
845 |
||
846 |
return 3; // max stack size: [ exception, exception, string ] |
|
847 |
} |
|
848 |
||
849 |
static Method* new_method( |
|
850 |
BytecodeConstantPool* cp, BytecodeBuffer* bytecodes, Symbol* name, |
|
851 |
Symbol* sig, AccessFlags flags, int max_stack, int params, |
|
852 |
ConstMethod::MethodType mt, TRAPS) { |
|
853 |
||
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
854 |
address code_start = 0; |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
855 |
int code_length = 0; |
15601 | 856 |
InlineTableSizes sizes; |
14385 | 857 |
|
18695
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
858 |
if (bytecodes != NULL && bytecodes->length() > 0) { |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
859 |
code_start = static_cast<address>(bytecodes->adr_at(0)); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
860 |
code_length = bytecodes->length(); |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
861 |
} |
be902722fe0a
8013635: VM should no longer create bridges for generic signatures.
acorn
parents:
17859
diff
changeset
|
862 |
|
14385 | 863 |
Method* m = Method::allocate(cp->pool_holder()->class_loader_data(), |
15601 | 864 |
code_length, flags, &sizes, |
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
865 |
mt, CHECK_NULL); |
14385 | 866 |
|
867 |
m->set_constants(NULL); // This will get filled in later |
|
868 |
m->set_name_index(cp->utf8(name)); |
|
869 |
m->set_signature_index(cp->utf8(sig)); |
|
870 |
ResultTypeFinder rtf(sig); |
|
37480 | 871 |
m->constMethod()->set_result_type(rtf.type()); |
14385 | 872 |
m->set_size_of_parameters(params); |
873 |
m->set_max_stack(max_stack); |
|
874 |
m->set_max_locals(params); |
|
875 |
m->constMethod()->set_stackmap_data(NULL); |
|
876 |
m->set_code(code_start); |
|
877 |
||
878 |
return m; |
|
879 |
} |
|
880 |
||
881 |
static void switchover_constant_pool(BytecodeConstantPool* bpool, |
|
882 |
InstanceKlass* klass, GrowableArray<Method*>* new_methods, TRAPS) { |
|
883 |
||
884 |
if (new_methods->length() > 0) { |
|
885 |
ConstantPool* cp = bpool->create_constant_pool(CHECK); |
|
886 |
if (cp != klass->constants()) { |
|
49677 | 887 |
// Copy resolved anonymous class into new constant pool. |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51334
diff
changeset
|
888 |
if (klass->is_unsafe_anonymous()) { |
49677 | 889 |
cp->klass_at_put(klass->this_class_index(), klass); |
890 |
} |
|
14385 | 891 |
klass->class_loader_data()->add_to_deallocate_list(klass->constants()); |
892 |
klass->set_constants(cp); |
|
893 |
cp->set_pool_holder(klass); |
|
894 |
||
895 |
for (int i = 0; i < new_methods->length(); ++i) { |
|
896 |
new_methods->at(i)->set_constants(cp); |
|
897 |
} |
|
898 |
for (int i = 0; i < klass->methods()->length(); ++i) { |
|
899 |
Method* mo = klass->methods()->at(i); |
|
900 |
mo->set_constants(cp); |
|
901 |
} |
|
902 |
} |
|
903 |
} |
|
904 |
} |
|
905 |
||
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
906 |
// Create default_methods list for the current class. |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
907 |
// With the VM only processing erased signatures, the VM only |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
908 |
// creates an overpass in a conflict case or a case with no candidates. |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
909 |
// This allows virtual methods to override the overpass, but ensures |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
910 |
// that a local method search will find the exception rather than an abstract |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
911 |
// or default method that is not a valid candidate. |
47554
bc112140e089
8186092: Unnecessary loader constraints produced when there are multiple defaults
hseigel
parents:
47216
diff
changeset
|
912 |
// |
bc112140e089
8186092: Unnecessary loader constraints produced when there are multiple defaults
hseigel
parents:
47216
diff
changeset
|
913 |
// Note that if overpass method are ever created that are not exception |
bc112140e089
8186092: Unnecessary loader constraints produced when there are multiple defaults
hseigel
parents:
47216
diff
changeset
|
914 |
// throwing methods then the loader constraint checking logic for vtable and |
bc112140e089
8186092: Unnecessary loader constraints produced when there are multiple defaults
hseigel
parents:
47216
diff
changeset
|
915 |
// itable creation needs to be changed to check loader constraints for the |
bc112140e089
8186092: Unnecessary loader constraints produced when there are multiple defaults
hseigel
parents:
47216
diff
changeset
|
916 |
// overpass methods that do not throw exceptions. |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
917 |
static void create_defaults_and_exceptions( |
14385 | 918 |
GrowableArray<EmptyVtableSlot*>* slots, |
919 |
InstanceKlass* klass, TRAPS) { |
|
920 |
||
921 |
GrowableArray<Method*> overpasses; |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
922 |
GrowableArray<Method*> defaults; |
14385 | 923 |
BytecodeConstantPool bpool(klass->constants()); |
924 |
||
925 |
for (int i = 0; i < slots->length(); ++i) { |
|
926 |
EmptyVtableSlot* slot = slots->at(i); |
|
927 |
||
928 |
if (slot->is_bound()) { |
|
929 |
MethodFamily* method = slot->get_binding(); |
|
930 |
BytecodeBuffer buffer; |
|
931 |
||
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
932 |
LogTarget(Debug, defaultmethods) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
933 |
if (lt.is_enabled()) { |
41669
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
37480
diff
changeset
|
934 |
ResourceMark rm(THREAD); |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
935 |
LogStream ls(lt); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
936 |
ls.print("for slot: "); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
937 |
slot->print_on(&ls); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
938 |
ls.cr(); |
14385 | 939 |
if (method->has_target()) { |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
940 |
method->print_selected(&ls, 1); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
941 |
} else if (method->throws_exception()) { |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
42059
diff
changeset
|
942 |
method->print_exception(&ls, 1); |
14385 | 943 |
} |
944 |
} |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
945 |
|
14385 | 946 |
if (method->has_target()) { |
947 |
Method* selected = method->get_selected_target(); |
|
19966
64732b96b5f5
8024647: Default method resolution with private superclass method
acorn
parents:
19690
diff
changeset
|
948 |
if (selected->method_holder()->is_interface()) { |
41669
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
37480
diff
changeset
|
949 |
assert(!selected->is_private(), "pushing private interface method as default"); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
950 |
defaults.push(selected); |
19966
64732b96b5f5
8024647: Default method resolution with private superclass method
acorn
parents:
19690
diff
changeset
|
951 |
} |
14385 | 952 |
} else if (method->throws_exception()) { |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
953 |
int max_stack = assemble_method_error(&bpool, &buffer, |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
954 |
method->get_exception_name(), method->get_exception_message(), CHECK); |
19966
64732b96b5f5
8024647: Default method resolution with private superclass method
acorn
parents:
19690
diff
changeset
|
955 |
AccessFlags flags = accessFlags_from( |
14385 | 956 |
JVM_ACC_PUBLIC | JVM_ACC_SYNTHETIC | JVM_ACC_BRIDGE); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
957 |
Method* m = new_method(&bpool, &buffer, slot->name(), slot->signature(), |
14385 | 958 |
flags, max_stack, slot->size_of_parameters(), |
959 |
ConstMethod::OVERPASS, CHECK); |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
960 |
// We push to the methods list: |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
961 |
// overpass methods which are exception throwing methods |
19966
64732b96b5f5
8024647: Default method resolution with private superclass method
acorn
parents:
19690
diff
changeset
|
962 |
if (m != NULL) { |
64732b96b5f5
8024647: Default method resolution with private superclass method
acorn
parents:
19690
diff
changeset
|
963 |
overpasses.push(m); |
64732b96b5f5
8024647: Default method resolution with private superclass method
acorn
parents:
19690
diff
changeset
|
964 |
} |
14385 | 965 |
} |
966 |
} |
|
967 |
} |
|
968 |
||
33736
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
969 |
|
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
970 |
log_debug(defaultmethods)("Created %d overpass methods", overpasses.length()); |
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
29871
diff
changeset
|
971 |
log_debug(defaultmethods)("Created %d default methods", defaults.length()); |
14385 | 972 |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
973 |
if (overpasses.length() > 0) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
974 |
switchover_constant_pool(&bpool, klass, &overpasses, CHECK); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
975 |
merge_in_new_methods(klass, &overpasses, CHECK); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
976 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
977 |
if (defaults.length() > 0) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
978 |
create_default_methods(klass, &defaults, CHECK); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
979 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
980 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
981 |
|
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
982 |
static void create_default_methods( InstanceKlass* klass, |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
983 |
GrowableArray<Method*>* new_methods, TRAPS) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
984 |
|
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
985 |
int new_size = new_methods->length(); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
986 |
Array<Method*>* total_default_methods = MetadataFactory::new_array<Method*>( |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
987 |
klass->class_loader_data(), new_size, NULL, CHECK); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
988 |
for (int index = 0; index < new_size; index++ ) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
989 |
total_default_methods->at_put(index, new_methods->at(index)); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
990 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
991 |
Method::sort_methods(total_default_methods, false, false); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
992 |
|
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20300
diff
changeset
|
993 |
klass->set_default_methods(total_default_methods); |
14385 | 994 |
} |
995 |
||
996 |
static void sort_methods(GrowableArray<Method*>* methods) { |
|
997 |
// Note that this must sort using the same key as is used for sorting |
|
998 |
// methods in InstanceKlass. |
|
999 |
bool sorted = true; |
|
1000 |
for (int i = methods->length() - 1; i > 0; --i) { |
|
1001 |
for (int j = 0; j < i; ++j) { |
|
1002 |
Method* m1 = methods->at(j); |
|
1003 |
Method* m2 = methods->at(j + 1); |
|
1004 |
if ((uintptr_t)m1->name() > (uintptr_t)m2->name()) { |
|
1005 |
methods->at_put(j, m2); |
|
1006 |
methods->at_put(j + 1, m1); |
|
1007 |
sorted = false; |
|
1008 |
} |
|
1009 |
} |
|
1010 |
if (sorted) break; |
|
1011 |
sorted = true; |
|
1012 |
} |
|
1013 |
#ifdef ASSERT |
|
1014 |
uintptr_t prev = 0; |
|
1015 |
for (int i = 0; i < methods->length(); ++i) { |
|
1016 |
Method* mh = methods->at(i); |
|
1017 |
uintptr_t nv = (uintptr_t)mh->name(); |
|
1018 |
assert(nv >= prev, "Incorrect overpass method ordering"); |
|
1019 |
prev = nv; |
|
1020 |
} |
|
1021 |
#endif |
|
1022 |
} |
|
1023 |
||
1024 |
static void merge_in_new_methods(InstanceKlass* klass, |
|
1025 |
GrowableArray<Method*>* new_methods, TRAPS) { |
|
1026 |
||
1027 |
enum { ANNOTATIONS, PARAMETERS, DEFAULTS, NUM_ARRAYS }; |
|
1028 |
||
1029 |
Array<Method*>* original_methods = klass->methods(); |
|
1030 |
Array<int>* original_ordering = klass->method_ordering(); |
|
1031 |
Array<int>* merged_ordering = Universe::the_empty_int_array(); |
|
1032 |
||
1033 |
int new_size = klass->methods()->length() + new_methods->length(); |
|
1034 |
||
1035 |
Array<Method*>* merged_methods = MetadataFactory::new_array<Method*>( |
|
1036 |
klass->class_loader_data(), new_size, NULL, CHECK); |
|
15601 | 1037 |
|
22233
f0028de67b30
8030633: nsk/jvmti/RedefineClasses/StressRedefine failed invalid method ordering length on Solaris
coleenp
parents:
22232
diff
changeset
|
1038 |
// original_ordering might be empty if this class has no methods of its own |
f0028de67b30
8030633: nsk/jvmti/RedefineClasses/StressRedefine failed invalid method ordering length on Solaris
coleenp
parents:
22232
diff
changeset
|
1039 |
if (JvmtiExport::can_maintain_original_method_order() || DumpSharedSpaces) { |
14385 | 1040 |
merged_ordering = MetadataFactory::new_array<int>( |
1041 |
klass->class_loader_data(), new_size, CHECK); |
|
1042 |
} |
|
1043 |
int method_order_index = klass->methods()->length(); |
|
1044 |
||
1045 |
sort_methods(new_methods); |
|
1046 |
||
1047 |
// Perform grand merge of existing methods and new methods |
|
1048 |
int orig_idx = 0; |
|
1049 |
int new_idx = 0; |
|
1050 |
||
1051 |
for (int i = 0; i < new_size; ++i) { |
|
1052 |
Method* orig_method = NULL; |
|
1053 |
Method* new_method = NULL; |
|
1054 |
if (orig_idx < original_methods->length()) { |
|
1055 |
orig_method = original_methods->at(orig_idx); |
|
1056 |
} |
|
1057 |
if (new_idx < new_methods->length()) { |
|
1058 |
new_method = new_methods->at(new_idx); |
|
1059 |
} |
|
1060 |
||
1061 |
if (orig_method != NULL && |
|
1062 |
(new_method == NULL || orig_method->name() < new_method->name())) { |
|
1063 |
merged_methods->at_put(i, orig_method); |
|
1064 |
original_methods->at_put(orig_idx, NULL); |
|
1065 |
if (merged_ordering->length() > 0) { |
|
22233
f0028de67b30
8030633: nsk/jvmti/RedefineClasses/StressRedefine failed invalid method ordering length on Solaris
coleenp
parents:
22232
diff
changeset
|
1066 |
assert(original_ordering != NULL && original_ordering->length() > 0, |
f0028de67b30
8030633: nsk/jvmti/RedefineClasses/StressRedefine failed invalid method ordering length on Solaris
coleenp
parents:
22232
diff
changeset
|
1067 |
"should have original order information for this method"); |
14385 | 1068 |
merged_ordering->at_put(i, original_ordering->at(orig_idx)); |
1069 |
} |
|
1070 |
++orig_idx; |
|
1071 |
} else { |
|
1072 |
merged_methods->at_put(i, new_method); |
|
1073 |
if (merged_ordering->length() > 0) { |
|
1074 |
merged_ordering->at_put(i, method_order_index++); |
|
1075 |
} |
|
1076 |
++new_idx; |
|
1077 |
} |
|
1078 |
// update idnum for new location |
|
1079 |
merged_methods->at(i)->set_method_idnum(i); |
|
29316
5287df8a8972
8046246: the constantPoolCacheOopDesc::adjust_method_entries() used in RedefineClasses does not scale
sspitsyn
parents:
27680
diff
changeset
|
1080 |
merged_methods->at(i)->set_orig_method_idnum(i); |
14385 | 1081 |
} |
1082 |
||
1083 |
// Verify correct order |
|
1084 |
#ifdef ASSERT |
|
1085 |
uintptr_t prev = 0; |
|
1086 |
for (int i = 0; i < merged_methods->length(); ++i) { |
|
1087 |
Method* mo = merged_methods->at(i); |
|
1088 |
uintptr_t nv = (uintptr_t)mo->name(); |
|
1089 |
assert(nv >= prev, "Incorrect method ordering"); |
|
1090 |
prev = nv; |
|
1091 |
} |
|
1092 |
#endif |
|
1093 |
||
1094 |
// Replace klass methods with new merged lists |
|
1095 |
klass->set_methods(merged_methods); |
|
17859
cda7f55ca4dc
8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
16379
diff
changeset
|
1096 |
klass->set_initial_method_idnum(new_size); |
22233
f0028de67b30
8030633: nsk/jvmti/RedefineClasses/StressRedefine failed invalid method ordering length on Solaris
coleenp
parents:
22232
diff
changeset
|
1097 |
klass->set_method_ordering(merged_ordering); |
14385 | 1098 |
|
22233
f0028de67b30
8030633: nsk/jvmti/RedefineClasses/StressRedefine failed invalid method ordering length on Solaris
coleenp
parents:
22232
diff
changeset
|
1099 |
// Free metadata |
14385 | 1100 |
ClassLoaderData* cld = klass->class_loader_data(); |
22233
f0028de67b30
8030633: nsk/jvmti/RedefineClasses/StressRedefine failed invalid method ordering length on Solaris
coleenp
parents:
22232
diff
changeset
|
1101 |
if (original_methods->length() > 0) { |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
1102 |
MetadataFactory::free_array(cld, original_methods); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21516
diff
changeset
|
1103 |
} |
22233
f0028de67b30
8030633: nsk/jvmti/RedefineClasses/StressRedefine failed invalid method ordering length on Solaris
coleenp
parents:
22232
diff
changeset
|
1104 |
if (original_ordering != NULL && original_ordering->length() > 0) { |
14385 | 1105 |
MetadataFactory::free_array(cld, original_ordering); |
1106 |
} |
|
1107 |
} |