comparison src/share/vm/runtime/sharedRuntime.cpp @ 1793:d257356e35f0

6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions Reviewed-by: never
author jrose
date Mon, 13 Sep 2010 23:24:30 -0700
parents 3e8fbc61cee8
children 3dc12ef8735e
comparison
equal deleted inserted replaced
1792:d20603ee9e10 1793:d257356e35f0
1631 } 1631 }
1632 1632
1633 char* SharedRuntime::generate_wrong_method_type_message(JavaThread* thread, 1633 char* SharedRuntime::generate_wrong_method_type_message(JavaThread* thread,
1634 oopDesc* required, 1634 oopDesc* required,
1635 oopDesc* actual) { 1635 oopDesc* actual) {
1636 if (TraceMethodHandles) {
1637 tty->print_cr("WrongMethodType thread="PTR_FORMAT" req="PTR_FORMAT" act="PTR_FORMAT"",
1638 thread, required, actual);
1639 }
1636 assert(EnableMethodHandles, ""); 1640 assert(EnableMethodHandles, "");
1637 oop singleKlass = wrong_method_type_is_for_single_argument(thread, required); 1641 oop singleKlass = wrong_method_type_is_for_single_argument(thread, required);
1642 char* message = NULL;
1638 if (singleKlass != NULL) { 1643 if (singleKlass != NULL) {
1639 const char* objName = "argument or return value"; 1644 const char* objName = "argument or return value";
1640 if (actual != NULL) { 1645 if (actual != NULL) {
1641 // be flexible about the junk passed in: 1646 // be flexible about the junk passed in:
1642 klassOop ak = (actual->is_klass() 1647 klassOop ak = (actual->is_klass()
1645 objName = Klass::cast(ak)->external_name(); 1650 objName = Klass::cast(ak)->external_name();
1646 } 1651 }
1647 Klass* targetKlass = Klass::cast(required->is_klass() 1652 Klass* targetKlass = Klass::cast(required->is_klass()
1648 ? (klassOop)required 1653 ? (klassOop)required
1649 : java_lang_Class::as_klassOop(required)); 1654 : java_lang_Class::as_klassOop(required));
1650 return generate_class_cast_message(objName, targetKlass->external_name()); 1655 message = generate_class_cast_message(objName, targetKlass->external_name());
1651 } else { 1656 } else {
1652 // %%% need to get the MethodType string, without messing around too much 1657 // %%% need to get the MethodType string, without messing around too much
1653 // Get a signature from the invoke instruction 1658 // Get a signature from the invoke instruction
1654 const char* mhName = "method handle"; 1659 const char* mhName = "method handle";
1655 const char* targetType = "the required signature"; 1660 const char* targetType = "the required signature";
1677 else 1682 else
1678 mhName = actual_method->signature()->as_C_string(); 1683 mhName = actual_method->signature()->as_C_string();
1679 if (mhName[0] == '$') 1684 if (mhName[0] == '$')
1680 mhName = actual_method->signature()->as_C_string(); 1685 mhName = actual_method->signature()->as_C_string();
1681 } 1686 }
1682 return generate_class_cast_message(mhName, targetType, 1687 message = generate_class_cast_message(mhName, targetType,
1683 " cannot be called as "); 1688 " cannot be called as ");
1684 } 1689 }
1690 if (TraceMethodHandles) {
1691 tty->print_cr("WrongMethodType => message=%s", message);
1692 }
1693 return message;
1685 } 1694 }
1686 1695
1687 oop SharedRuntime::wrong_method_type_is_for_single_argument(JavaThread* thr, 1696 oop SharedRuntime::wrong_method_type_is_for_single_argument(JavaThread* thr,
1688 oopDesc* required) { 1697 oopDesc* required) {
1689 if (required == NULL) return NULL; 1698 if (required == NULL) return NULL;