comparison src/share/vm/interpreter/linkResolver.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 93c71eb28866
children d17383603741
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
1 /* 1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
73 //------------------------------------------------------------------------------------------------------------------------ 73 //------------------------------------------------------------------------------------------------------------------------
74 // Implementation of CallInfo 74 // Implementation of CallInfo
75 75
76 76
77 void CallInfo::set_static(KlassHandle resolved_klass, methodHandle resolved_method, TRAPS) { 77 void CallInfo::set_static(KlassHandle resolved_klass, methodHandle resolved_method, TRAPS) {
78 int vtable_index = methodOopDesc::nonvirtual_vtable_index; 78 int vtable_index = Method::nonvirtual_vtable_index;
79 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, vtable_index, CHECK); 79 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, vtable_index, CHECK);
80 } 80 }
81 81
82 82
83 void CallInfo::set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, TRAPS) { 83 void CallInfo::set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, TRAPS) {
84 // This is only called for interface methods. If the resolved_method 84 // This is only called for interface methods. If the resolved_method
85 // comes from java/lang/Object, it can be the subject of a virtual call, so 85 // comes from java/lang/Object, it can be the subject of a virtual call, so
86 // we should pick the vtable index from the resolved method. 86 // we should pick the vtable index from the resolved method.
87 // Other than that case, there is no valid vtable index to specify. 87 // Other than that case, there is no valid vtable index to specify.
88 int vtable_index = methodOopDesc::invalid_vtable_index; 88 int vtable_index = Method::invalid_vtable_index;
89 if (resolved_method->method_holder() == SystemDictionary::Object_klass()) { 89 if (resolved_method->method_holder() == SystemDictionary::Object_klass()) {
90 assert(resolved_method->vtable_index() == selected_method->vtable_index(), "sanity check"); 90 assert(resolved_method->vtable_index() == selected_method->vtable_index(), "sanity check");
91 vtable_index = resolved_method->vtable_index(); 91 vtable_index = resolved_method->vtable_index();
92 } 92 }
93 set_common(resolved_klass, selected_klass, resolved_method, selected_method, vtable_index, CHECK); 93 set_common(resolved_klass, selected_klass, resolved_method, selected_method, vtable_index, CHECK);
94 } 94 }
95 95
96 void CallInfo::set_virtual(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS) { 96 void CallInfo::set_virtual(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS) {
97 assert(vtable_index >= 0 || vtable_index == methodOopDesc::nonvirtual_vtable_index, "valid index"); 97 assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, "valid index");
98 set_common(resolved_klass, selected_klass, resolved_method, selected_method, vtable_index, CHECK); 98 set_common(resolved_klass, selected_klass, resolved_method, selected_method, vtable_index, CHECK);
99 assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call"); 99 assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call");
100 } 100 }
101 101
102 void CallInfo::set_handle(methodHandle resolved_method, Handle resolved_appendix, TRAPS) { 102 void CallInfo::set_handle(methodHandle resolved_method, Handle resolved_appendix, TRAPS) {
103 if (resolved_method.is_null()) { 103 if (resolved_method.is_null()) {
104 THROW_MSG(vmSymbols::java_lang_InternalError(), "resolved method is null"); 104 THROW_MSG(vmSymbols::java_lang_InternalError(), "resolved method is null");
105 } 105 }
106 KlassHandle resolved_klass = SystemDictionaryHandles::MethodHandle_klass(); 106 KlassHandle resolved_klass = SystemDictionary::MethodHandle_klass();
107 assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic || 107 assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic ||
108 resolved_method->is_compiled_lambda_form(), 108 resolved_method->is_compiled_lambda_form(),
109 "linkMethod must return one of these"); 109 "linkMethod must return one of these");
110 int vtable_index = methodOopDesc::nonvirtual_vtable_index; 110 int vtable_index = Method::nonvirtual_vtable_index;
111 assert(resolved_method->vtable_index() == vtable_index, ""); 111 assert(resolved_method->vtable_index() == vtable_index, "");
112 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, vtable_index, CHECK); 112 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, vtable_index, CHECK);
113 _resolved_appendix = resolved_appendix; 113 _resolved_appendix = resolved_appendix;
114 } 114 }
115 115
129 // assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile"); 129 // assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile");
130 if (THREAD->is_Compiler_thread()) { 130 if (THREAD->is_Compiler_thread()) {
131 // don't force compilation, resolve was on behalf of compiler 131 // don't force compilation, resolve was on behalf of compiler
132 return; 132 return;
133 } 133 }
134 if (instanceKlass::cast(selected_method->method_holder())->is_not_initialized()) { 134 if (InstanceKlass::cast(selected_method->method_holder())->is_not_initialized()) {
135 // 'is_not_initialized' means not only '!is_initialized', but also that 135 // 'is_not_initialized' means not only '!is_initialized', but also that
136 // initialization has not been started yet ('!being_initialized') 136 // initialization has not been started yet ('!being_initialized')
137 // Do not force compilation of methods in uninitialized classes. 137 // Do not force compilation of methods in uninitialized classes.
138 // Note that doing this would throw an assert later, 138 // Note that doing this would throw an assert later,
139 // in CompileBroker::compile_method. 139 // in CompileBroker::compile_method.
150 150
151 //------------------------------------------------------------------------------------------------------------------------ 151 //------------------------------------------------------------------------------------------------------------------------
152 // Klass resolution 152 // Klass resolution
153 153
154 void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS) { 154 void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS) {
155 if (!Reflection::verify_class_access(ref_klass->as_klassOop(), 155 if (!Reflection::verify_class_access(ref_klass(),
156 sel_klass->as_klassOop(), 156 sel_klass(),
157 true)) { 157 true)) {
158 ResourceMark rm(THREAD); 158 ResourceMark rm(THREAD);
159 Exceptions::fthrow( 159 Exceptions::fthrow(
160 THREAD_AND_LOCATION, 160 THREAD_AND_LOCATION,
161 vmSymbols::java_lang_IllegalAccessError(), 161 vmSymbols::java_lang_IllegalAccessError(),
166 return; 166 return;
167 } 167 }
168 } 168 }
169 169
170 void LinkResolver::resolve_klass(KlassHandle& result, constantPoolHandle pool, int index, TRAPS) { 170 void LinkResolver::resolve_klass(KlassHandle& result, constantPoolHandle pool, int index, TRAPS) {
171 klassOop result_oop = pool->klass_ref_at(index, CHECK); 171 Klass* result_oop = pool->klass_ref_at(index, CHECK);
172 result = KlassHandle(THREAD, result_oop); 172 result = KlassHandle(THREAD, result_oop);
173 } 173 }
174 174
175 void LinkResolver::resolve_klass_no_update(KlassHandle& result, constantPoolHandle pool, int index, TRAPS) { 175 void LinkResolver::resolve_klass_no_update(KlassHandle& result, constantPoolHandle pool, int index, TRAPS) {
176 klassOop result_oop = 176 Klass* result_oop =
177 constantPoolOopDesc::klass_ref_at_if_loaded_check(pool, index, CHECK); 177 ConstantPool::klass_ref_at_if_loaded_check(pool, index, CHECK);
178 result = KlassHandle(THREAD, result_oop); 178 result = KlassHandle(THREAD, result_oop);
179 } 179 }
180 180
181 181
182 //------------------------------------------------------------------------------------------------------------------------ 182 //------------------------------------------------------------------------------------------------------------------------
183 // Method resolution 183 // Method resolution
184 // 184 //
185 // According to JVM spec. $5.4.3c & $5.4.3d 185 // According to JVM spec. $5.4.3c & $5.4.3d
186 186
187 void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { 187 void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
188 methodOop result_oop = klass->uncached_lookup_method(name, signature); 188 Method* result_oop = klass->uncached_lookup_method(name, signature);
189 if (EnableInvokeDynamic && result_oop != NULL) { 189 if (EnableInvokeDynamic && result_oop != NULL) {
190 vmIntrinsics::ID iid = result_oop->intrinsic_id(); 190 vmIntrinsics::ID iid = result_oop->intrinsic_id();
191 if (MethodHandles::is_signature_polymorphic(iid)) { 191 if (MethodHandles::is_signature_polymorphic(iid)) {
192 // Do not link directly to these. The VM must produce a synthetic one using lookup_polymorphic_method. 192 // Do not link directly to these. The VM must produce a synthetic one using lookup_polymorphic_method.
193 return; 193 return;
196 result = methodHandle(THREAD, result_oop); 196 result = methodHandle(THREAD, result_oop);
197 } 197 }
198 198
199 // returns first instance method 199 // returns first instance method
200 void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { 200 void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
201 methodOop result_oop = klass->uncached_lookup_method(name, signature); 201 Method* result_oop = klass->uncached_lookup_method(name, signature);
202 result = methodHandle(THREAD, result_oop); 202 result = methodHandle(THREAD, result_oop);
203 while (!result.is_null() && result->is_static()) { 203 while (!result.is_null() && result->is_static()) {
204 klass = KlassHandle(THREAD, Klass::cast(result->method_holder())->super()); 204 klass = KlassHandle(THREAD, Klass::cast(result->method_holder())->super());
205 result = methodHandle(THREAD, klass->uncached_lookup_method(name, signature)); 205 result = methodHandle(THREAD, klass->uncached_lookup_method(name, signature));
206 } 206 }
207 } 207 }
208 208
209 209
210 int LinkResolver::vtable_index_of_miranda_method(KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { 210 int LinkResolver::vtable_index_of_miranda_method(KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
211 ResourceMark rm(THREAD); 211 ResourceMark rm(THREAD);
212 klassVtable *vt = instanceKlass::cast(klass())->vtable(); 212 klassVtable *vt = InstanceKlass::cast(klass())->vtable();
213 return vt->index_of_miranda(name, signature); 213 return vt->index_of_miranda(name, signature);
214 } 214 }
215 215
216 void LinkResolver::lookup_method_in_interfaces(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { 216 void LinkResolver::lookup_method_in_interfaces(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
217 instanceKlass *ik = instanceKlass::cast(klass()); 217 InstanceKlass *ik = InstanceKlass::cast(klass());
218 result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name, signature)); 218 result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name, signature));
219 } 219 }
220 220
221 void LinkResolver::lookup_polymorphic_method(methodHandle& result, 221 void LinkResolver::lookup_polymorphic_method(methodHandle& result,
222 KlassHandle klass, Symbol* name, Symbol* full_signature, 222 KlassHandle klass, Symbol* name, Symbol* full_signature,
262 && appendix_result_or_null != NULL) { 262 && appendix_result_or_null != NULL) {
263 // This is a method with type-checking semantics. 263 // This is a method with type-checking semantics.
264 // We will ask Java code to spin an adapter method for it. 264 // We will ask Java code to spin an adapter method for it.
265 if (!MethodHandles::enabled()) { 265 if (!MethodHandles::enabled()) {
266 // Make sure the Java part of the runtime has been booted up. 266 // Make sure the Java part of the runtime has been booted up.
267 klassOop natives = SystemDictionary::MethodHandleNatives_klass(); 267 Klass* natives = SystemDictionary::MethodHandleNatives_klass();
268 if (natives == NULL || instanceKlass::cast(natives)->is_not_initialized()) { 268 if (natives == NULL || InstanceKlass::cast(natives)->is_not_initialized()) {
269 SystemDictionary::resolve_or_fail(vmSymbols::java_lang_invoke_MethodHandleNatives(), 269 SystemDictionary::resolve_or_fail(vmSymbols::java_lang_invoke_MethodHandleNatives(),
270 Handle(), 270 Handle(),
271 Handle(), 271 Handle(),
272 true, 272 true,
273 CHECK); 273 CHECK);
338 new_flags = new_flags | JVM_ACC_PUBLIC; 338 new_flags = new_flags | JVM_ACC_PUBLIC;
339 flags.set_flags(new_flags); 339 flags.set_flags(new_flags);
340 } 340 }
341 // assert(extra_arg_result_or_null != NULL, "must be able to return extra argument"); 341 // assert(extra_arg_result_or_null != NULL, "must be able to return extra argument");
342 342
343 if (!Reflection::verify_field_access(ref_klass->as_klassOop(), 343 if (!Reflection::verify_field_access(ref_klass(),
344 resolved_klass->as_klassOop(), 344 resolved_klass(),
345 sel_klass->as_klassOop(), 345 sel_klass(),
346 flags, 346 flags,
347 true)) { 347 true)) {
348 ResourceMark rm(THREAD); 348 ResourceMark rm(THREAD);
349 Exceptions::fthrow( 349 Exceptions::fthrow(
350 THREAD_AND_LOCATION, 350 THREAD_AND_LOCATION,
362 void LinkResolver::resolve_method_statically(methodHandle& resolved_method, KlassHandle& resolved_klass, 362 void LinkResolver::resolve_method_statically(methodHandle& resolved_method, KlassHandle& resolved_klass,
363 Bytecodes::Code code, constantPoolHandle pool, int index, TRAPS) { 363 Bytecodes::Code code, constantPoolHandle pool, int index, TRAPS) {
364 364
365 // resolve klass 365 // resolve klass
366 if (code == Bytecodes::_invokedynamic) { 366 if (code == Bytecodes::_invokedynamic) {
367 resolved_klass = SystemDictionaryHandles::MethodHandle_klass(); 367 resolved_klass = SystemDictionary::MethodHandle_klass();
368 Symbol* method_name = vmSymbols::invoke_name(); 368 Symbol* method_name = vmSymbols::invoke_name();
369 Symbol* method_signature = pool->signature_ref_at(index); 369 Symbol* method_signature = pool->signature_ref_at(index);
370 KlassHandle current_klass(THREAD, pool->pool_holder()); 370 KlassHandle current_klass(THREAD, pool->pool_holder());
371 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK); 371 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
372 return; 372 return;
379 KlassHandle current_klass(THREAD, pool->pool_holder()); 379 KlassHandle current_klass(THREAD, pool->pool_holder());
380 380
381 if (pool->has_preresolution() 381 if (pool->has_preresolution()
382 || (resolved_klass() == SystemDictionary::MethodHandle_klass() && 382 || (resolved_klass() == SystemDictionary::MethodHandle_klass() &&
383 MethodHandles::is_signature_polymorphic_name(resolved_klass(), method_name))) { 383 MethodHandles::is_signature_polymorphic_name(resolved_klass(), method_name))) {
384 methodOop result_oop = constantPoolOopDesc::method_at_if_loaded(pool, index); 384 Method* result_oop = ConstantPool::method_at_if_loaded(pool, index);
385 if (result_oop != NULL) { 385 if (result_oop != NULL) {
386 resolved_method = methodHandle(THREAD, result_oop); 386 resolved_method = methodHandle(THREAD, result_oop);
387 return; 387 return;
388 } 388 }
389 } 389 }
428 428
429 if (resolved_method.is_null()) { 429 if (resolved_method.is_null()) {
430 // 4. method lookup failed 430 // 4. method lookup failed
431 ResourceMark rm(THREAD); 431 ResourceMark rm(THREAD);
432 THROW_MSG_CAUSE(vmSymbols::java_lang_NoSuchMethodError(), 432 THROW_MSG_CAUSE(vmSymbols::java_lang_NoSuchMethodError(),
433 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), 433 Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
434 method_name, 434 method_name,
435 method_signature), 435 method_signature),
436 nested_exception); 436 nested_exception);
437 } 437 }
438 } 438 }
439 439
440 // 5. check if method is concrete 440 // 5. check if method is concrete
441 if (resolved_method->is_abstract() && !resolved_klass->is_abstract()) { 441 if (resolved_method->is_abstract() && !resolved_klass->is_abstract()) {
442 ResourceMark rm(THREAD); 442 ResourceMark rm(THREAD);
443 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 443 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
444 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), 444 Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
445 method_name, 445 method_name,
446 method_signature)); 446 method_signature));
447 } 447 }
448 448
449 // 6. access checks, access checking may be turned off when calling from within the VM. 449 // 6. access checks, access checking may be turned off when calling from within the VM.
456 KlassHandle(THREAD, resolved_method->method_holder()), 456 KlassHandle(THREAD, resolved_method->method_holder()),
457 resolved_method, 457 resolved_method,
458 CHECK); 458 CHECK);
459 459
460 // check loader constraints 460 // check loader constraints
461 Handle loader (THREAD, instanceKlass::cast(current_klass())->class_loader()); 461 Handle loader (THREAD, InstanceKlass::cast(current_klass())->class_loader());
462 Handle class_loader (THREAD, instanceKlass::cast(resolved_method->method_holder())->class_loader()); 462 Handle class_loader (THREAD, InstanceKlass::cast(resolved_method->method_holder())->class_loader());
463 { 463 {
464 ResourceMark rm(THREAD); 464 ResourceMark rm(THREAD);
465 char* failed_type_name = 465 char* failed_type_name =
466 SystemDictionary::check_signature_loaders(method_signature, loader, 466 SystemDictionary::check_signature_loaders(method_signature, loader,
467 class_loader, true, CHECK); 467 class_loader, true, CHECK);
468 if (failed_type_name != NULL) { 468 if (failed_type_name != NULL) {
469 const char* msg = "loader constraint violation: when resolving method" 469 const char* msg = "loader constraint violation: when resolving method"
470 " \"%s\" the class loader (instance of %s) of the current class, %s," 470 " \"%s\" the class loader (instance of %s) of the current class, %s,"
471 " and the class loader (instance of %s) for resolved class, %s, have" 471 " and the class loader (instance of %s) for resolved class, %s, have"
472 " different Class objects for the type %s used in the signature"; 472 " different Class objects for the type %s used in the signature";
473 char* sig = methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name,method_signature); 473 char* sig = Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name,method_signature);
474 const char* loader1 = SystemDictionary::loader_name(loader()); 474 const char* loader1 = SystemDictionary::loader_name(loader());
475 char* current = instanceKlass::cast(current_klass())->name()->as_C_string(); 475 char* current = InstanceKlass::cast(current_klass())->name()->as_C_string();
476 const char* loader2 = SystemDictionary::loader_name(class_loader()); 476 const char* loader2 = SystemDictionary::loader_name(class_loader());
477 char* resolved = instanceKlass::cast(resolved_klass())->name()->as_C_string(); 477 char* resolved = InstanceKlass::cast(resolved_klass())->name()->as_C_string();
478 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + 478 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
479 strlen(current) + strlen(loader2) + strlen(resolved) + 479 strlen(current) + strlen(loader2) + strlen(resolved) +
480 strlen(failed_type_name); 480 strlen(failed_type_name);
481 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); 481 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
482 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, 482 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2,
510 lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK); 510 lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK);
511 if (resolved_method.is_null()) { 511 if (resolved_method.is_null()) {
512 // no method found 512 // no method found
513 ResourceMark rm(THREAD); 513 ResourceMark rm(THREAD);
514 THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(), 514 THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(),
515 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), 515 Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
516 method_name, 516 method_name,
517 method_signature)); 517 method_signature));
518 } 518 }
519 } 519 }
520 520
521 if (check_access) { 521 if (check_access) {
522 HandleMark hm(THREAD); 522 HandleMark hm(THREAD);
523 Handle loader (THREAD, instanceKlass::cast(current_klass())->class_loader()); 523 Handle loader (THREAD, InstanceKlass::cast(current_klass())->class_loader());
524 Handle class_loader (THREAD, instanceKlass::cast(resolved_method->method_holder())->class_loader()); 524 Handle class_loader (THREAD, InstanceKlass::cast(resolved_method->method_holder())->class_loader());
525 { 525 {
526 ResourceMark rm(THREAD); 526 ResourceMark rm(THREAD);
527 char* failed_type_name = 527 char* failed_type_name =
528 SystemDictionary::check_signature_loaders(method_signature, loader, 528 SystemDictionary::check_signature_loaders(method_signature, loader,
529 class_loader, true, CHECK); 529 class_loader, true, CHECK);
531 const char* msg = "loader constraint violation: when resolving " 531 const char* msg = "loader constraint violation: when resolving "
532 "interface method \"%s\" the class loader (instance of %s) of the " 532 "interface method \"%s\" the class loader (instance of %s) of the "
533 "current class, %s, and the class loader (instance of %s) for " 533 "current class, %s, and the class loader (instance of %s) for "
534 "resolved class, %s, have different Class objects for the type %s " 534 "resolved class, %s, have different Class objects for the type %s "
535 "used in the signature"; 535 "used in the signature";
536 char* sig = methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name,method_signature); 536 char* sig = Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name,method_signature);
537 const char* loader1 = SystemDictionary::loader_name(loader()); 537 const char* loader1 = SystemDictionary::loader_name(loader());
538 char* current = instanceKlass::cast(current_klass())->name()->as_C_string(); 538 char* current = InstanceKlass::cast(current_klass())->name()->as_C_string();
539 const char* loader2 = SystemDictionary::loader_name(class_loader()); 539 const char* loader2 = SystemDictionary::loader_name(class_loader());
540 char* resolved = instanceKlass::cast(resolved_klass())->name()->as_C_string(); 540 char* resolved = InstanceKlass::cast(resolved_klass())->name()->as_C_string();
541 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + 541 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
542 strlen(current) + strlen(loader2) + strlen(resolved) + 542 strlen(current) + strlen(loader2) + strlen(resolved) +
543 strlen(failed_type_name); 543 strlen(failed_type_name);
544 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); 544 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
545 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, 545 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2,
556 void LinkResolver::check_field_accessability(KlassHandle ref_klass, 556 void LinkResolver::check_field_accessability(KlassHandle ref_klass,
557 KlassHandle resolved_klass, 557 KlassHandle resolved_klass,
558 KlassHandle sel_klass, 558 KlassHandle sel_klass,
559 fieldDescriptor& fd, 559 fieldDescriptor& fd,
560 TRAPS) { 560 TRAPS) {
561 if (!Reflection::verify_field_access(ref_klass->as_klassOop(), 561 if (!Reflection::verify_field_access(ref_klass(),
562 resolved_klass->as_klassOop(), 562 resolved_klass(),
563 sel_klass->as_klassOop(), 563 sel_klass(),
564 fd.access_flags(), 564 fd.access_flags(),
565 true)) { 565 true)) {
566 ResourceMark rm(THREAD); 566 ResourceMark rm(THREAD);
567 Exceptions::fthrow( 567 Exceptions::fthrow(
568 THREAD_AND_LOCATION, 568 THREAD_AND_LOCATION,
603 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); 603 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());
604 } 604 }
605 605
606 // Resolve instance field 606 // Resolve instance field
607 fieldDescriptor fd; // find_field initializes fd if found 607 fieldDescriptor fd; // find_field initializes fd if found
608 KlassHandle sel_klass(THREAD, instanceKlass::cast(resolved_klass())->find_field(field, sig, &fd)); 608 KlassHandle sel_klass(THREAD, InstanceKlass::cast(resolved_klass())->find_field(field, sig, &fd));
609 // check if field exists; i.e., if a klass containing the field def has been selected 609 // check if field exists; i.e., if a klass containing the field def has been selected
610 if (sel_klass.is_null()){ 610 if (sel_klass.is_null()){
611 ResourceMark rm(THREAD); 611 ResourceMark rm(THREAD);
612 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); 612 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());
613 } 613 }
639 sel_klass->initialize(CHECK); 639 sel_klass->initialize(CHECK);
640 } 640 }
641 641
642 { 642 {
643 HandleMark hm(THREAD); 643 HandleMark hm(THREAD);
644 Handle ref_loader (THREAD, instanceKlass::cast(ref_klass())->class_loader()); 644 Handle ref_loader (THREAD, InstanceKlass::cast(ref_klass())->class_loader());
645 Handle sel_loader (THREAD, instanceKlass::cast(sel_klass())->class_loader()); 645 Handle sel_loader (THREAD, InstanceKlass::cast(sel_klass())->class_loader());
646 Symbol* signature_ref = pool->signature_ref_at(index); 646 Symbol* signature_ref = pool->signature_ref_at(index);
647 { 647 {
648 ResourceMark rm(THREAD); 648 ResourceMark rm(THREAD);
649 char* failed_type_name = 649 char* failed_type_name =
650 SystemDictionary::check_signature_loaders(signature_ref, 650 SystemDictionary::check_signature_loaders(signature_ref,
656 " \"%s\" the class loader (instance of %s) of the referring class, " 656 " \"%s\" the class loader (instance of %s) of the referring class, "
657 "%s, and the class loader (instance of %s) for the field's resolved " 657 "%s, and the class loader (instance of %s) for the field's resolved "
658 "type, %s, have different Class objects for that type"; 658 "type, %s, have different Class objects for that type";
659 char* field_name = field->as_C_string(); 659 char* field_name = field->as_C_string();
660 const char* loader1 = SystemDictionary::loader_name(ref_loader()); 660 const char* loader1 = SystemDictionary::loader_name(ref_loader());
661 char* sel = instanceKlass::cast(sel_klass())->name()->as_C_string(); 661 char* sel = InstanceKlass::cast(sel_klass())->name()->as_C_string();
662 const char* loader2 = SystemDictionary::loader_name(sel_loader()); 662 const char* loader2 = SystemDictionary::loader_name(sel_loader());
663 size_t buflen = strlen(msg) + strlen(field_name) + strlen(loader1) + 663 size_t buflen = strlen(msg) + strlen(field_name) + strlen(loader1) +
664 strlen(sel) + strlen(loader2) + strlen(failed_type_name); 664 strlen(sel) + strlen(loader2) + strlen(failed_type_name);
665 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); 665 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
666 jio_snprintf(buf, buflen, msg, field_name, loader1, sel, loader2, 666 jio_snprintf(buf, buflen, msg, field_name, loader1, sel, loader2,
716 716
717 // check if static 717 // check if static
718 if (!resolved_method->is_static()) { 718 if (!resolved_method->is_static()) {
719 ResourceMark rm(THREAD); 719 ResourceMark rm(THREAD);
720 char buf[200]; 720 char buf[200];
721 jio_snprintf(buf, sizeof(buf), "Expected static method %s", methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), 721 jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
722 resolved_method->name(), 722 resolved_method->name(),
723 resolved_method->signature())); 723 resolved_method->signature()));
724 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 724 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
725 } 725 }
726 } 726 }
759 if (resolved_method->is_static()) { 759 if (resolved_method->is_static()) {
760 ResourceMark rm(THREAD); 760 ResourceMark rm(THREAD);
761 char buf[200]; 761 char buf[200];
762 jio_snprintf(buf, sizeof(buf), 762 jio_snprintf(buf, sizeof(buf),
763 "Expecting non-static method %s", 763 "Expecting non-static method %s",
764 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), 764 Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
765 resolved_method->name(), 765 resolved_method->name(),
766 resolved_method->signature())); 766 resolved_method->signature()));
767 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 767 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
768 } 768 }
769 } 769 }
793 resolved_method->signature(), CHECK); 793 resolved_method->signature(), CHECK);
794 // check if found 794 // check if found
795 if (sel_method.is_null()) { 795 if (sel_method.is_null()) {
796 ResourceMark rm(THREAD); 796 ResourceMark rm(THREAD);
797 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 797 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
798 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), 798 Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
799 resolved_method->name(), 799 resolved_method->name(),
800 resolved_method->signature())); 800 resolved_method->signature()));
801 } 801 }
802 } 802 }
803 } 803 }
804 804
805 // check if not static 805 // check if not static
806 if (sel_method->is_static()) { 806 if (sel_method->is_static()) {
807 ResourceMark rm(THREAD); 807 ResourceMark rm(THREAD);
808 char buf[200]; 808 char buf[200];
809 jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), 809 jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
810 resolved_method->name(), 810 resolved_method->name(),
811 resolved_method->signature())); 811 resolved_method->signature()));
812 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 812 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
813 } 813 }
814 814
815 // check if abstract 815 // check if abstract
816 if (sel_method->is_abstract()) { 816 if (sel_method->is_abstract()) {
817 ResourceMark rm(THREAD); 817 ResourceMark rm(THREAD);
818 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 818 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
819 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), 819 Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
820 sel_method->name(), 820 sel_method->name(),
821 sel_method->signature())); 821 sel_method->signature()));
822 } 822 }
823 823
824 // setup result 824 // setup result
845 845
846 // check if not static 846 // check if not static
847 if (resolved_method->is_static()) { 847 if (resolved_method->is_static()) {
848 ResourceMark rm(THREAD); 848 ResourceMark rm(THREAD);
849 char buf[200]; 849 char buf[200];
850 jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), 850 jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
851 resolved_method->name(), 851 resolved_method->name(),
852 resolved_method->signature())); 852 resolved_method->signature()));
853 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 853 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
854 } 854 }
855 } 855 }
862 KlassHandle recv_klass, 862 KlassHandle recv_klass,
863 bool check_null_and_abstract, 863 bool check_null_and_abstract,
864 TRAPS) { 864 TRAPS) {
865 865
866 // setup default return values 866 // setup default return values
867 int vtable_index = methodOopDesc::invalid_vtable_index; 867 int vtable_index = Method::invalid_vtable_index;
868 methodHandle selected_method; 868 methodHandle selected_method;
869 869
870 assert(recv.is_null() || recv->is_oop(), "receiver is not an oop"); 870 assert(recv.is_null() || recv->is_oop(), "receiver is not an oop");
871 871
872 // runtime method resolution 872 // runtime method resolution
873 if (check_null_and_abstract && recv.is_null()) { // check if receiver exists 873 if (check_null_and_abstract && recv.is_null()) { // check if receiver exists
874 THROW(vmSymbols::java_lang_NullPointerException()); 874 THROW(vmSymbols::java_lang_NullPointerException());
875 } 875 }
876 876
877 // Virtual methods cannot be resolved before its klass has been linked, for otherwise the methodOop's 877 // Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s
878 // has not been rewritten, and the vtable initialized. 878 // has not been rewritten, and the vtable initialized.
879 assert(instanceKlass::cast(resolved_method->method_holder())->is_linked(), "must be linked"); 879 assert(InstanceKlass::cast(resolved_method->method_holder())->is_linked(), "must be linked");
880 880
881 // Virtual methods cannot be resolved before its klass has been linked, for otherwise the methodOop's 881 // Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s
882 // has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since 882 // has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since
883 // a missing receiver might result in a bogus lookup. 883 // a missing receiver might result in a bogus lookup.
884 assert(instanceKlass::cast(resolved_method->method_holder())->is_linked(), "must be linked"); 884 assert(InstanceKlass::cast(resolved_method->method_holder())->is_linked(), "must be linked");
885 885
886 // do lookup based on receiver klass using the vtable index 886 // do lookup based on receiver klass using the vtable index
887 if (resolved_method->method_holder()->klass_part()->is_interface()) { // miranda method 887 if (resolved_method->method_holder()->is_interface()) { // miranda method
888 vtable_index = vtable_index_of_miranda_method(resolved_klass, 888 vtable_index = vtable_index_of_miranda_method(resolved_klass,
889 resolved_method->name(), 889 resolved_method->name(),
890 resolved_method->signature(), CHECK); 890 resolved_method->signature(), CHECK);
891 assert(vtable_index >= 0 , "we should have valid vtable index at this point"); 891 assert(vtable_index >= 0 , "we should have valid vtable index at this point");
892 892
893 instanceKlass* inst = instanceKlass::cast(recv_klass()); 893 InstanceKlass* inst = InstanceKlass::cast(recv_klass());
894 selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index)); 894 selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index));
895 } else { 895 } else {
896 // at this point we are sure that resolved_method is virtual and not 896 // at this point we are sure that resolved_method is virtual and not
897 // a miranda method; therefore, it must have a valid vtable index. 897 // a miranda method; therefore, it must have a valid vtable index.
898 vtable_index = resolved_method->vtable_index(); 898 vtable_index = resolved_method->vtable_index();
899 // We could get a negative vtable_index for final methods, 899 // We could get a negative vtable_index for final methods,
900 // because as an optimization they are they are never put in the vtable, 900 // because as an optimization they are they are never put in the vtable,
901 // unless they override an existing method. 901 // unless they override an existing method.
902 // If we do get a negative, it means the resolved method is the the selected 902 // If we do get a negative, it means the resolved method is the the selected
903 // method, and it can never be changed by an override. 903 // method, and it can never be changed by an override.
904 if (vtable_index == methodOopDesc::nonvirtual_vtable_index) { 904 if (vtable_index == Method::nonvirtual_vtable_index) {
905 assert(resolved_method->can_be_statically_bound(), "cannot override this method"); 905 assert(resolved_method->can_be_statically_bound(), "cannot override this method");
906 selected_method = resolved_method; 906 selected_method = resolved_method;
907 } else { 907 } else {
908 // recv_klass might be an arrayKlassOop but all vtables start at 908 // recv_klass might be an arrayKlassOop but all vtables start at
909 // the same place. The cast is to avoid virtual call and assertion. 909 // the same place. The cast is to avoid virtual call and assertion.
910 instanceKlass* inst = (instanceKlass*)recv_klass()->klass_part(); 910 InstanceKlass* inst = (InstanceKlass*)recv_klass();
911 selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index)); 911 selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index));
912 } 912 }
913 } 913 }
914 914
915 // check if method exists 915 // check if method exists
916 if (selected_method.is_null()) { 916 if (selected_method.is_null()) {
917 ResourceMark rm(THREAD); 917 ResourceMark rm(THREAD);
918 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 918 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
919 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), 919 Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
920 resolved_method->name(), 920 resolved_method->name(),
921 resolved_method->signature())); 921 resolved_method->signature()));
922 } 922 }
923 923
924 // check if abstract 924 // check if abstract
925 if (check_null_and_abstract && selected_method->is_abstract()) { 925 if (check_null_and_abstract && selected_method->is_abstract()) {
926 ResourceMark rm(THREAD); 926 ResourceMark rm(THREAD);
927 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 927 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
928 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), 928 Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
929 selected_method->name(), 929 selected_method->name(),
930 selected_method->signature())); 930 selected_method->signature()));
931 } 931 }
932 932
933 // setup result 933 // setup result
976 resolved_method->signature(), CHECK); 976 resolved_method->signature(), CHECK);
977 // check if method exists 977 // check if method exists
978 if (sel_method.is_null()) { 978 if (sel_method.is_null()) {
979 ResourceMark rm(THREAD); 979 ResourceMark rm(THREAD);
980 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 980 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
981 methodOopDesc::name_and_sig_as_C_string(Klass::cast(recv_klass()), 981 Method::name_and_sig_as_C_string(Klass::cast(recv_klass()),
982 resolved_method->name(), 982 resolved_method->name(),
983 resolved_method->signature())); 983 resolved_method->signature()));
984 } 984 }
985 // check if public 985 // check if public
986 if (!sel_method->is_public()) { 986 if (!sel_method->is_public()) {
987 ResourceMark rm(THREAD); 987 ResourceMark rm(THREAD);
988 THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), 988 THROW_MSG(vmSymbols::java_lang_IllegalAccessError(),
989 methodOopDesc::name_and_sig_as_C_string(Klass::cast(recv_klass()), 989 Method::name_and_sig_as_C_string(Klass::cast(recv_klass()),
990 sel_method->name(), 990 sel_method->name(),
991 sel_method->signature())); 991 sel_method->signature()));
992 } 992 }
993 // check if abstract 993 // check if abstract
994 if (check_null_and_abstract && sel_method->is_abstract()) { 994 if (check_null_and_abstract && sel_method->is_abstract()) {
995 ResourceMark rm(THREAD); 995 ResourceMark rm(THREAD);
996 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 996 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
997 methodOopDesc::name_and_sig_as_C_string(Klass::cast(recv_klass()), 997 Method::name_and_sig_as_C_string(Klass::cast(recv_klass()),
998 sel_method->name(), 998 sel_method->name(),
999 sel_method->signature())); 999 sel_method->signature()));
1000 } 1000 }
1001 // setup result 1001 // setup result
1002 result.set_interface(resolved_klass, recv_klass, resolved_method, sel_method, CHECK); 1002 result.set_interface(resolved_klass, recv_klass, resolved_method, sel_method, CHECK);
1078 EXCEPTION_MARK; 1078 EXCEPTION_MARK;
1079 CallInfo info; 1079 CallInfo info;
1080 resolve_virtual_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD); 1080 resolve_virtual_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD);
1081 if (HAS_PENDING_EXCEPTION) { 1081 if (HAS_PENDING_EXCEPTION) {
1082 CLEAR_PENDING_EXCEPTION; 1082 CLEAR_PENDING_EXCEPTION;
1083 return methodOopDesc::invalid_vtable_index; 1083 return Method::invalid_vtable_index;
1084 } 1084 }
1085 return info.vtable_index(); 1085 return info.vtable_index();
1086 } 1086 }
1087 1087
1088 methodHandle LinkResolver::resolve_static_call_or_null( 1088 methodHandle LinkResolver::resolve_static_call_or_null(
1168 KlassHandle resolved_klass; 1168 KlassHandle resolved_klass;
1169 Symbol* method_name = NULL; 1169 Symbol* method_name = NULL;
1170 Symbol* method_signature = NULL; 1170 Symbol* method_signature = NULL;
1171 KlassHandle current_klass; 1171 KlassHandle current_klass;
1172 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK); 1172 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK);
1173 KlassHandle recvrKlass (THREAD, recv.is_null() ? (klassOop)NULL : recv->klass()); 1173 KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass());
1174 resolve_virtual_call(result, recv, recvrKlass, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK); 1174 resolve_virtual_call(result, recv, recvrKlass, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
1175 } 1175 }
1176 1176
1177 1177
1178 void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, constantPoolHandle pool, int index, TRAPS) { 1178 void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, constantPoolHandle pool, int index, TRAPS) {
1179 KlassHandle resolved_klass; 1179 KlassHandle resolved_klass;
1180 Symbol* method_name = NULL; 1180 Symbol* method_name = NULL;
1181 Symbol* method_signature = NULL; 1181 Symbol* method_signature = NULL;
1182 KlassHandle current_klass; 1182 KlassHandle current_klass;
1183 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK); 1183 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK);
1184 KlassHandle recvrKlass (THREAD, recv.is_null() ? (klassOop)NULL : recv->klass()); 1184 KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass());
1185 resolve_interface_call(result, recv, recvrKlass, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK); 1185 resolve_interface_call(result, recv, recvrKlass, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
1186 } 1186 }
1187 1187
1188 1188
1189 void LinkResolver::resolve_invokehandle(CallInfo& result, constantPoolHandle pool, int index, TRAPS) { 1189 void LinkResolver::resolve_invokehandle(CallInfo& result, constantPoolHandle pool, int index, TRAPS) {
1225 KlassHandle current_klass = KlassHandle(THREAD, pool->pool_holder()); 1225 KlassHandle current_klass = KlassHandle(THREAD, pool->pool_holder());
1226 1226
1227 // Resolve the bootstrap specifier (BSM + optional arguments). 1227 // Resolve the bootstrap specifier (BSM + optional arguments).
1228 Handle bootstrap_specifier; 1228 Handle bootstrap_specifier;
1229 // Check if CallSite has been bound already: 1229 // Check if CallSite has been bound already:
1230 ConstantPoolCacheEntry* cpce = pool->cache()->secondary_entry_at(index); 1230 ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(index);
1231 if (cpce->is_f1_null()) { 1231 if (cpce->is_f1_null()) {
1232 int pool_index = pool->cache()->main_entry_at(index)->constant_pool_index(); 1232 int pool_index = cpce->constant_pool_index();
1233 oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, CHECK); 1233 oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, CHECK);
1234 assert(bsm_info != NULL, ""); 1234 assert(bsm_info != NULL, "");
1235 // FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic. 1235 // FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic.
1236 bootstrap_specifier = Handle(THREAD, bsm_info); 1236 bootstrap_specifier = Handle(THREAD, bsm_info);
1237 } 1237 }
1238 if (!cpce->is_f1_null()) { 1238 if (!cpce->is_f1_null()) {
1239 methodHandle method(THREAD, cpce->f2_as_vfinal_method()); 1239 methodHandle method(THREAD, cpce->f1_as_method());
1240 Handle appendix(THREAD, cpce->has_appendix() ? cpce->f1_appendix() : (oop)NULL); 1240 Handle appendix(THREAD, cpce->appendix_if_resolved(pool));
1241 result.set_handle(method, appendix, CHECK); 1241 result.set_handle(method, appendix, CHECK);
1242 return; 1242 return;
1243 } 1243 }
1244 1244
1245 if (TraceMethodHandles) { 1245 if (TraceMethodHandles) {
1246 tty->print_cr("resolve_invokedynamic #%d %s %s", 1246 tty->print_cr("resolve_invokedynamic #%d %s %s",
1247 constantPoolCacheOopDesc::decode_secondary_index(index), 1247 ConstantPool::decode_invokedynamic_index(index),
1248 method_name->as_C_string(), method_signature->as_C_string()); 1248 method_name->as_C_string(), method_signature->as_C_string());
1249 tty->print(" BSM info: "); bootstrap_specifier->print(); 1249 tty->print(" BSM info: "); bootstrap_specifier->print();
1250 } 1250 }
1251 1251
1252 resolve_dynamic_call(result, bootstrap_specifier, method_name, method_signature, current_klass, CHECK); 1252 resolve_dynamic_call(result, bootstrap_specifier, method_name, method_signature, current_klass, CHECK);
1263 methodHandle resolved_method = 1263 methodHandle resolved_method =
1264 SystemDictionary::find_dynamic_call_site_invoker(current_klass, 1264 SystemDictionary::find_dynamic_call_site_invoker(current_klass,
1265 bootstrap_specifier, 1265 bootstrap_specifier,
1266 method_name, method_signature, 1266 method_name, method_signature,
1267 &resolved_appendix, 1267 &resolved_appendix,
1268 THREAD); 1268 CHECK);
1269 if (HAS_PENDING_EXCEPTION) { 1269 if (HAS_PENDING_EXCEPTION) {
1270 if (TraceMethodHandles) { 1270 if (TraceMethodHandles) {
1271 tty->print_cr("invokedynamic throws BSME for "INTPTR_FORMAT, PENDING_EXCEPTION); 1271 tty->print_cr("invokedynamic throws BSME for "INTPTR_FORMAT, PENDING_EXCEPTION);
1272 PENDING_EXCEPTION->print(); 1272 PENDING_EXCEPTION->print();
1273 } 1273 }
1280 return; 1280 return;
1281 } 1281 }
1282 // See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS. 1282 // See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS.
1283 Handle nested_exception(THREAD, PENDING_EXCEPTION); 1283 Handle nested_exception(THREAD, PENDING_EXCEPTION);
1284 CLEAR_PENDING_EXCEPTION; 1284 CLEAR_PENDING_EXCEPTION;
1285 THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception) 1285 THROW_MSG_CAUSE(vmSymbols::java_lang_BootstrapMethodError(),
1286 "BootstrapMethodError", nested_exception)
1286 } 1287 }
1287 result.set_handle(resolved_method, resolved_appendix, CHECK); 1288 result.set_handle(resolved_method, resolved_appendix, CHECK);
1288 } 1289 }
1289 1290
1290 //------------------------------------------------------------------------------------------------------------------------ 1291 //------------------------------------------------------------------------------------------------------------------------