< prev index next >

src/hotspot/share/oops/klassVtable.cpp

Print this page
rev 49250 : [mq]: JDK-8199781.patch


 479                              target_classname, THREAD))
 480                              != (InstanceKlass*)NULL)))))
 481         {
 482         // Package private methods always need a new entry to root their own
 483         // overriding. They may also override other methods.
 484         if (!target_method()->is_package_private()) {
 485           allocate_new = false;
 486         }
 487 
 488         // Do not check loader constraints for overpass methods because overpass
 489         // methods are created by the jvm to throw exceptions.
 490         if (checkconstraints && !target_method()->is_overpass()) {
 491           // Override vtable entry if passes loader constraint check
 492           // if loader constraint checking requested
 493           // No need to visit his super, since he and his super
 494           // have already made any needed loader constraints.
 495           // Since loader constraints are transitive, it is enough
 496           // to link to the first super, and we get all the others.
 497           Handle super_loader(THREAD, super_klass->class_loader());
 498 
 499           if (target_loader() != super_loader()) {
 500             ResourceMark rm(THREAD);
 501             Symbol* failed_type_symbol =
 502               SystemDictionary::check_signature_loaders(signature, target_loader,
 503                                                         super_loader, true,
 504                                                         CHECK_(false));
 505             if (failed_type_symbol != NULL) {
 506               const char* msg = "loader constraint violation for class %s: when selecting "
 507                 "overriding method \"%s\" the class loader (instance of %s) of the "
 508                 "selected method's type %s, and the class loader (instance of %s) for its super "
 509                 "type %s have different Class objects for the type %s used in the signature";
 510               char* curr_class = klass->name()->as_C_string();
 511               char* sig = target_method()->name_and_sig_as_C_string();
 512               const char* loader1 = SystemDictionary::loader_name(target_loader());
 513               char* sel_class = target_klass->name()->as_C_string();
 514               const char* loader2 = SystemDictionary::loader_name(super_loader());
 515               char* super_class = super_klass->name()->as_C_string();
 516               char* failed_type_name = failed_type_symbol->as_C_string();
 517               size_t buflen = strlen(msg) + strlen(curr_class) + strlen(sig) +
 518                 strlen(loader1) + strlen(sel_class) + strlen(loader2) +
 519                 strlen(super_class) + strlen(failed_type_name);


1208     methodHandle target;
1209     if (m->has_itable_index()) {
1210       // This search must match the runtime resolution, i.e. selection search for invokeinterface
1211       // to correctly enforce loader constraints for interface method inheritance
1212       target = LinkResolver::lookup_instance_method_in_klasses(_klass, m->name(), m->signature(), CHECK);
1213     }
1214     if (target == NULL || !target->is_public() || target->is_abstract() || target->is_overpass()) {
1215       assert(target == NULL || !target->is_overpass() || target->is_public(),
1216              "Non-public overpass method!");
1217       // Entry does not resolve. Leave it empty for AbstractMethodError or other error.
1218       if (!(target == NULL) && !target->is_public()) {
1219         // Stuff an IllegalAccessError throwing method in there instead.
1220         itableOffsetEntry::method_entry(_klass, method_table_offset)[m->itable_index()].
1221             initialize(Universe::throw_illegal_access_error());
1222       }
1223     } else {
1224       // Entry did resolve, check loader constraints before initializing
1225       // if checkconstraints requested
1226       if (checkconstraints) {
1227         Handle method_holder_loader (THREAD, target->method_holder()->class_loader());
1228         if (method_holder_loader() != interface_loader()) {
1229           ResourceMark rm(THREAD);
1230           Symbol* failed_type_symbol =
1231             SystemDictionary::check_signature_loaders(m->signature(),
1232                                                       method_holder_loader,
1233                                                       interface_loader,
1234                                                       true, CHECK);
1235           if (failed_type_symbol != NULL) {
1236             const char* msg = "loader constraint violation in interface itable"
1237               " initialization for class %s: when selecting method \"%s\" the"
1238               " class loader (instance of %s) for super interface %s, and the class"
1239               " loader (instance of %s) of the selected method's type, %s have"
1240               " different Class objects for the type %s used in the signature";
1241             char* current = _klass->name()->as_C_string();
1242             char* sig = m->name_and_sig_as_C_string();
1243             const char* loader1 = SystemDictionary::loader_name(interface_loader());
1244             char* iface = InstanceKlass::cast(interf)->name()->as_C_string();
1245             const char* loader2 = SystemDictionary::loader_name(method_holder_loader());
1246             char* mclass = target()->method_holder()->name()->as_C_string();
1247             char* failed_type_name = failed_type_symbol->as_C_string();
1248             size_t buflen = strlen(msg) + strlen(current) + strlen(sig) +




 479                              target_classname, THREAD))
 480                              != (InstanceKlass*)NULL)))))
 481         {
 482         // Package private methods always need a new entry to root their own
 483         // overriding. They may also override other methods.
 484         if (!target_method()->is_package_private()) {
 485           allocate_new = false;
 486         }
 487 
 488         // Do not check loader constraints for overpass methods because overpass
 489         // methods are created by the jvm to throw exceptions.
 490         if (checkconstraints && !target_method()->is_overpass()) {
 491           // Override vtable entry if passes loader constraint check
 492           // if loader constraint checking requested
 493           // No need to visit his super, since he and his super
 494           // have already made any needed loader constraints.
 495           // Since loader constraints are transitive, it is enough
 496           // to link to the first super, and we get all the others.
 497           Handle super_loader(THREAD, super_klass->class_loader());
 498 
 499           if (!oopDesc::equals(target_loader(), super_loader())) {
 500             ResourceMark rm(THREAD);
 501             Symbol* failed_type_symbol =
 502               SystemDictionary::check_signature_loaders(signature, target_loader,
 503                                                         super_loader, true,
 504                                                         CHECK_(false));
 505             if (failed_type_symbol != NULL) {
 506               const char* msg = "loader constraint violation for class %s: when selecting "
 507                 "overriding method \"%s\" the class loader (instance of %s) of the "
 508                 "selected method's type %s, and the class loader (instance of %s) for its super "
 509                 "type %s have different Class objects for the type %s used in the signature";
 510               char* curr_class = klass->name()->as_C_string();
 511               char* sig = target_method()->name_and_sig_as_C_string();
 512               const char* loader1 = SystemDictionary::loader_name(target_loader());
 513               char* sel_class = target_klass->name()->as_C_string();
 514               const char* loader2 = SystemDictionary::loader_name(super_loader());
 515               char* super_class = super_klass->name()->as_C_string();
 516               char* failed_type_name = failed_type_symbol->as_C_string();
 517               size_t buflen = strlen(msg) + strlen(curr_class) + strlen(sig) +
 518                 strlen(loader1) + strlen(sel_class) + strlen(loader2) +
 519                 strlen(super_class) + strlen(failed_type_name);


1208     methodHandle target;
1209     if (m->has_itable_index()) {
1210       // This search must match the runtime resolution, i.e. selection search for invokeinterface
1211       // to correctly enforce loader constraints for interface method inheritance
1212       target = LinkResolver::lookup_instance_method_in_klasses(_klass, m->name(), m->signature(), CHECK);
1213     }
1214     if (target == NULL || !target->is_public() || target->is_abstract() || target->is_overpass()) {
1215       assert(target == NULL || !target->is_overpass() || target->is_public(),
1216              "Non-public overpass method!");
1217       // Entry does not resolve. Leave it empty for AbstractMethodError or other error.
1218       if (!(target == NULL) && !target->is_public()) {
1219         // Stuff an IllegalAccessError throwing method in there instead.
1220         itableOffsetEntry::method_entry(_klass, method_table_offset)[m->itable_index()].
1221             initialize(Universe::throw_illegal_access_error());
1222       }
1223     } else {
1224       // Entry did resolve, check loader constraints before initializing
1225       // if checkconstraints requested
1226       if (checkconstraints) {
1227         Handle method_holder_loader (THREAD, target->method_holder()->class_loader());
1228         if (!oopDesc::equals(method_holder_loader(), interface_loader())) {
1229           ResourceMark rm(THREAD);
1230           Symbol* failed_type_symbol =
1231             SystemDictionary::check_signature_loaders(m->signature(),
1232                                                       method_holder_loader,
1233                                                       interface_loader,
1234                                                       true, CHECK);
1235           if (failed_type_symbol != NULL) {
1236             const char* msg = "loader constraint violation in interface itable"
1237               " initialization for class %s: when selecting method \"%s\" the"
1238               " class loader (instance of %s) for super interface %s, and the class"
1239               " loader (instance of %s) of the selected method's type, %s have"
1240               " different Class objects for the type %s used in the signature";
1241             char* current = _klass->name()->as_C_string();
1242             char* sig = m->name_and_sig_as_C_string();
1243             const char* loader1 = SystemDictionary::loader_name(interface_loader());
1244             char* iface = InstanceKlass::cast(interf)->name()->as_C_string();
1245             const char* loader2 = SystemDictionary::loader_name(method_holder_loader());
1246             char* mclass = target()->method_holder()->name()->as_C_string();
1247             char* failed_type_name = failed_type_symbol->as_C_string();
1248             size_t buflen = strlen(msg) + strlen(current) + strlen(sig) +


< prev index next >