< prev index next >

src/hotspot/share/oops/klassVtable.cpp

Print this page




 492         // methods are created by the jvm to throw exceptions.
 493         if (checkconstraints && !target_method()->is_overpass()) {
 494           // Override vtable entry if passes loader constraint check
 495           // if loader constraint checking requested
 496           // No need to visit his super, since he and his super
 497           // have already made any needed loader constraints.
 498           // Since loader constraints are transitive, it is enough
 499           // to link to the first super, and we get all the others.
 500           Handle super_loader(THREAD, super_klass->class_loader());
 501 
 502           if (!oopDesc::equals(target_loader(), super_loader())) {
 503             ResourceMark rm(THREAD);
 504             Symbol* failed_type_symbol =
 505               SystemDictionary::check_signature_loaders(signature, target_loader,
 506                                                         super_loader, true,
 507                                                         CHECK_(false));
 508             if (failed_type_symbol != NULL) {
 509               const char* msg = "loader constraint violation for class %s: when selecting "
 510                 "overriding method %s the class loader %s of the "
 511                 "selected method's type %s, and the class loader %s for its super "
 512                 "type %s have different Class objects for the type %s used in the signature";
 513               const char* curr_class = klass->external_name();
 514               const char* method = target_method()->name_and_sig_as_C_string();
 515               const char* loader1 = java_lang_ClassLoader::describe_external(target_loader());
 516               const char* sel_class = target_klass->external_name();
 517               const char* loader2 = java_lang_ClassLoader::describe_external(super_loader());

 518               const char* super_class = super_klass->external_name();

 519               const char* failed_type_name = failed_type_symbol->as_klass_external_name();
 520               size_t buflen = strlen(msg) + strlen(curr_class) + strlen(method) +
 521                 strlen(loader1) + strlen(sel_class) + strlen(loader2) +
 522                 strlen(super_class) + strlen(failed_type_name);

 523               char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
 524               jio_snprintf(buf, buflen, msg, curr_class, method, loader1, sel_class, loader2,
 525                            super_class, failed_type_name);
 526               THROW_MSG_(vmSymbols::java_lang_LinkageError(), buf, false);
 527             }
 528           }
 529         }
 530 
 531         put_method_at(target_method(), i);
 532         overrides = true;
 533         if (!is_default) {
 534           target_method()->set_vtable_index(i);
 535         } else {
 536           if (def_vtable_indices != NULL) {
 537             if (is_preinitialized_vtable()) {
 538               // At runtime initialize_vtable is rerun as part of link_class_impl()
 539               // for a shared class loaded by the non-boot loader.
 540               // The dumptime vtable index should be the same as the runtime index.
 541               assert(def_vtable_indices->at(default_index) == i,
 542                      "dump time vtable index is different from runtime index");
 543             } else {
 544               def_vtable_indices->at_put(default_index, i);
 545             }


1228         itableOffsetEntry::method_entry(_klass, method_table_offset)[m->itable_index()].
1229             initialize(Universe::throw_illegal_access_error());
1230       }
1231     } else {
1232       // Entry did resolve, check loader constraints before initializing
1233       // if checkconstraints requested
1234       if (checkconstraints) {
1235         Handle method_holder_loader (THREAD, target->method_holder()->class_loader());
1236         if (!oopDesc::equals(method_holder_loader(), interface_loader())) {
1237           ResourceMark rm(THREAD);
1238           Symbol* failed_type_symbol =
1239             SystemDictionary::check_signature_loaders(m->signature(),
1240                                                       method_holder_loader,
1241                                                       interface_loader,
1242                                                       true, CHECK);
1243           if (failed_type_symbol != NULL) {
1244             const char* msg = "loader constraint violation in interface itable"
1245               " initialization for class %s: when selecting method %s the"
1246               " class loader %s for super interface %s, and the class"
1247               " loader %s of the selected method's type, %s have"
1248               " different Class objects for the type %s used in the signature";
1249             const char* current = _klass->external_name();
1250             const char* sig = m->name_and_sig_as_C_string();
1251             const char* loader1 = java_lang_ClassLoader::describe_external(interface_loader());
1252             const char* iface = InstanceKlass::cast(interf)->external_name();
1253             const char* loader2 = java_lang_ClassLoader::describe_external(method_holder_loader());

1254             const char* mclass = target()->method_holder()->external_name();

1255             const char* failed_type_name = failed_type_symbol->as_klass_external_name();
1256             size_t buflen = strlen(msg) + strlen(current) + strlen(sig) +
1257               strlen(loader1) + strlen(iface) + strlen(loader2) + strlen(mclass) +

1258               strlen(failed_type_name);
1259             char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
1260             jio_snprintf(buf, buflen, msg, current, sig, loader1, iface,
1261                          loader2, mclass, failed_type_name);
1262             THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
1263           }
1264         }
1265       }
1266 
1267       // ime may have moved during GC so recalculate address
1268       int ime_num = m->itable_index();
1269       assert(ime_num < ime_count, "oob");
1270       itableOffsetEntry::method_entry(_klass, method_table_offset)[ime_num].initialize(target());
1271       if (log_develop_is_enabled(Trace, itables)) {
1272         ResourceMark rm(THREAD);
1273         if (target() != NULL) {
1274           LogTarget(Trace, itables) lt;
1275           LogStream ls(lt);
1276           char* sig = target()->name_and_sig_as_C_string();
1277           ls.print("interface: %s, ime_num: %d, target: %s, method_holder: %s ",
1278                        interf->internal_name(), ime_num, sig,
1279                        target()->method_holder()->internal_name());
1280           ls.print("target_method flags: ");
1281           target()->print_linkage_flags(&ls);




 492         // methods are created by the jvm to throw exceptions.
 493         if (checkconstraints && !target_method()->is_overpass()) {
 494           // Override vtable entry if passes loader constraint check
 495           // if loader constraint checking requested
 496           // No need to visit his super, since he and his super
 497           // have already made any needed loader constraints.
 498           // Since loader constraints are transitive, it is enough
 499           // to link to the first super, and we get all the others.
 500           Handle super_loader(THREAD, super_klass->class_loader());
 501 
 502           if (!oopDesc::equals(target_loader(), super_loader())) {
 503             ResourceMark rm(THREAD);
 504             Symbol* failed_type_symbol =
 505               SystemDictionary::check_signature_loaders(signature, target_loader,
 506                                                         super_loader, true,
 507                                                         CHECK_(false));
 508             if (failed_type_symbol != NULL) {
 509               const char* msg = "loader constraint violation for class %s: when selecting "
 510                 "overriding method %s the class loader %s of the "
 511                 "selected method's type %s, and the class loader %s for its super "
 512                 "type %s have different Class objects for the type %s used in the signature (%s; %s)";
 513               const char* curr_class = klass->external_name();
 514               const char* method = target_method()->name_and_sig_as_C_string();
 515               const char* loader1 = target_klass->class_loader_data()->loader_name_and_id();
 516               const char* sel_class = target_klass->external_name();
 517               const char* sel_class_description = target_klass->class_in_module_of_loader(false,true);
 518               const char* loader2 = super_klass->class_loader_data()->loader_name_and_id();
 519               const char* super_class = super_klass->external_name();
 520               const char* super_class_description = super_klass->class_in_module_of_loader(false,true);
 521               const char* failed_type_name = failed_type_symbol->as_klass_external_name();
 522               size_t buflen = strlen(msg) + strlen(curr_class) + strlen(method) +
 523                                             strlen(loader1) + strlen(sel_class) + strlen(sel_class_description) +
 524                                             strlen(loader2) + strlen(super_class) + strlen(super_class_description) +
 525                                             strlen(failed_type_name);
 526               char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
 527               jio_snprintf(buf, buflen, msg, curr_class, method, loader1, sel_class, loader2,
 528                            super_class, failed_type_name, sel_class_description, super_class_description);
 529               THROW_MSG_(vmSymbols::java_lang_LinkageError(), buf, false);
 530             }
 531           }
 532         }
 533 
 534         put_method_at(target_method(), i);
 535         overrides = true;
 536         if (!is_default) {
 537           target_method()->set_vtable_index(i);
 538         } else {
 539           if (def_vtable_indices != NULL) {
 540             if (is_preinitialized_vtable()) {
 541               // At runtime initialize_vtable is rerun as part of link_class_impl()
 542               // for a shared class loaded by the non-boot loader.
 543               // The dumptime vtable index should be the same as the runtime index.
 544               assert(def_vtable_indices->at(default_index) == i,
 545                      "dump time vtable index is different from runtime index");
 546             } else {
 547               def_vtable_indices->at_put(default_index, i);
 548             }


1231         itableOffsetEntry::method_entry(_klass, method_table_offset)[m->itable_index()].
1232             initialize(Universe::throw_illegal_access_error());
1233       }
1234     } else {
1235       // Entry did resolve, check loader constraints before initializing
1236       // if checkconstraints requested
1237       if (checkconstraints) {
1238         Handle method_holder_loader (THREAD, target->method_holder()->class_loader());
1239         if (!oopDesc::equals(method_holder_loader(), interface_loader())) {
1240           ResourceMark rm(THREAD);
1241           Symbol* failed_type_symbol =
1242             SystemDictionary::check_signature_loaders(m->signature(),
1243                                                       method_holder_loader,
1244                                                       interface_loader,
1245                                                       true, CHECK);
1246           if (failed_type_symbol != NULL) {
1247             const char* msg = "loader constraint violation in interface itable"
1248               " initialization for class %s: when selecting method %s the"
1249               " class loader %s for super interface %s, and the class"
1250               " loader %s of the selected method's type, %s have"
1251               " different Class objects for the type %s used in the signature (%s; %s)";
1252             const char* current = _klass->external_name();
1253             const char* sig = m->name_and_sig_as_C_string();
1254             const char* loader1 = interf->class_loader_data()->loader_name_and_id();
1255             const char* iface = interf->external_name();
1256             const char* iface_class_description = interf->class_in_module_of_loader(false,true);
1257             const char* loader2 = target()->method_holder()->class_loader_data()->loader_name_and_id();
1258             const char* mclass = target()->method_holder()->external_name();
1259             const char* mclass_class_description = target()->method_holder()->class_in_module_of_loader(false,true);
1260             const char* failed_type_name = failed_type_symbol->as_klass_external_name();
1261             size_t buflen = strlen(msg) + strlen(current) + strlen(sig) +
1262                                           strlen(loader1) + strlen(iface) + strlen(iface_class_description) +
1263                                           strlen(loader2) + strlen(mclass) + strlen(mclass_class_description) +
1264                                           strlen(failed_type_name);
1265             char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
1266             jio_snprintf(buf, buflen, msg, current, sig, loader1, iface,
1267                          loader2, mclass, failed_type_name, iface_class_description, mclass_class_description);
1268             THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
1269           }
1270         }
1271       }
1272 
1273       // ime may have moved during GC so recalculate address
1274       int ime_num = m->itable_index();
1275       assert(ime_num < ime_count, "oob");
1276       itableOffsetEntry::method_entry(_klass, method_table_offset)[ime_num].initialize(target());
1277       if (log_develop_is_enabled(Trace, itables)) {
1278         ResourceMark rm(THREAD);
1279         if (target() != NULL) {
1280           LogTarget(Trace, itables) lt;
1281           LogStream ls(lt);
1282           char* sig = target()->name_and_sig_as_C_string();
1283           ls.print("interface: %s, ime_num: %d, target: %s, method_holder: %s ",
1284                        interf->internal_name(), ime_num, sig,
1285                        target()->method_holder()->internal_name());
1286           ls.print("target_method flags: ");
1287           target()->print_linkage_flags(&ls);


< prev index next >