< prev index next >

src/hotspot/share/oops/klassVtable.cpp

Print this page
rev 50967 : 8206977: Minor improvements of runtime code.


 489         }
 490 
 491         // Do not check loader constraints for overpass methods because overpass
 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             }
 546           }


1224              "Non-public overpass method!");
1225       // Entry does not resolve. Leave it empty for AbstractMethodError or other error.
1226       if (!(target == NULL) && !target->is_public()) {
1227         // Stuff an IllegalAccessError throwing method in there instead.
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);
1282           ls.cr();




 489         }
 490 
 491         // Do not check loader constraints for overpass methods because overpass
 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               ResourceMark rm(THREAD);
 510               stringStream ss;
 511               ss.print("loader constraint violation for class %s: when selecting "
 512                        "overriding method %s the class loader %s of the "
 513                        "selected method's type %s, and the class loader %s for its super "
 514                        "type %s have different Class objects for the type %s used in the signature",
 515                        klass->external_name(),
 516                        target_method()->name_and_sig_as_C_string(),
 517                        java_lang_ClassLoader::describe_external(target_loader()),
 518                        target_klass->external_name(),
 519                        java_lang_ClassLoader::describe_external(super_loader()),
 520                        super_klass->external_name(),
 521                        failed_type_symbol->as_klass_external_name());
 522               THROW_MSG_(vmSymbols::java_lang_LinkageError(), ss.as_string(), false);






 523             }
 524           }
 525         }
 526 
 527         put_method_at(target_method(), i);
 528         overrides = true;
 529         if (!is_default) {
 530           target_method()->set_vtable_index(i);
 531         } else {
 532           if (def_vtable_indices != NULL) {
 533             if (is_preinitialized_vtable()) {
 534               // At runtime initialize_vtable is rerun as part of link_class_impl()
 535               // for a shared class loaded by the non-boot loader.
 536               // The dumptime vtable index should be the same as the runtime index.
 537               assert(def_vtable_indices->at(default_index) == i,
 538                      "dump time vtable index is different from runtime index");
 539             } else {
 540               def_vtable_indices->at_put(default_index, i);
 541             }
 542           }


1220              "Non-public overpass method!");
1221       // Entry does not resolve. Leave it empty for AbstractMethodError or other error.
1222       if (!(target == NULL) && !target->is_public()) {
1223         // Stuff an IllegalAccessError throwing method in there instead.
1224         itableOffsetEntry::method_entry(_klass, method_table_offset)[m->itable_index()].
1225             initialize(Universe::throw_illegal_access_error());
1226       }
1227     } else {
1228       // Entry did resolve, check loader constraints before initializing
1229       // if checkconstraints requested
1230       if (checkconstraints) {
1231         Handle method_holder_loader (THREAD, target->method_holder()->class_loader());
1232         if (!oopDesc::equals(method_holder_loader(), interface_loader())) {
1233           ResourceMark rm(THREAD);
1234           Symbol* failed_type_symbol =
1235             SystemDictionary::check_signature_loaders(m->signature(),
1236                                                       method_holder_loader,
1237                                                       interface_loader,
1238                                                       true, CHECK);
1239           if (failed_type_symbol != NULL) {
1240             ResourceMark rm(THREAD);
1241             stringStream ss;
1242             ss.print("loader constraint violation in interface itable"
1243                      " initialization for class %s: when selecting method %s the"
1244                      " class loader %s for super interface %s, and the class"
1245                      " loader %s of the selected method's type, %s have"
1246                      " different Class objects for the type %s used in the signature",
1247                      _klass->external_name(),
1248                      m->name_and_sig_as_C_string(),
1249                      java_lang_ClassLoader::describe_external(interface_loader()),
1250                      InstanceKlass::cast(interf)->external_name(),
1251                      java_lang_ClassLoader::describe_external(method_holder_loader()),
1252                      target()->method_holder()->external_name(),
1253                      failed_type_symbol->as_klass_external_name());
1254             THROW_MSG(vmSymbols::java_lang_LinkageError(), ss.as_string());






1255           }
1256         }
1257       }
1258 
1259       // ime may have moved during GC so recalculate address
1260       int ime_num = m->itable_index();
1261       assert(ime_num < ime_count, "oob");
1262       itableOffsetEntry::method_entry(_klass, method_table_offset)[ime_num].initialize(target());
1263       if (log_develop_is_enabled(Trace, itables)) {
1264         ResourceMark rm(THREAD);
1265         if (target() != NULL) {
1266           LogTarget(Trace, itables) lt;
1267           LogStream ls(lt);
1268           char* sig = target()->name_and_sig_as_C_string();
1269           ls.print("interface: %s, ime_num: %d, target: %s, method_holder: %s ",
1270                        interf->internal_name(), ime_num, sig,
1271                        target()->method_holder()->internal_name());
1272           ls.print("target_method flags: ");
1273           target()->print_linkage_flags(&ls);
1274           ls.cr();


< prev index next >