mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 02:24:40 +02:00
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
Pass tag in LinkInfo and check that resolved method type matches tag, fix tests. Reviewed-by: sspitsyn, minqi
This commit is contained in:
parent
6253b1d251
commit
c36295e947
18 changed files with 543 additions and 62 deletions
|
@ -417,6 +417,19 @@ int ConstantPool::impl_name_and_type_ref_index_at(int which, bool uncached) {
|
|||
return extract_high_short_from_int(ref_index);
|
||||
}
|
||||
|
||||
constantTag ConstantPool::impl_tag_ref_at(int which, bool uncached) {
|
||||
int pool_index = which;
|
||||
if (!uncached && cache() != NULL) {
|
||||
if (ConstantPool::is_invokedynamic_index(which)) {
|
||||
// Invokedynamic index is index into resolved_references
|
||||
pool_index = invokedynamic_cp_cache_entry_at(which)->constant_pool_index();
|
||||
} else {
|
||||
// change byte-ordering and go via cache
|
||||
pool_index = remap_instruction_operand_from_cache(which);
|
||||
}
|
||||
}
|
||||
return tag_at(pool_index);
|
||||
}
|
||||
|
||||
int ConstantPool::impl_klass_ref_index_at(int which, bool uncached) {
|
||||
guarantee(!ConstantPool::is_invokedynamic_index(which),
|
||||
|
@ -672,6 +685,7 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp, in
|
|||
int callee_index = this_cp->method_handle_klass_index_at(index);
|
||||
Symbol* name = this_cp->method_handle_name_ref_at(index);
|
||||
Symbol* signature = this_cp->method_handle_signature_ref_at(index);
|
||||
constantTag m_tag = this_cp->tag_at(this_cp->method_handle_index_at(index));
|
||||
{ ResourceMark rm(THREAD);
|
||||
log_debug(class, resolve)("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s",
|
||||
ref_kind, index, this_cp->method_handle_index_at(index),
|
||||
|
@ -681,6 +695,15 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp, in
|
|||
{ Klass* k = klass_at_impl(this_cp, callee_index, true, CHECK_NULL);
|
||||
callee = KlassHandle(THREAD, k);
|
||||
}
|
||||
if ((callee->is_interface() && m_tag.is_method()) ||
|
||||
(!callee->is_interface() && m_tag.is_interface_method())) {
|
||||
ResourceMark rm(THREAD);
|
||||
char buf[200];
|
||||
jio_snprintf(buf, sizeof(buf), "Inconsistent constant data for %s.%s%s at index %d",
|
||||
callee->name()->as_C_string(), name->as_C_string(), signature->as_C_string(), index);
|
||||
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
|
||||
}
|
||||
|
||||
KlassHandle klass(THREAD, this_cp->pool_holder());
|
||||
Handle value = SystemDictionary::link_method_handle_constant(klass, ref_kind,
|
||||
callee, name, signature,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue