Thu, 15 Jul 2010 18:40:45 -0700
6964498: JSR 292 invokedynamic sites need local bootstrap methods
Summary: Add JVM_CONSTANT_InvokeDynamic records to constant pool to determine per-instruction BSMs.
Reviewed-by: twisti
1 /*
2 * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
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 */
25 #include "incls/_precompiled.incl"
26 #include "incls/_linkResolver.cpp.incl"
28 //------------------------------------------------------------------------------------------------------------------------
29 // Implementation of FieldAccessInfo
31 void FieldAccessInfo::set(KlassHandle klass, symbolHandle name, int field_index, int field_offset,
32 BasicType field_type, AccessFlags access_flags) {
33 _klass = klass;
34 _name = name;
35 _field_index = field_index;
36 _field_offset = field_offset;
37 _field_type = field_type;
38 _access_flags = access_flags;
39 }
42 //------------------------------------------------------------------------------------------------------------------------
43 // Implementation of CallInfo
46 void CallInfo::set_static(KlassHandle resolved_klass, methodHandle resolved_method, TRAPS) {
47 int vtable_index = methodOopDesc::nonvirtual_vtable_index;
48 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, vtable_index, CHECK);
49 }
52 void CallInfo::set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, TRAPS) {
53 // This is only called for interface methods. If the resolved_method
54 // comes from java/lang/Object, it can be the subject of a virtual call, so
55 // we should pick the vtable index from the resolved method.
56 // Other than that case, there is no valid vtable index to specify.
57 int vtable_index = methodOopDesc::invalid_vtable_index;
58 if (resolved_method->method_holder() == SystemDictionary::Object_klass()) {
59 assert(resolved_method->vtable_index() == selected_method->vtable_index(), "sanity check");
60 vtable_index = resolved_method->vtable_index();
61 }
62 set_common(resolved_klass, selected_klass, resolved_method, selected_method, vtable_index, CHECK);
63 }
65 void CallInfo::set_virtual(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS) {
66 assert(vtable_index >= 0 || vtable_index == methodOopDesc::nonvirtual_vtable_index, "valid index");
67 set_common(resolved_klass, selected_klass, resolved_method, selected_method, vtable_index, CHECK);
68 }
70 void CallInfo::set_dynamic(methodHandle resolved_method, TRAPS) {
71 assert(resolved_method->is_method_handle_invoke(), "");
72 KlassHandle resolved_klass = SystemDictionaryHandles::MethodHandle_klass();
73 assert(resolved_klass == resolved_method->method_holder(), "");
74 int vtable_index = methodOopDesc::nonvirtual_vtable_index;
75 assert(resolved_method->vtable_index() == vtable_index, "");
76 set_common(resolved_klass, KlassHandle(), resolved_method, resolved_method, vtable_index, CHECK);
77 }
79 void CallInfo::set_common(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS) {
80 assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond");
81 _resolved_klass = resolved_klass;
82 _selected_klass = selected_klass;
83 _resolved_method = resolved_method;
84 _selected_method = selected_method;
85 _vtable_index = vtable_index;
86 if (CompilationPolicy::mustBeCompiled(selected_method)) {
87 // This path is unusual, mostly used by the '-Xcomp' stress test mode.
89 // Note: with several active threads, the mustBeCompiled may be true
90 // while canBeCompiled is false; remove assert
91 // assert(CompilationPolicy::canBeCompiled(selected_method), "cannot compile");
92 if (THREAD->is_Compiler_thread()) {
93 // don't force compilation, resolve was on behalf of compiler
94 return;
95 }
96 if (instanceKlass::cast(selected_method->method_holder())->is_not_initialized()) {
97 // 'is_not_initialized' means not only '!is_initialized', but also that
98 // initialization has not been started yet ('!being_initialized')
99 // Do not force compilation of methods in uninitialized classes.
100 // Note that doing this would throw an assert later,
101 // in CompileBroker::compile_method.
102 // We sometimes use the link resolver to do reflective lookups
103 // even before classes are initialized.
104 return;
105 }
106 CompileBroker::compile_method(selected_method, InvocationEntryBci,
107 methodHandle(), 0, "mustBeCompiled", CHECK);
108 }
109 }
112 //------------------------------------------------------------------------------------------------------------------------
113 // Klass resolution
115 void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS) {
116 if (!Reflection::verify_class_access(ref_klass->as_klassOop(),
117 sel_klass->as_klassOop(),
118 true)) {
119 ResourceMark rm(THREAD);
120 Exceptions::fthrow(
121 THREAD_AND_LOCATION,
122 vmSymbolHandles::java_lang_IllegalAccessError(),
123 "tried to access class %s from class %s",
124 sel_klass->external_name(),
125 ref_klass->external_name()
126 );
127 return;
128 }
129 }
131 void LinkResolver::resolve_klass(KlassHandle& result, constantPoolHandle pool, int index, TRAPS) {
132 klassOop result_oop = pool->klass_ref_at(index, CHECK);
133 result = KlassHandle(THREAD, result_oop);
134 }
136 void LinkResolver::resolve_klass_no_update(KlassHandle& result, constantPoolHandle pool, int index, TRAPS) {
137 klassOop result_oop =
138 constantPoolOopDesc::klass_ref_at_if_loaded_check(pool, index, CHECK);
139 result = KlassHandle(THREAD, result_oop);
140 }
143 //------------------------------------------------------------------------------------------------------------------------
144 // Method resolution
145 //
146 // According to JVM spec. $5.4.3c & $5.4.3d
148 void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
149 methodOop result_oop = klass->uncached_lookup_method(name(), signature());
150 if (EnableMethodHandles && result_oop != NULL) {
151 switch (result_oop->intrinsic_id()) {
152 case vmIntrinsics::_invokeExact:
153 case vmIntrinsics::_invokeGeneric:
154 case vmIntrinsics::_invokeDynamic:
155 // Do not link directly to these. The VM must produce a synthetic one using lookup_implicit_method.
156 return;
157 }
158 }
159 result = methodHandle(THREAD, result_oop);
160 }
162 // returns first instance method
163 void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
164 methodOop result_oop = klass->uncached_lookup_method(name(), signature());
165 result = methodHandle(THREAD, result_oop);
166 while (!result.is_null() && result->is_static()) {
167 klass = KlassHandle(THREAD, Klass::cast(result->method_holder())->super());
168 result = methodHandle(THREAD, klass->uncached_lookup_method(name(), signature()));
169 }
170 }
173 int LinkResolver::vtable_index_of_miranda_method(KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
174 ResourceMark rm(THREAD);
175 klassVtable *vt = instanceKlass::cast(klass())->vtable();
176 return vt->index_of_miranda(name(), signature());
177 }
179 void LinkResolver::lookup_method_in_interfaces(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
180 instanceKlass *ik = instanceKlass::cast(klass());
181 result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name(), signature()));
182 }
184 void LinkResolver::lookup_implicit_method(methodHandle& result,
185 KlassHandle klass, symbolHandle name, symbolHandle signature,
186 KlassHandle current_klass,
187 TRAPS) {
188 if (EnableMethodHandles &&
189 klass() == SystemDictionary::MethodHandle_klass() &&
190 methodOopDesc::is_method_handle_invoke_name(name())) {
191 if (!MethodHandles::enabled()) {
192 // Make sure the Java part of the runtime has been booted up.
193 klassOop natives = SystemDictionary::MethodHandleNatives_klass();
194 if (natives == NULL || instanceKlass::cast(natives)->is_not_initialized()) {
195 SystemDictionary::resolve_or_fail(vmSymbolHandles::sun_dyn_MethodHandleNatives(),
196 Handle(),
197 Handle(),
198 true,
199 CHECK);
200 }
201 }
202 methodOop result_oop = SystemDictionary::find_method_handle_invoke(name,
203 signature,
204 current_klass,
205 CHECK);
206 if (result_oop != NULL) {
207 assert(result_oop->is_method_handle_invoke() && result_oop->signature() == signature(), "consistent");
208 result = methodHandle(THREAD, result_oop);
209 }
210 }
211 }
213 void LinkResolver::check_method_accessability(KlassHandle ref_klass,
214 KlassHandle resolved_klass,
215 KlassHandle sel_klass,
216 methodHandle sel_method,
217 TRAPS) {
219 AccessFlags flags = sel_method->access_flags();
221 // Special case: arrays always override "clone". JVMS 2.15.
222 // If the resolved klass is an array class, and the declaring class
223 // is java.lang.Object and the method is "clone", set the flags
224 // to public.
225 //
226 // We'll check for the method name first, as that's most likely
227 // to be false (so we'll short-circuit out of these tests).
228 if (sel_method->name() == vmSymbols::clone_name() &&
229 sel_klass() == SystemDictionary::Object_klass() &&
230 resolved_klass->oop_is_array()) {
231 // We need to change "protected" to "public".
232 assert(flags.is_protected(), "clone not protected?");
233 jint new_flags = flags.as_int();
234 new_flags = new_flags & (~JVM_ACC_PROTECTED);
235 new_flags = new_flags | JVM_ACC_PUBLIC;
236 flags.set_flags(new_flags);
237 }
239 if (!Reflection::verify_field_access(ref_klass->as_klassOop(),
240 resolved_klass->as_klassOop(),
241 sel_klass->as_klassOop(),
242 flags,
243 true)) {
244 ResourceMark rm(THREAD);
245 Exceptions::fthrow(
246 THREAD_AND_LOCATION,
247 vmSymbolHandles::java_lang_IllegalAccessError(),
248 "tried to access method %s.%s%s from class %s",
249 sel_klass->external_name(),
250 sel_method->name()->as_C_string(),
251 sel_method->signature()->as_C_string(),
252 ref_klass->external_name()
253 );
254 return;
255 }
256 }
258 void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle& resolved_klass,
259 constantPoolHandle pool, int index, TRAPS) {
261 // resolve klass
262 resolve_klass(resolved_klass, pool, index, CHECK);
264 symbolHandle method_name (THREAD, pool->name_ref_at(index));
265 symbolHandle method_signature (THREAD, pool->signature_ref_at(index));
266 KlassHandle current_klass(THREAD, pool->pool_holder());
268 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
269 }
271 void LinkResolver::resolve_dynamic_method(methodHandle& resolved_method, KlassHandle& resolved_klass, constantPoolHandle pool, int index, TRAPS) {
272 // The class is java.dyn.MethodHandle
273 resolved_klass = SystemDictionaryHandles::MethodHandle_klass();
275 symbolHandle method_name = vmSymbolHandles::invokeExact_name();
277 symbolHandle method_signature(THREAD, pool->signature_ref_at(index));
278 KlassHandle current_klass (THREAD, pool->pool_holder());
280 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
281 }
283 void LinkResolver::resolve_interface_method(methodHandle& resolved_method, KlassHandle& resolved_klass, constantPoolHandle pool, int index, TRAPS) {
285 // resolve klass
286 resolve_klass(resolved_klass, pool, index, CHECK);
287 symbolHandle method_name (THREAD, pool->name_ref_at(index));
288 symbolHandle method_signature (THREAD, pool->signature_ref_at(index));
289 KlassHandle current_klass(THREAD, pool->pool_holder());
291 resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
292 }
295 void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle resolved_klass,
296 symbolHandle method_name, symbolHandle method_signature,
297 KlassHandle current_klass, bool check_access, TRAPS) {
299 // 1. check if klass is not interface
300 if (resolved_klass->is_interface()) {
301 char buf[200];
302 jio_snprintf(buf, sizeof(buf), "Found interface %s, but class was expected", Klass::cast(resolved_klass())->external_name());
303 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
304 }
306 // 2. lookup method in resolved klass and its super klasses
307 lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, CHECK);
309 if (resolved_method.is_null()) { // not found in the class hierarchy
310 // 3. lookup method in all the interfaces implemented by the resolved klass
311 lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK);
313 if (resolved_method.is_null()) {
314 // JSR 292: see if this is an implicitly generated method MethodHandle.invoke(*...)
315 lookup_implicit_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, CHECK);
316 }
318 if (resolved_method.is_null()) {
319 // 4. method lookup failed
320 ResourceMark rm(THREAD);
321 THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(),
322 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
323 method_name(),
324 method_signature()));
325 }
326 }
328 // 5. check if method is concrete
329 if (resolved_method->is_abstract() && !resolved_klass->is_abstract()) {
330 ResourceMark rm(THREAD);
331 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
332 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
333 method_name(),
334 method_signature()));
335 }
337 // 6. access checks, access checking may be turned off when calling from within the VM.
338 if (check_access) {
339 assert(current_klass.not_null() , "current_klass should not be null");
341 // check if method can be accessed by the referring class
342 check_method_accessability(current_klass,
343 resolved_klass,
344 KlassHandle(THREAD, resolved_method->method_holder()),
345 resolved_method,
346 CHECK);
348 // check loader constraints
349 Handle loader (THREAD, instanceKlass::cast(current_klass())->class_loader());
350 Handle class_loader (THREAD, instanceKlass::cast(resolved_method->method_holder())->class_loader());
351 {
352 ResourceMark rm(THREAD);
353 char* failed_type_name =
354 SystemDictionary::check_signature_loaders(method_signature, loader,
355 class_loader, true, CHECK);
356 if (failed_type_name != NULL) {
357 const char* msg = "loader constraint violation: when resolving method"
358 " \"%s\" the class loader (instance of %s) of the current class, %s,"
359 " and the class loader (instance of %s) for resolved class, %s, have"
360 " different Class objects for the type %s used in the signature";
361 char* sig = methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name(),method_signature());
362 const char* loader1 = SystemDictionary::loader_name(loader());
363 char* current = instanceKlass::cast(current_klass())->name()->as_C_string();
364 const char* loader2 = SystemDictionary::loader_name(class_loader());
365 char* resolved = instanceKlass::cast(resolved_klass())->name()->as_C_string();
366 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
367 strlen(current) + strlen(loader2) + strlen(resolved) +
368 strlen(failed_type_name);
369 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
370 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2,
371 resolved, failed_type_name);
372 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
373 }
374 }
375 }
376 }
378 void LinkResolver::resolve_interface_method(methodHandle& resolved_method,
379 KlassHandle resolved_klass,
380 symbolHandle method_name,
381 symbolHandle method_signature,
382 KlassHandle current_klass,
383 bool check_access, TRAPS) {
385 // check if klass is interface
386 if (!resolved_klass->is_interface()) {
387 char buf[200];
388 jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", Klass::cast(resolved_klass())->external_name());
389 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
390 }
392 // lookup method in this interface or its super, java.lang.Object
393 lookup_instance_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, CHECK);
395 if (resolved_method.is_null()) {
396 // lookup method in all the super-interfaces
397 lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK);
398 if (resolved_method.is_null()) {
399 // no method found
400 ResourceMark rm(THREAD);
401 THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(),
402 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
403 method_name(),
404 method_signature()));
405 }
406 }
408 if (check_access) {
409 HandleMark hm(THREAD);
410 Handle loader (THREAD, instanceKlass::cast(current_klass())->class_loader());
411 Handle class_loader (THREAD, instanceKlass::cast(resolved_method->method_holder())->class_loader());
412 {
413 ResourceMark rm(THREAD);
414 char* failed_type_name =
415 SystemDictionary::check_signature_loaders(method_signature, loader,
416 class_loader, true, CHECK);
417 if (failed_type_name != NULL) {
418 const char* msg = "loader constraint violation: when resolving "
419 "interface method \"%s\" the class loader (instance of %s) of the "
420 "current class, %s, and the class loader (instance of %s) for "
421 "resolved class, %s, have different Class objects for the type %s "
422 "used in the signature";
423 char* sig = methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name(),method_signature());
424 const char* loader1 = SystemDictionary::loader_name(loader());
425 char* current = instanceKlass::cast(current_klass())->name()->as_C_string();
426 const char* loader2 = SystemDictionary::loader_name(class_loader());
427 char* resolved = instanceKlass::cast(resolved_klass())->name()->as_C_string();
428 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
429 strlen(current) + strlen(loader2) + strlen(resolved) +
430 strlen(failed_type_name);
431 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
432 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2,
433 resolved, failed_type_name);
434 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
435 }
436 }
437 }
438 }
440 //------------------------------------------------------------------------------------------------------------------------
441 // Field resolution
443 void LinkResolver::check_field_accessability(KlassHandle ref_klass,
444 KlassHandle resolved_klass,
445 KlassHandle sel_klass,
446 fieldDescriptor& fd,
447 TRAPS) {
448 if (!Reflection::verify_field_access(ref_klass->as_klassOop(),
449 resolved_klass->as_klassOop(),
450 sel_klass->as_klassOop(),
451 fd.access_flags(),
452 true)) {
453 ResourceMark rm(THREAD);
454 Exceptions::fthrow(
455 THREAD_AND_LOCATION,
456 vmSymbolHandles::java_lang_IllegalAccessError(),
457 "tried to access field %s.%s from class %s",
458 sel_klass->external_name(),
459 fd.name()->as_C_string(),
460 ref_klass->external_name()
461 );
462 return;
463 }
464 }
466 void LinkResolver::resolve_field(FieldAccessInfo& result, constantPoolHandle pool, int index, Bytecodes::Code byte, bool check_only, TRAPS) {
467 resolve_field(result, pool, index, byte, check_only, true, CHECK);
468 }
470 void LinkResolver::resolve_field(FieldAccessInfo& result, constantPoolHandle pool, int index, Bytecodes::Code byte, bool check_only, bool update_pool, TRAPS) {
471 assert(byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic ||
472 byte == Bytecodes::_getfield || byte == Bytecodes::_putfield, "bad bytecode");
474 bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic);
475 bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic);
477 // resolve specified klass
478 KlassHandle resolved_klass;
479 if (update_pool) {
480 resolve_klass(resolved_klass, pool, index, CHECK);
481 } else {
482 resolve_klass_no_update(resolved_klass, pool, index, CHECK);
483 }
484 // Load these early in case the resolve of the containing klass fails
485 symbolOop field = pool->name_ref_at(index);
486 symbolHandle field_h (THREAD, field); // preserve in case we need the name
487 symbolOop sig = pool->signature_ref_at(index);
488 // Check if there's a resolved klass containing the field
489 if( resolved_klass.is_null() ) {
490 ResourceMark rm(THREAD);
491 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());
492 }
494 // Resolve instance field
495 fieldDescriptor fd; // find_field initializes fd if found
496 KlassHandle sel_klass(THREAD, instanceKlass::cast(resolved_klass())->find_field(field, sig, &fd));
497 // check if field exists; i.e., if a klass containing the field def has been selected
498 if (sel_klass.is_null()){
499 ResourceMark rm(THREAD);
500 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());
501 }
503 // check access
504 KlassHandle ref_klass(THREAD, pool->pool_holder());
505 check_field_accessability(ref_klass, resolved_klass, sel_klass, fd, CHECK);
507 // check for errors
508 if (is_static != fd.is_static()) {
509 char msg[200];
510 jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", Klass::cast(resolved_klass())->external_name(), fd.name()->as_C_string());
511 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg);
512 }
514 // Final fields can only be accessed from its own class.
515 if (is_put && fd.access_flags().is_final() && sel_klass() != pool->pool_holder()) {
516 THROW(vmSymbols::java_lang_IllegalAccessError());
517 }
519 // initialize resolved_klass if necessary
520 // note 1: the klass which declared the field must be initialized (i.e, sel_klass)
521 // according to the newest JVM spec (5.5, p.170) - was bug (gri 7/28/99)
522 //
523 // note 2: we don't want to force initialization if we are just checking
524 // if the field access is legal; e.g., during compilation
525 if (is_static && !check_only) {
526 sel_klass->initialize(CHECK);
527 }
529 {
530 HandleMark hm(THREAD);
531 Handle ref_loader (THREAD, instanceKlass::cast(ref_klass())->class_loader());
532 Handle sel_loader (THREAD, instanceKlass::cast(sel_klass())->class_loader());
533 symbolHandle signature_ref (THREAD, pool->signature_ref_at(index));
534 {
535 ResourceMark rm(THREAD);
536 char* failed_type_name =
537 SystemDictionary::check_signature_loaders(signature_ref,
538 ref_loader, sel_loader,
539 false,
540 CHECK);
541 if (failed_type_name != NULL) {
542 const char* msg = "loader constraint violation: when resolving field"
543 " \"%s\" the class loader (instance of %s) of the referring class, "
544 "%s, and the class loader (instance of %s) for the field's resolved "
545 "type, %s, have different Class objects for that type";
546 char* field_name = field_h()->as_C_string();
547 const char* loader1 = SystemDictionary::loader_name(ref_loader());
548 char* sel = instanceKlass::cast(sel_klass())->name()->as_C_string();
549 const char* loader2 = SystemDictionary::loader_name(sel_loader());
550 size_t buflen = strlen(msg) + strlen(field_name) + strlen(loader1) +
551 strlen(sel) + strlen(loader2) + strlen(failed_type_name);
552 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
553 jio_snprintf(buf, buflen, msg, field_name, loader1, sel, loader2,
554 failed_type_name);
555 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
556 }
557 }
558 }
560 // return information. note that the klass is set to the actual klass containing the
561 // field, otherwise access of static fields in superclasses will not work.
562 KlassHandle holder (THREAD, fd.field_holder());
563 symbolHandle name (THREAD, fd.name());
564 result.set(holder, name, fd.index(), fd.offset(), fd.field_type(), fd.access_flags());
565 }
568 //------------------------------------------------------------------------------------------------------------------------
569 // Invoke resolution
570 //
571 // Naming conventions:
572 //
573 // resolved_method the specified method (i.e., static receiver specified via constant pool index)
574 // sel_method the selected method (selected via run-time lookup; e.g., based on dynamic receiver class)
575 // resolved_klass the specified klass (i.e., specified via constant pool index)
576 // recv_klass the receiver klass
579 void LinkResolver::resolve_static_call(CallInfo& result, KlassHandle& resolved_klass, symbolHandle method_name,
580 symbolHandle method_signature, KlassHandle current_klass,
581 bool check_access, bool initialize_class, TRAPS) {
582 methodHandle resolved_method;
583 linktime_resolve_static_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
584 resolved_klass = KlassHandle(THREAD, Klass::cast(resolved_method->method_holder()));
586 // Initialize klass (this should only happen if everything is ok)
587 if (initialize_class && resolved_klass->should_be_initialized()) {
588 resolved_klass->initialize(CHECK);
589 linktime_resolve_static_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
590 }
592 // setup result
593 result.set_static(resolved_klass, resolved_method, CHECK);
594 }
596 // throws linktime exceptions
597 void LinkResolver::linktime_resolve_static_method(methodHandle& resolved_method, KlassHandle resolved_klass,
598 symbolHandle method_name, symbolHandle method_signature,
599 KlassHandle current_klass, bool check_access, TRAPS) {
601 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
602 assert(resolved_method->name() != vmSymbols::class_initializer_name(), "should have been checked in verifier");
604 // check if static
605 if (!resolved_method->is_static()) {
606 char buf[200];
607 jio_snprintf(buf, sizeof(buf), "Expected static method %s", methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
608 resolved_method->name(),
609 resolved_method->signature()));
610 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
611 }
612 }
615 void LinkResolver::resolve_special_call(CallInfo& result, KlassHandle resolved_klass, symbolHandle method_name,
616 symbolHandle method_signature, KlassHandle current_klass, bool check_access, TRAPS) {
617 methodHandle resolved_method;
618 linktime_resolve_special_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
619 runtime_resolve_special_method(result, resolved_method, resolved_klass, current_klass, check_access, CHECK);
620 }
622 // throws linktime exceptions
623 void LinkResolver::linktime_resolve_special_method(methodHandle& resolved_method, KlassHandle resolved_klass,
624 symbolHandle method_name, symbolHandle method_signature,
625 KlassHandle current_klass, bool check_access, TRAPS) {
627 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
629 // check if method name is <init>, that it is found in same klass as static type
630 if (resolved_method->name() == vmSymbols::object_initializer_name() &&
631 resolved_method->method_holder() != resolved_klass()) {
632 ResourceMark rm(THREAD);
633 Exceptions::fthrow(
634 THREAD_AND_LOCATION,
635 vmSymbolHandles::java_lang_NoSuchMethodError(),
636 "%s: method %s%s not found",
637 resolved_klass->external_name(),
638 resolved_method->name()->as_C_string(),
639 resolved_method->signature()->as_C_string()
640 );
641 return;
642 }
644 // check if not static
645 if (resolved_method->is_static()) {
646 char buf[200];
647 jio_snprintf(buf, sizeof(buf),
648 "Expecting non-static method %s",
649 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
650 resolved_method->name(),
651 resolved_method->signature()));
652 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
653 }
654 }
656 // throws runtime exceptions
657 void LinkResolver::runtime_resolve_special_method(CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass,
658 KlassHandle current_klass, bool check_access, TRAPS) {
660 // resolved method is selected method unless we have an old-style lookup
661 methodHandle sel_method(THREAD, resolved_method());
663 // check if this is an old-style super call and do a new lookup if so
664 { KlassHandle method_klass = KlassHandle(THREAD,
665 resolved_method->method_holder());
667 if (check_access &&
668 // a) check if ACC_SUPER flag is set for the current class
669 current_klass->is_super() &&
670 // b) check if the method class is a superclass of the current class (superclass relation is not reflexive!)
671 current_klass->is_subtype_of(method_klass()) && current_klass() != method_klass() &&
672 // c) check if the method is not <init>
673 resolved_method->name() != vmSymbols::object_initializer_name()) {
674 // Lookup super method
675 KlassHandle super_klass(THREAD, current_klass->super());
676 lookup_instance_method_in_klasses(sel_method, super_klass,
677 symbolHandle(THREAD, resolved_method->name()),
678 symbolHandle(THREAD, resolved_method->signature()), CHECK);
679 // check if found
680 if (sel_method.is_null()) {
681 ResourceMark rm(THREAD);
682 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
683 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
684 resolved_method->name(),
685 resolved_method->signature()));
686 }
687 }
688 }
690 // check if not static
691 if (sel_method->is_static()) {
692 char buf[200];
693 jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
694 resolved_method->name(),
695 resolved_method->signature()));
696 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
697 }
699 // check if abstract
700 if (sel_method->is_abstract()) {
701 ResourceMark rm(THREAD);
702 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
703 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
704 sel_method->name(),
705 sel_method->signature()));
706 }
708 // setup result
709 result.set_static(resolved_klass, sel_method, CHECK);
710 }
712 void LinkResolver::resolve_virtual_call(CallInfo& result, Handle recv, KlassHandle receiver_klass, KlassHandle resolved_klass,
713 symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass,
714 bool check_access, bool check_null_and_abstract, TRAPS) {
715 methodHandle resolved_method;
716 linktime_resolve_virtual_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
717 runtime_resolve_virtual_method(result, resolved_method, resolved_klass, recv, receiver_klass, check_null_and_abstract, CHECK);
718 }
720 // throws linktime exceptions
721 void LinkResolver::linktime_resolve_virtual_method(methodHandle &resolved_method, KlassHandle resolved_klass,
722 symbolHandle method_name, symbolHandle method_signature,
723 KlassHandle current_klass, bool check_access, TRAPS) {
724 // normal method resolution
725 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
727 assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier");
728 assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier");
730 // check if not static
731 if (resolved_method->is_static()) {
732 char buf[200];
733 jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
734 resolved_method->name(),
735 resolved_method->signature()));
736 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
737 }
738 }
740 // throws runtime exceptions
741 void LinkResolver::runtime_resolve_virtual_method(CallInfo& result,
742 methodHandle resolved_method,
743 KlassHandle resolved_klass,
744 Handle recv,
745 KlassHandle recv_klass,
746 bool check_null_and_abstract,
747 TRAPS) {
749 // setup default return values
750 int vtable_index = methodOopDesc::invalid_vtable_index;
751 methodHandle selected_method;
753 assert(recv.is_null() || recv->is_oop(), "receiver is not an oop");
755 // runtime method resolution
756 if (check_null_and_abstract && recv.is_null()) { // check if receiver exists
757 THROW(vmSymbols::java_lang_NullPointerException());
758 }
760 // Virtual methods cannot be resolved before its klass has been linked, for otherwise the methodOop's
761 // has not been rewritten, and the vtable initialized.
762 assert(instanceKlass::cast(resolved_method->method_holder())->is_linked(), "must be linked");
764 // Virtual methods cannot be resolved before its klass has been linked, for otherwise the methodOop's
765 // has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since
766 // a missing receiver might result in a bogus lookup.
767 assert(instanceKlass::cast(resolved_method->method_holder())->is_linked(), "must be linked");
769 // do lookup based on receiver klass using the vtable index
770 if (resolved_method->method_holder()->klass_part()->is_interface()) { // miranda method
771 vtable_index = vtable_index_of_miranda_method(resolved_klass,
772 symbolHandle(THREAD, resolved_method->name()),
773 symbolHandle(THREAD, resolved_method->signature()), CHECK);
774 assert(vtable_index >= 0 , "we should have valid vtable index at this point");
776 instanceKlass* inst = instanceKlass::cast(recv_klass());
777 selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index));
778 } else {
779 // at this point we are sure that resolved_method is virtual and not
780 // a miranda method; therefore, it must have a valid vtable index.
781 vtable_index = resolved_method->vtable_index();
782 // We could get a negative vtable_index for final methods,
783 // because as an optimization they are they are never put in the vtable,
784 // unless they override an existing method.
785 // If we do get a negative, it means the resolved method is the the selected
786 // method, and it can never be changed by an override.
787 if (vtable_index == methodOopDesc::nonvirtual_vtable_index) {
788 assert(resolved_method->can_be_statically_bound(), "cannot override this method");
789 selected_method = resolved_method;
790 } else {
791 // recv_klass might be an arrayKlassOop but all vtables start at
792 // the same place. The cast is to avoid virtual call and assertion.
793 instanceKlass* inst = (instanceKlass*)recv_klass()->klass_part();
794 selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index));
795 }
796 }
798 // check if method exists
799 if (selected_method.is_null()) {
800 ResourceMark rm(THREAD);
801 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
802 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
803 resolved_method->name(),
804 resolved_method->signature()));
805 }
807 // check if abstract
808 if (check_null_and_abstract && selected_method->is_abstract()) {
809 ResourceMark rm(THREAD);
810 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
811 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
812 selected_method->name(),
813 selected_method->signature()));
814 }
816 // setup result
817 result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK);
818 }
820 void LinkResolver::resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, KlassHandle resolved_klass,
821 symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass,
822 bool check_access, bool check_null_and_abstract, TRAPS) {
823 methodHandle resolved_method;
824 linktime_resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
825 runtime_resolve_interface_method(result, resolved_method, resolved_klass, recv, recv_klass, check_null_and_abstract, CHECK);
826 }
828 // throws linktime exceptions
829 void LinkResolver::linktime_resolve_interface_method(methodHandle& resolved_method, KlassHandle resolved_klass, symbolHandle method_name,
830 symbolHandle method_signature, KlassHandle current_klass, bool check_access, TRAPS) {
831 // normal interface method resolution
832 resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
834 assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier");
835 assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier");
836 }
838 // throws runtime exceptions
839 void LinkResolver::runtime_resolve_interface_method(CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass,
840 Handle recv, KlassHandle recv_klass, bool check_null_and_abstract, TRAPS) {
841 // check if receiver exists
842 if (check_null_and_abstract && recv.is_null()) {
843 THROW(vmSymbols::java_lang_NullPointerException());
844 }
846 // check if receiver klass implements the resolved interface
847 if (!recv_klass->is_subtype_of(resolved_klass())) {
848 char buf[200];
849 jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s",
850 (Klass::cast(recv_klass()))->external_name(),
851 (Klass::cast(resolved_klass()))->external_name());
852 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
853 }
854 // do lookup based on receiver klass
855 methodHandle sel_method;
856 lookup_instance_method_in_klasses(sel_method, recv_klass,
857 symbolHandle(THREAD, resolved_method->name()),
858 symbolHandle(THREAD, resolved_method->signature()), CHECK);
859 // check if method exists
860 if (sel_method.is_null()) {
861 ResourceMark rm(THREAD);
862 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
863 methodOopDesc::name_and_sig_as_C_string(Klass::cast(recv_klass()),
864 resolved_method->name(),
865 resolved_method->signature()));
866 }
867 // check if public
868 if (!sel_method->is_public()) {
869 ResourceMark rm(THREAD);
870 THROW_MSG(vmSymbols::java_lang_IllegalAccessError(),
871 methodOopDesc::name_and_sig_as_C_string(Klass::cast(recv_klass()),
872 sel_method->name(),
873 sel_method->signature()));
874 }
875 // check if abstract
876 if (check_null_and_abstract && sel_method->is_abstract()) {
877 ResourceMark rm(THREAD);
878 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
879 methodOopDesc::name_and_sig_as_C_string(Klass::cast(recv_klass()),
880 sel_method->name(),
881 sel_method->signature()));
882 }
883 // setup result
884 result.set_interface(resolved_klass, recv_klass, resolved_method, sel_method, CHECK);
885 }
888 methodHandle LinkResolver::linktime_resolve_interface_method_or_null(
889 KlassHandle resolved_klass,
890 symbolHandle method_name,
891 symbolHandle method_signature,
892 KlassHandle current_klass,
893 bool check_access) {
894 EXCEPTION_MARK;
895 methodHandle method_result;
896 linktime_resolve_interface_method(method_result, resolved_klass, method_name, method_signature, current_klass, check_access, THREAD);
897 if (HAS_PENDING_EXCEPTION) {
898 CLEAR_PENDING_EXCEPTION;
899 return methodHandle();
900 } else {
901 return method_result;
902 }
903 }
905 methodHandle LinkResolver::linktime_resolve_virtual_method_or_null(
906 KlassHandle resolved_klass,
907 symbolHandle method_name,
908 symbolHandle method_signature,
909 KlassHandle current_klass,
910 bool check_access) {
911 EXCEPTION_MARK;
912 methodHandle method_result;
913 linktime_resolve_virtual_method(method_result, resolved_klass, method_name, method_signature, current_klass, check_access, THREAD);
914 if (HAS_PENDING_EXCEPTION) {
915 CLEAR_PENDING_EXCEPTION;
916 return methodHandle();
917 } else {
918 return method_result;
919 }
920 }
922 methodHandle LinkResolver::resolve_virtual_call_or_null(
923 KlassHandle receiver_klass,
924 KlassHandle resolved_klass,
925 symbolHandle name,
926 symbolHandle signature,
927 KlassHandle current_klass) {
928 EXCEPTION_MARK;
929 CallInfo info;
930 resolve_virtual_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD);
931 if (HAS_PENDING_EXCEPTION) {
932 CLEAR_PENDING_EXCEPTION;
933 return methodHandle();
934 }
935 return info.selected_method();
936 }
938 methodHandle LinkResolver::resolve_interface_call_or_null(
939 KlassHandle receiver_klass,
940 KlassHandle resolved_klass,
941 symbolHandle name,
942 symbolHandle signature,
943 KlassHandle current_klass) {
944 EXCEPTION_MARK;
945 CallInfo info;
946 resolve_interface_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD);
947 if (HAS_PENDING_EXCEPTION) {
948 CLEAR_PENDING_EXCEPTION;
949 return methodHandle();
950 }
951 return info.selected_method();
952 }
954 int LinkResolver::resolve_virtual_vtable_index(
955 KlassHandle receiver_klass,
956 KlassHandle resolved_klass,
957 symbolHandle name,
958 symbolHandle signature,
959 KlassHandle current_klass) {
960 EXCEPTION_MARK;
961 CallInfo info;
962 resolve_virtual_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD);
963 if (HAS_PENDING_EXCEPTION) {
964 CLEAR_PENDING_EXCEPTION;
965 return methodOopDesc::invalid_vtable_index;
966 }
967 return info.vtable_index();
968 }
970 methodHandle LinkResolver::resolve_static_call_or_null(
971 KlassHandle resolved_klass,
972 symbolHandle name,
973 symbolHandle signature,
974 KlassHandle current_klass) {
975 EXCEPTION_MARK;
976 CallInfo info;
977 resolve_static_call(info, resolved_klass, name, signature, current_klass, true, false, THREAD);
978 if (HAS_PENDING_EXCEPTION) {
979 CLEAR_PENDING_EXCEPTION;
980 return methodHandle();
981 }
982 return info.selected_method();
983 }
985 methodHandle LinkResolver::resolve_special_call_or_null(KlassHandle resolved_klass, symbolHandle name, symbolHandle signature,
986 KlassHandle current_klass) {
987 EXCEPTION_MARK;
988 CallInfo info;
989 resolve_special_call(info, resolved_klass, name, signature, current_klass, true, THREAD);
990 if (HAS_PENDING_EXCEPTION) {
991 CLEAR_PENDING_EXCEPTION;
992 return methodHandle();
993 }
994 return info.selected_method();
995 }
999 //------------------------------------------------------------------------------------------------------------------------
1000 // ConstantPool entries
1002 void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, constantPoolHandle pool, int index, Bytecodes::Code byte, TRAPS) {
1003 switch (byte) {
1004 case Bytecodes::_invokestatic : resolve_invokestatic (result, pool, index, CHECK); break;
1005 case Bytecodes::_invokespecial : resolve_invokespecial (result, pool, index, CHECK); break;
1006 case Bytecodes::_invokevirtual : resolve_invokevirtual (result, recv, pool, index, CHECK); break;
1007 case Bytecodes::_invokedynamic : resolve_invokedynamic (result, pool, index, CHECK); break;
1008 case Bytecodes::_invokeinterface: resolve_invokeinterface(result, recv, pool, index, CHECK); break;
1009 }
1010 return;
1011 }
1013 void LinkResolver::resolve_pool(KlassHandle& resolved_klass, symbolHandle& method_name, symbolHandle& method_signature,
1014 KlassHandle& current_klass, constantPoolHandle pool, int index, TRAPS) {
1015 // resolve klass
1016 resolve_klass(resolved_klass, pool, index, CHECK);
1018 // Get name, signature, and static klass
1019 method_name = symbolHandle(THREAD, pool->name_ref_at(index));
1020 method_signature = symbolHandle(THREAD, pool->signature_ref_at(index));
1021 current_klass = KlassHandle(THREAD, pool->pool_holder());
1022 }
1025 void LinkResolver::resolve_invokestatic(CallInfo& result, constantPoolHandle pool, int index, TRAPS) {
1026 KlassHandle resolved_klass;
1027 symbolHandle method_name;
1028 symbolHandle method_signature;
1029 KlassHandle current_klass;
1030 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK);
1031 resolve_static_call(result, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
1032 }
1035 void LinkResolver::resolve_invokespecial(CallInfo& result, constantPoolHandle pool, int index, TRAPS) {
1036 KlassHandle resolved_klass;
1037 symbolHandle method_name;
1038 symbolHandle method_signature;
1039 KlassHandle current_klass;
1040 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK);
1041 resolve_special_call(result, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
1042 }
1045 void LinkResolver::resolve_invokevirtual(CallInfo& result, Handle recv,
1046 constantPoolHandle pool, int index,
1047 TRAPS) {
1049 KlassHandle resolved_klass;
1050 symbolHandle method_name;
1051 symbolHandle method_signature;
1052 KlassHandle current_klass;
1053 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK);
1054 KlassHandle recvrKlass (THREAD, recv.is_null() ? (klassOop)NULL : recv->klass());
1055 resolve_virtual_call(result, recv, recvrKlass, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
1056 }
1059 void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, constantPoolHandle pool, int index, TRAPS) {
1060 KlassHandle resolved_klass;
1061 symbolHandle method_name;
1062 symbolHandle method_signature;
1063 KlassHandle current_klass;
1064 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK);
1065 KlassHandle recvrKlass (THREAD, recv.is_null() ? (klassOop)NULL : recv->klass());
1066 resolve_interface_call(result, recv, recvrKlass, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
1067 }
1070 void LinkResolver::resolve_invokedynamic(CallInfo& result, constantPoolHandle pool, int raw_index, TRAPS) {
1071 assert(EnableInvokeDynamic, "");
1073 // This guy is reached from InterpreterRuntime::resolve_invokedynamic.
1075 // At this point, we only need the signature, and can ignore the name.
1076 symbolHandle method_signature(THREAD, pool->signature_ref_at(raw_index)); // raw_index works directly
1077 symbolHandle method_name = vmSymbolHandles::invokeExact_name();
1078 KlassHandle resolved_klass = SystemDictionaryHandles::MethodHandle_klass();
1080 // JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...)
1081 // The extra MH receiver will be inserted into the stack on every call.
1082 methodHandle resolved_method;
1083 KlassHandle current_klass(THREAD, pool->pool_holder());
1084 lookup_implicit_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, CHECK);
1085 if (resolved_method.is_null()) {
1086 THROW(vmSymbols::java_lang_InternalError());
1087 }
1088 result.set_dynamic(resolved_method, CHECK);
1089 }
1091 //------------------------------------------------------------------------------------------------------------------------
1092 #ifndef PRODUCT
1094 void FieldAccessInfo::print() {
1095 ResourceMark rm;
1096 tty->print_cr("Field %s@%d", name()->as_C_string(), field_offset());
1097 }
1099 #endif