Mercurial > hg > truffle
comparison src/share/vm/oops/klassVtable.cpp @ 8840:cd3089a56438
8009731: Confusing error message for loader constraint violation
Summary: Fix text, overwritten type and holder for resolved method
Reviewed-by: coleenp, dcubed, minqi, dholmes
author | acorn |
---|---|
date | Wed, 27 Mar 2013 14:10:59 -0400 |
parents | 8d9fc28831cc |
children | 08236d966eea |
comparison
equal
deleted
inserted
replaced
8823:23f2d309e855 | 8840:cd3089a56438 |
---|---|
325 // to link to the first super, and we get all the others. | 325 // to link to the first super, and we get all the others. |
326 Handle super_loader(THREAD, super_klass->class_loader()); | 326 Handle super_loader(THREAD, super_klass->class_loader()); |
327 | 327 |
328 if (target_loader() != super_loader()) { | 328 if (target_loader() != super_loader()) { |
329 ResourceMark rm(THREAD); | 329 ResourceMark rm(THREAD); |
330 char* failed_type_name = | 330 Symbol* failed_type_symbol = |
331 SystemDictionary::check_signature_loaders(signature, target_loader, | 331 SystemDictionary::check_signature_loaders(signature, target_loader, |
332 super_loader, true, | 332 super_loader, true, |
333 CHECK_(false)); | 333 CHECK_(false)); |
334 if (failed_type_name != NULL) { | 334 if (failed_type_symbol != NULL) { |
335 const char* msg = "loader constraint violation: when resolving " | 335 const char* msg = "loader constraint violation: when resolving " |
336 "overridden method \"%s\" the class loader (instance" | 336 "overridden method \"%s\" the class loader (instance" |
337 " of %s) of the current class, %s, and its superclass loader " | 337 " of %s) of the current class, %s, and its superclass loader " |
338 "(instance of %s), have different Class objects for the type " | 338 "(instance of %s), have different Class objects for the type " |
339 "%s used in the signature"; | 339 "%s used in the signature"; |
340 char* sig = target_method()->name_and_sig_as_C_string(); | 340 char* sig = target_method()->name_and_sig_as_C_string(); |
341 const char* loader1 = SystemDictionary::loader_name(target_loader()); | 341 const char* loader1 = SystemDictionary::loader_name(target_loader()); |
342 char* current = _klass->name()->as_C_string(); | 342 char* current = _klass->name()->as_C_string(); |
343 const char* loader2 = SystemDictionary::loader_name(super_loader()); | 343 const char* loader2 = SystemDictionary::loader_name(super_loader()); |
344 char* failed_type_name = failed_type_symbol->as_C_string(); | |
344 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + | 345 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + |
345 strlen(current) + strlen(loader2) + strlen(failed_type_name); | 346 strlen(current) + strlen(loader2) + strlen(failed_type_name); |
346 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); | 347 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); |
347 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, | 348 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, |
348 failed_type_name); | 349 failed_type_name); |
785 methodHandle target_h (THREAD, target); // preserve across gc | 786 methodHandle target_h (THREAD, target); // preserve across gc |
786 if (checkconstraints) { | 787 if (checkconstraints) { |
787 Handle method_holder_loader (THREAD, target->method_holder()->class_loader()); | 788 Handle method_holder_loader (THREAD, target->method_holder()->class_loader()); |
788 if (method_holder_loader() != interface_loader()) { | 789 if (method_holder_loader() != interface_loader()) { |
789 ResourceMark rm(THREAD); | 790 ResourceMark rm(THREAD); |
790 char* failed_type_name = | 791 Symbol* failed_type_symbol = |
791 SystemDictionary::check_signature_loaders(method_signature, | 792 SystemDictionary::check_signature_loaders(method_signature, |
792 method_holder_loader, | 793 method_holder_loader, |
793 interface_loader, | 794 interface_loader, |
794 true, CHECK); | 795 true, CHECK); |
795 if (failed_type_name != NULL) { | 796 if (failed_type_symbol != NULL) { |
796 const char* msg = "loader constraint violation in interface " | 797 const char* msg = "loader constraint violation in interface " |
797 "itable initialization: when resolving method \"%s\" the class" | 798 "itable initialization: when resolving method \"%s\" the class" |
798 " loader (instance of %s) of the current class, %s, " | 799 " loader (instance of %s) of the current class, %s, " |
799 "and the class loader (instance of %s) for interface " | 800 "and the class loader (instance of %s) for interface " |
800 "%s have different Class objects for the type %s " | 801 "%s have different Class objects for the type %s " |
802 char* sig = target_h()->name_and_sig_as_C_string(); | 803 char* sig = target_h()->name_and_sig_as_C_string(); |
803 const char* loader1 = SystemDictionary::loader_name(method_holder_loader()); | 804 const char* loader1 = SystemDictionary::loader_name(method_holder_loader()); |
804 char* current = klass->name()->as_C_string(); | 805 char* current = klass->name()->as_C_string(); |
805 const char* loader2 = SystemDictionary::loader_name(interface_loader()); | 806 const char* loader2 = SystemDictionary::loader_name(interface_loader()); |
806 char* iface = InstanceKlass::cast(interf_h())->name()->as_C_string(); | 807 char* iface = InstanceKlass::cast(interf_h())->name()->as_C_string(); |
808 char* failed_type_name = failed_type_symbol->as_C_string(); | |
807 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + | 809 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + |
808 strlen(current) + strlen(loader2) + strlen(iface) + | 810 strlen(current) + strlen(loader2) + strlen(iface) + |
809 strlen(failed_type_name); | 811 strlen(failed_type_name); |
810 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); | 812 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); |
811 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, | 813 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, |