mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8036533
: Method for correct defaults
8036156: Limit default method hierarchy Fix protected access checks Reviewed-by: coleenp, lfoltan, acorn, ahgross
This commit is contained in:
parent
7bd17413f2
commit
f203dcbfbf
6 changed files with 36 additions and 27 deletions
|
@ -1721,7 +1721,7 @@ void ClassVerifier::verify_exception_handler_table(u4 code_length, char* code_da
|
|||
VerificationType throwable =
|
||||
VerificationType::reference_type(vmSymbols::java_lang_Throwable());
|
||||
bool is_subclass = throwable.is_assignable_from(
|
||||
catch_type, this, CHECK_VERIFY(this));
|
||||
catch_type, this, false, CHECK_VERIFY(this));
|
||||
if (!is_subclass) {
|
||||
// 4286534: should throw VerifyError according to recent spec change
|
||||
verify_error(ErrorContext::bad_type(handler_pc,
|
||||
|
@ -2174,7 +2174,7 @@ void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs,
|
|||
stack_object_type = current_type();
|
||||
}
|
||||
is_assignable = target_class_type.is_assignable_from(
|
||||
stack_object_type, this, CHECK_VERIFY(this));
|
||||
stack_object_type, this, false, CHECK_VERIFY(this));
|
||||
if (!is_assignable) {
|
||||
verify_error(ErrorContext::bad_type(bci,
|
||||
current_frame->stack_top_ctx(),
|
||||
|
@ -2201,7 +2201,7 @@ void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs,
|
|||
// It's protected access, check if stack object is assignable to
|
||||
// current class.
|
||||
is_assignable = current_type().is_assignable_from(
|
||||
stack_object_type, this, CHECK_VERIFY(this));
|
||||
stack_object_type, this, true, CHECK_VERIFY(this));
|
||||
if (!is_assignable) {
|
||||
verify_error(ErrorContext::bad_type(bci,
|
||||
current_frame->stack_top_ctx(),
|
||||
|
@ -2475,7 +2475,7 @@ void ClassVerifier::verify_invoke_init(
|
|||
instanceKlassHandle mh(THREAD, m->method_holder());
|
||||
if (m->is_protected() && !mh->is_same_class_package(_klass())) {
|
||||
bool assignable = current_type().is_assignable_from(
|
||||
objectref_type, this, CHECK_VERIFY(this));
|
||||
objectref_type, this, true, CHECK_VERIFY(this));
|
||||
if (!assignable) {
|
||||
verify_error(ErrorContext::bad_type(bci,
|
||||
TypeOrigin::cp(new_class_index, objectref_type),
|
||||
|
@ -2646,11 +2646,11 @@ void ClassVerifier::verify_invoke_instructions(
|
|||
bool have_imr_indirect = cp->tag_at(index).value() == JVM_CONSTANT_InterfaceMethodref;
|
||||
if (!current_class()->is_anonymous()) {
|
||||
subtype = ref_class_type.is_assignable_from(
|
||||
current_type(), this, CHECK_VERIFY(this));
|
||||
current_type(), this, false, CHECK_VERIFY(this));
|
||||
} else {
|
||||
VerificationType host_klass_type =
|
||||
VerificationType::reference_type(current_class()->host_klass()->name());
|
||||
subtype = ref_class_type.is_assignable_from(host_klass_type, this, CHECK_VERIFY(this));
|
||||
subtype = ref_class_type.is_assignable_from(host_klass_type, this, false, CHECK_VERIFY(this));
|
||||
|
||||
// If invokespecial of IMR, need to recheck for same or
|
||||
// direct interface relative to the host class
|
||||
|
@ -2694,7 +2694,7 @@ void ClassVerifier::verify_invoke_instructions(
|
|||
VerificationType top = current_frame->pop_stack(CHECK_VERIFY(this));
|
||||
VerificationType hosttype =
|
||||
VerificationType::reference_type(current_class()->host_klass()->name());
|
||||
bool subtype = hosttype.is_assignable_from(top, this, CHECK_VERIFY(this));
|
||||
bool subtype = hosttype.is_assignable_from(top, this, false, CHECK_VERIFY(this));
|
||||
if (!subtype) {
|
||||
verify_error( ErrorContext::bad_type(current_frame->offset(),
|
||||
current_frame->stack_top_ctx(),
|
||||
|
@ -2719,7 +2719,7 @@ void ClassVerifier::verify_invoke_instructions(
|
|||
// It's protected access, check if stack object is
|
||||
// assignable to current class.
|
||||
bool is_assignable = current_type().is_assignable_from(
|
||||
stack_object_type, this, CHECK_VERIFY(this));
|
||||
stack_object_type, this, true, CHECK_VERIFY(this));
|
||||
if (!is_assignable) {
|
||||
if (ref_class_type.name() == vmSymbols::java_lang_Object()
|
||||
&& stack_object_type.is_array()
|
||||
|
@ -2902,7 +2902,7 @@ void ClassVerifier::verify_return_value(
|
|||
"Method expects a return value");
|
||||
return;
|
||||
}
|
||||
bool match = return_type.is_assignable_from(type, this, CHECK_VERIFY(this));
|
||||
bool match = return_type.is_assignable_from(type, this, false, CHECK_VERIFY(this));
|
||||
if (!match) {
|
||||
verify_error(ErrorContext::bad_type(bci,
|
||||
current_frame->stack_top_ctx(), TypeOrigin::signature(return_type)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue