141 // an itable linkage is <interface, itable index> |
141 // an itable linkage is <interface, itable index> |
142 decode_flags_result |= MethodHandles::_dmf_from_interface; |
142 decode_flags_result |= MethodHandles::_dmf_from_interface; |
143 return klassItable::method_for_itable_index((klassOop)vmtarget, vmindex); |
143 return klassItable::method_for_itable_index((klassOop)vmtarget, vmindex); |
144 } else { |
144 } else { |
145 if (!tk->oop_is_instance()) |
145 if (!tk->oop_is_instance()) |
146 tk = instanceKlass::cast(SystemDictionary::object_klass()); |
146 tk = instanceKlass::cast(SystemDictionary::Object_klass()); |
147 return ((instanceKlass*)tk)->method_at_vtable(vmindex); |
147 return ((instanceKlass*)tk)->method_at_vtable(vmindex); |
148 } |
148 } |
149 } |
149 } |
150 } |
150 } |
151 |
151 |
262 } else if (xk == SystemDictionary::MemberName_klass()) { |
262 } else if (xk == SystemDictionary::MemberName_klass()) { |
263 // Note: This only works if the MemberName has already been resolved. |
263 // Note: This only works if the MemberName has already been resolved. |
264 return decode_MemberName(x, receiver_limit_result, decode_flags_result); |
264 return decode_MemberName(x, receiver_limit_result, decode_flags_result); |
265 } else if (java_dyn_MethodHandle::is_subclass(xk)) { |
265 } else if (java_dyn_MethodHandle::is_subclass(xk)) { |
266 return decode_MethodHandle(x, receiver_limit_result, decode_flags_result); |
266 return decode_MethodHandle(x, receiver_limit_result, decode_flags_result); |
267 } else if (xk == SystemDictionary::reflect_method_klass()) { |
267 } else if (xk == SystemDictionary::reflect_Method_klass()) { |
268 oop clazz = java_lang_reflect_Method::clazz(x); |
268 oop clazz = java_lang_reflect_Method::clazz(x); |
269 int slot = java_lang_reflect_Method::slot(x); |
269 int slot = java_lang_reflect_Method::slot(x); |
270 klassOop k = java_lang_Class::as_klassOop(clazz); |
270 klassOop k = java_lang_Class::as_klassOop(clazz); |
271 if (k != NULL && Klass::cast(k)->oop_is_instance()) |
271 if (k != NULL && Klass::cast(k)->oop_is_instance()) |
272 return decode_methodOop(instanceKlass::cast(k)->method_with_idnum(slot), |
272 return decode_methodOop(instanceKlass::cast(k)->method_with_idnum(slot), |
273 decode_flags_result); |
273 decode_flags_result); |
274 } else if (xk == SystemDictionary::reflect_constructor_klass()) { |
274 } else if (xk == SystemDictionary::reflect_Constructor_klass()) { |
275 oop clazz = java_lang_reflect_Constructor::clazz(x); |
275 oop clazz = java_lang_reflect_Constructor::clazz(x); |
276 int slot = java_lang_reflect_Constructor::slot(x); |
276 int slot = java_lang_reflect_Constructor::slot(x); |
277 klassOop k = java_lang_Class::as_klassOop(clazz); |
277 klassOop k = java_lang_Class::as_klassOop(clazz); |
278 if (k != NULL && Klass::cast(k)->oop_is_instance()) |
278 if (k != NULL && Klass::cast(k)->oop_is_instance()) |
279 return decode_methodOop(instanceKlass::cast(k)->method_with_idnum(slot), |
279 return decode_methodOop(instanceKlass::cast(k)->method_with_idnum(slot), |
326 ALL_KINDS = IS_METHOD | IS_CONSTRUCTOR | IS_FIELD | IS_TYPE, |
326 ALL_KINDS = IS_METHOD | IS_CONSTRUCTOR | IS_FIELD | IS_TYPE, |
327 VM_INDEX_UNINITIALIZED = sun_dyn_MemberName::VM_INDEX_UNINITIALIZED |
327 VM_INDEX_UNINITIALIZED = sun_dyn_MemberName::VM_INDEX_UNINITIALIZED |
328 }; |
328 }; |
329 |
329 |
330 void MethodHandles::init_MemberName(oop mname_oop, oop target_oop) { |
330 void MethodHandles::init_MemberName(oop mname_oop, oop target_oop) { |
331 if (target_oop->klass() == SystemDictionary::reflect_field_klass()) { |
331 if (target_oop->klass() == SystemDictionary::reflect_Field_klass()) { |
332 oop clazz = java_lang_reflect_Field::clazz(target_oop); // fd.field_holder() |
332 oop clazz = java_lang_reflect_Field::clazz(target_oop); // fd.field_holder() |
333 int slot = java_lang_reflect_Field::slot(target_oop); // fd.index() |
333 int slot = java_lang_reflect_Field::slot(target_oop); // fd.index() |
334 int mods = java_lang_reflect_Field::modifiers(target_oop); |
334 int mods = java_lang_reflect_Field::modifiers(target_oop); |
335 klassOop k = java_lang_Class::as_klassOop(clazz); |
335 klassOop k = java_lang_Class::as_klassOop(clazz); |
336 int offset = instanceKlass::cast(k)->offset_from_fields(slot); |
336 int offset = instanceKlass::cast(k)->offset_from_fields(slot); |
411 klassOop defc_klassOop = java_lang_Class::as_klassOop(defc_oop); |
411 klassOop defc_klassOop = java_lang_Class::as_klassOop(defc_oop); |
412 defc_oop = NULL; // safety |
412 defc_oop = NULL; // safety |
413 if (defc_klassOop == NULL) return; // a primitive; no resolution possible |
413 if (defc_klassOop == NULL) return; // a primitive; no resolution possible |
414 if (!Klass::cast(defc_klassOop)->oop_is_instance()) { |
414 if (!Klass::cast(defc_klassOop)->oop_is_instance()) { |
415 if (!Klass::cast(defc_klassOop)->oop_is_array()) return; |
415 if (!Klass::cast(defc_klassOop)->oop_is_array()) return; |
416 defc_klassOop = SystemDictionary::object_klass(); |
416 defc_klassOop = SystemDictionary::Object_klass(); |
417 } |
417 } |
418 instanceKlassHandle defc(THREAD, defc_klassOop); |
418 instanceKlassHandle defc(THREAD, defc_klassOop); |
419 defc_klassOop = NULL; // safety |
419 defc_klassOop = NULL; // safety |
420 if (defc.is_null()) { |
420 if (defc.is_null()) { |
421 THROW_MSG(vmSymbols::java_lang_InternalError(), "primitive class"); |
421 THROW_MSG(vmSymbols::java_lang_InternalError(), "primitive class"); |
747 oop target = java_dyn_MethodHandle::vmtarget(mh()); |
747 oop target = java_dyn_MethodHandle::vmtarget(mh()); |
748 if (target == NULL) { |
748 if (target == NULL) { |
749 return NULL; // unformed MH |
749 return NULL; // unformed MH |
750 } |
750 } |
751 klassOop tklass = target->klass(); |
751 klassOop tklass = target->klass(); |
752 if (Klass::cast(tklass)->is_subclass_of(SystemDictionary::object_klass())) { |
752 if (Klass::cast(tklass)->is_subclass_of(SystemDictionary::Object_klass())) { |
753 return target; // target is another MH (or something else?) |
753 return target; // target is another MH (or something else?) |
754 } |
754 } |
755 } |
755 } |
756 if (format == ETF_DIRECT_HANDLE) { |
756 if (format == ETF_DIRECT_HANDLE) { |
757 oop target = mh(); |
757 oop target = mh(); |
826 } |
826 } |
827 return false; |
827 return false; |
828 } |
828 } |
829 |
829 |
830 bool MethodHandles::class_cast_needed(klassOop src, klassOop dst) { |
830 bool MethodHandles::class_cast_needed(klassOop src, klassOop dst) { |
831 if (src == dst || dst == SystemDictionary::object_klass()) |
831 if (src == dst || dst == SystemDictionary::Object_klass()) |
832 return false; // quickest checks |
832 return false; // quickest checks |
833 Klass* srck = Klass::cast(src); |
833 Klass* srck = Klass::cast(src); |
834 Klass* dstk = Klass::cast(dst); |
834 Klass* dstk = Klass::cast(dst); |
835 if (dstk->is_interface()) { |
835 if (dstk->is_interface()) { |
836 // interface receivers can safely be viewed as untyped, |
836 // interface receivers can safely be viewed as untyped, |
837 // because interface calls always include a dynamic check |
837 // because interface calls always include a dynamic check |
838 //dstk = Klass::cast(SystemDictionary::object_klass()); |
838 //dstk = Klass::cast(SystemDictionary::Object_klass()); |
839 return false; |
839 return false; |
840 } |
840 } |
841 if (srck->is_interface()) { |
841 if (srck->is_interface()) { |
842 // interface arguments must be viewed as untyped |
842 // interface arguments must be viewed as untyped |
843 //srck = Klass::cast(SystemDictionary::object_klass()); |
843 //srck = Klass::cast(SystemDictionary::Object_klass()); |
844 return true; |
844 return true; |
845 } |
845 } |
846 if (is_always_null_type(src)) { |
846 if (is_always_null_type(src)) { |
847 // some source types are known to be never instantiated; |
847 // some source types are known to be never instantiated; |
848 // they represent references which are always null |
848 // they represent references which are always null |
851 } |
851 } |
852 return !srck->is_subclass_of(dstk->as_klassOop()); |
852 return !srck->is_subclass_of(dstk->as_klassOop()); |
853 } |
853 } |
854 |
854 |
855 static oop object_java_mirror() { |
855 static oop object_java_mirror() { |
856 return Klass::cast(SystemDictionary::object_klass())->java_mirror(); |
856 return Klass::cast(SystemDictionary::Object_klass())->java_mirror(); |
857 } |
857 } |
858 |
858 |
859 bool MethodHandles::same_basic_type_for_arguments(BasicType src, |
859 bool MethodHandles::same_basic_type_for_arguments(BasicType src, |
860 BasicType dst, |
860 BasicType dst, |
861 bool raw, |
861 bool raw, |
1447 if (ptype != T_INT && !is_subword_type(ptype)) { |
1447 if (ptype != T_INT && !is_subword_type(ptype)) { |
1448 err = "unexpected parameter type"; |
1448 err = "unexpected parameter type"; |
1449 break; |
1449 break; |
1450 } |
1450 } |
1451 // check subrange of Integer.value, if necessary |
1451 // check subrange of Integer.value, if necessary |
1452 if (argument == NULL || argument->klass() != SystemDictionary::int_klass()) { |
1452 if (argument == NULL || argument->klass() != SystemDictionary::Integer_klass()) { |
1453 err = "bound integer argument must be of type java.lang.Integer"; |
1453 err = "bound integer argument must be of type java.lang.Integer"; |
1454 break; |
1454 break; |
1455 } |
1455 } |
1456 if (ptype != T_INT) { |
1456 if (ptype != T_INT) { |
1457 int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_INT); |
1457 int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_INT); |
1470 { |
1470 { |
1471 // we must implicitly convert from the unboxed arg type to the outgoing ptype |
1471 // we must implicitly convert from the unboxed arg type to the outgoing ptype |
1472 BasicType argbox = java_lang_boxing_object::basic_type(argument); |
1472 BasicType argbox = java_lang_boxing_object::basic_type(argument); |
1473 if (argbox != ptype) { |
1473 if (argbox != ptype) { |
1474 err = check_argument_type_change(T_OBJECT, (argument == NULL |
1474 err = check_argument_type_change(T_OBJECT, (argument == NULL |
1475 ? SystemDictionary::object_klass() |
1475 ? SystemDictionary::Object_klass() |
1476 : argument->klass()), |
1476 : argument->klass()), |
1477 ptype, ptype_klass(), argnum); |
1477 ptype, ptype_klass(), argnum); |
1478 assert(err != NULL, "this must be an error"); |
1478 assert(err != NULL, "this must be an error"); |
1479 } |
1479 } |
1480 break; |
1480 break; |
2173 if (WizardMode || Verbose) { // Warning: this calls Java code on the MH! |
2173 if (WizardMode || Verbose) { // Warning: this calls Java code on the MH! |
2174 // call Object.toString() |
2174 // call Object.toString() |
2175 symbolOop name = vmSymbols::toString_name(), sig = vmSymbols::void_string_signature(); |
2175 symbolOop name = vmSymbols::toString_name(), sig = vmSymbols::void_string_signature(); |
2176 JavaCallArguments args(Handle(THREAD, JNIHandles::resolve_non_null(erased_jh))); |
2176 JavaCallArguments args(Handle(THREAD, JNIHandles::resolve_non_null(erased_jh))); |
2177 JavaValue result(T_OBJECT); |
2177 JavaValue result(T_OBJECT); |
2178 JavaCalls::call_virtual(&result, SystemDictionary::object_klass(), name, sig, |
2178 JavaCalls::call_virtual(&result, SystemDictionary::Object_klass(), name, sig, |
2179 &args, CHECK); |
2179 &args, CHECK); |
2180 Handle str(THREAD, (oop)result.get_jobject()); |
2180 Handle str(THREAD, (oop)result.get_jobject()); |
2181 java_lang_String::print(str, tty); |
2181 java_lang_String::print(str, tty); |
2182 } |
2182 } |
2183 tty->cr(); |
2183 tty->cr(); |