提交 eeede01a 编写于 作者: A amurillo

Merge

......@@ -410,5 +410,7 @@ d3521d8e562a782f66fc0dfdebeffba2c7e3471d jdk8-b122
591135a7d6f96c0ef281d078cee9a8d8c342d45c jdk8-b123
c89630a122b43d0eabd78b74f6498a1c3cf04ca3 jdk8u20-b00
c89630a122b43d0eabd78b74f6498a1c3cf04ca3 hs25.20-b00
9b9816164447214f21b06ccf646893c281c76a42 hs25-b66
df333ee12bba67e2e928f8ce1da37afd9bf95b48 jdk8-b124
412d3b5fe90e54c0ff9d9ac7374b98607c561d5a hs25.20-b01
4638c4d7ff106db0f29ef7f18b128dd7e69bc470 hs25.20-b02
此差异已折叠。
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -390,6 +390,20 @@ class MethodFamily : public ResourceObj {
Symbol* get_exception_message() { return _exception_message; }
Symbol* get_exception_name() { return _exception_name; }
// Return true if the specified klass has a static method that matches
// the name and signature of the target method.
bool has_matching_static(InstanceKlass* root) {
if (_members.length() > 0) {
Pair<Method*,QualifiedState> entry = _members.at(0);
Method* impl = root->find_method(entry.first->name(),
entry.first->signature());
if ((impl != NULL) && impl->is_static()) {
return true;
}
}
return false;
}
// Either sets the target or the exception error message
void determine_target(InstanceKlass* root, TRAPS) {
if (has_target() || throws_exception()) {
......@@ -416,19 +430,26 @@ class MethodFamily : public ResourceObj {
}
if (num_defaults == 0) {
if (qualified_methods.length() == 0) {
_exception_message = generate_no_defaults_message(CHECK);
} else {
assert(root != NULL, "Null root class");
_exception_message = generate_method_message(root->name(), qualified_methods.at(0), CHECK);
// If the root klass has a static method with matching name and signature
// then do not generate an overpass method because it will hide the
// static method during resolution.
if (!has_matching_static(root)) {
if (qualified_methods.length() == 0) {
_exception_message = generate_no_defaults_message(CHECK);
} else {
assert(root != NULL, "Null root class");
_exception_message = generate_method_message(root->name(), qualified_methods.at(0), CHECK);
}
_exception_name = vmSymbols::java_lang_AbstractMethodError();
}
_exception_name = vmSymbols::java_lang_AbstractMethodError();
// If only one qualified method is default, select that
} else if (num_defaults == 1) {
_selected_target = qualified_methods.at(default_index);
} else if (num_defaults > 1) {
_exception_message = generate_conflicts_message(&qualified_methods,CHECK);
_exception_name = vmSymbols::java_lang_IncompatibleClassChangeError();
} else if (num_defaults > 1 && !has_matching_static(root)) {
_exception_message = generate_conflicts_message(&qualified_methods,CHECK);
_exception_name = vmSymbols::java_lang_IncompatibleClassChangeError();
if (TraceDefaultMethods) {
_exception_message->print_value_on(tty);
tty->print_cr("");
......
......@@ -175,8 +175,8 @@ oop MethodHandles::init_MemberName(Handle mname, Handle target) {
oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
assert(info.resolved_appendix().is_null(), "only normal methods here");
KlassHandle receiver_limit = info.resolved_klass();
methodHandle m = info.resolved_method();
KlassHandle m_klass = m->method_holder();
int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS );
int vmindex = Method::invalid_vtable_index;
......@@ -184,14 +184,13 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
case CallInfo::itable_call:
vmindex = info.itable_index();
// More importantly, the itable index only works with the method holder.
receiver_limit = m->method_holder();
assert(receiver_limit->verify_itable_index(vmindex), "");
assert(m_klass->verify_itable_index(vmindex), "");
flags |= IS_METHOD | (JVM_REF_invokeInterface << REFERENCE_KIND_SHIFT);
if (TraceInvokeDynamic) {
ResourceMark rm;
tty->print_cr("memberName: invokeinterface method_holder::method: %s, receiver: %s, itableindex: %d, access_flags:",
Method::name_and_sig_as_C_string(receiver_limit(), m->name(), m->signature()),
receiver_limit()->internal_name(), vmindex);
tty->print_cr("memberName: invokeinterface method_holder::method: %s, itableindex: %d, access_flags:",
Method::name_and_sig_as_C_string(m->method_holder(), m->name(), m->signature()),
vmindex);
m->access_flags().print_on(tty);
if (!m->is_abstract()) {
tty->print("default");
......@@ -203,12 +202,35 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
case CallInfo::vtable_call:
vmindex = info.vtable_index();
flags |= IS_METHOD | (JVM_REF_invokeVirtual << REFERENCE_KIND_SHIFT);
assert(receiver_limit->is_subtype_of(m->method_holder()), "virtual call must be type-safe");
assert(info.resolved_klass()->is_subtype_of(m_klass()), "virtual call must be type-safe");
if (m_klass->is_interface()) {
// This is a vtable call to an interface method (abstract "miranda method" or default method).
// The vtable index is meaningless without a class (not interface) receiver type, so get one.
// (LinkResolver should help us figure this out.)
KlassHandle m_klass_non_interface = info.resolved_klass();
if (m_klass_non_interface->is_interface()) {
m_klass_non_interface = SystemDictionary::Object_klass();
#ifdef ASSERT
{ ResourceMark rm;
Method* m2 = m_klass_non_interface->vtable()->method_at(vmindex);
assert(m->name() == m2->name() && m->signature() == m2->signature(),
err_msg("at %d, %s != %s", vmindex,
m->name_and_sig_as_C_string(), m2->name_and_sig_as_C_string()));
}
#endif //ASSERT
}
if (!m->is_public()) {
assert(m->is_public(), "virtual call must be to public interface method");
return NULL; // elicit an error later in product build
}
assert(info.resolved_klass()->is_subtype_of(m_klass_non_interface()), "virtual call must be type-safe");
m_klass = m_klass_non_interface;
}
if (TraceInvokeDynamic) {
ResourceMark rm;
tty->print_cr("memberName: invokevirtual method_holder::method: %s, receiver: %s, vtableindex: %d, access_flags:",
Method::name_and_sig_as_C_string(receiver_limit(), m->name(), m->signature()),
receiver_limit()->internal_name(), vmindex);
Method::name_and_sig_as_C_string(m->method_holder(), m->name(), m->signature()),
m_klass->internal_name(), vmindex);
m->access_flags().print_on(tty);
if (m->is_default_method()) {
tty->print("default");
......@@ -223,10 +245,8 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
flags |= IS_METHOD | (JVM_REF_invokeStatic << REFERENCE_KIND_SHIFT);
} else if (m->is_initializer()) {
flags |= IS_CONSTRUCTOR | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT);
assert(receiver_limit == m->method_holder(), "constructor call must be exactly typed");
} else {
flags |= IS_METHOD | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT);
assert(receiver_limit->is_subtype_of(m->method_holder()), "special call must be type-safe");
}
break;
......@@ -242,7 +262,7 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
java_lang_invoke_MemberName::set_flags( mname_oop, flags);
java_lang_invoke_MemberName::set_vmtarget(mname_oop, m());
java_lang_invoke_MemberName::set_vmindex( mname_oop, vmindex); // vtable/itable index
java_lang_invoke_MemberName::set_clazz( mname_oop, receiver_limit->java_mirror());
java_lang_invoke_MemberName::set_clazz( mname_oop, m_klass->java_mirror());
// Note: name and type can be lazily computed by resolve_MemberName,
// if Java code needs them as resolved String and MethodType objects.
// The clazz must be eagerly stored, because it provides a GC
......@@ -569,7 +589,7 @@ oop MethodHandles::field_signature_type_or_null(Symbol* s) {
// An unresolved member name is a mere symbolic reference.
// Resolving it plants a vmtarget/vmindex in it,
// which refers directly to JVM internals.
Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
Handle MethodHandles::resolve_MemberName(Handle mname, KlassHandle caller, TRAPS) {
Handle empty;
assert(java_lang_invoke_MemberName::is_instance(mname()), "");
......@@ -646,20 +666,20 @@ Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
assert(!HAS_PENDING_EXCEPTION, "");
if (ref_kind == JVM_REF_invokeStatic) {
LinkResolver::resolve_static_call(result,
defc, name, type, KlassHandle(), false, false, THREAD);
defc, name, type, caller, caller.not_null(), false, THREAD);
} else if (ref_kind == JVM_REF_invokeInterface) {
LinkResolver::resolve_interface_call(result, Handle(), defc,
defc, name, type, KlassHandle(), false, false, THREAD);
defc, name, type, caller, caller.not_null(), false, THREAD);
} else if (mh_invoke_id != vmIntrinsics::_none) {
assert(!is_signature_polymorphic_static(mh_invoke_id), "");
LinkResolver::resolve_handle_call(result,
defc, name, type, KlassHandle(), THREAD);
defc, name, type, caller, THREAD);
} else if (ref_kind == JVM_REF_invokeSpecial) {
LinkResolver::resolve_special_call(result,
defc, name, type, KlassHandle(), false, THREAD);
defc, name, type, caller, caller.not_null(), THREAD);
} else if (ref_kind == JVM_REF_invokeVirtual) {
LinkResolver::resolve_virtual_call(result, Handle(), defc,
defc, name, type, KlassHandle(), false, false, THREAD);
defc, name, type, caller, caller.not_null(), false, THREAD);
} else {
assert(false, err_msg("ref_kind=%d", ref_kind));
}
......@@ -683,7 +703,7 @@ Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
assert(!HAS_PENDING_EXCEPTION, "");
if (name == vmSymbols::object_initializer_name()) {
LinkResolver::resolve_special_call(result,
defc, name, type, KlassHandle(), false, THREAD);
defc, name, type, caller, caller.not_null(), THREAD);
} else {
break; // will throw after end of switch
}
......@@ -700,7 +720,7 @@ Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
fieldDescriptor result; // find_field initializes fd if found
{
assert(!HAS_PENDING_EXCEPTION, "");
LinkResolver::resolve_field(result, defc, name, type, KlassHandle(), Bytecodes::_nop, false, false, THREAD);
LinkResolver::resolve_field(result, defc, name, type, caller, Bytecodes::_nop, false, false, THREAD);
if (HAS_PENDING_EXCEPTION) {
return empty;
}
......@@ -1121,7 +1141,11 @@ JVM_ENTRY(jobject, MHN_resolve_Mem(JNIEnv *env, jobject igcls, jobject mname_jh,
}
}
Handle resolved = MethodHandles::resolve_MemberName(mname, CHECK_NULL);
KlassHandle caller(THREAD,
caller_jh == NULL ? (Klass*) NULL :
java_lang_Class::as_Klass(JNIHandles::resolve_non_null(caller_jh)));
Handle resolved = MethodHandles::resolve_MemberName(mname, caller, CHECK_NULL);
if (resolved.is_null()) {
int flags = java_lang_invoke_MemberName::flags(mname());
int ref_kind = (flags >> REFERENCE_KIND_SHIFT) & REFERENCE_KIND_MASK;
......
......@@ -55,7 +55,7 @@ class MethodHandles: AllStatic {
public:
// working with member names
static Handle resolve_MemberName(Handle mname, TRAPS); // compute vmtarget/vmindex from name/type
static Handle resolve_MemberName(Handle mname, KlassHandle caller, TRAPS); // compute vmtarget/vmindex from name/type
static void expand_MemberName(Handle mname, int suppress, TRAPS); // expand defc/name/type if missing
static Handle new_MemberName(TRAPS); // must be followed by init_MemberName
static oop init_MemberName(Handle mname_h, Handle target_h); // compute vmtarget/vmindex from target
......
......@@ -1264,9 +1264,6 @@ bool os::set_boot_path(char fileSep, char pathSep) {
"%/lib/jce.jar:"
"%/lib/charsets.jar:"
"%/lib/jfr.jar:"
#ifdef __APPLE__
"%/lib/JObjC.jar:"
#endif
"%/classes";
char* sysclasspath = format_boot_path(classpath_format, home, home_len, fileSep, pathSep);
if (sysclasspath == NULL) return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册