< prev index next >
src/share/vm/classfile/verificationType.cpp
Print this page
*** 40,61 ****
ShouldNotReachHere();
return bogus_type();
}
}
! bool VerificationType::resolve_and_check_assignability(instanceKlassHandle klass, Symbol* name,
Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object, TRAPS) {
HandleMark hm(THREAD);
! Klass* obj = SystemDictionary::resolve_or_fail(
name, Handle(THREAD, klass->class_loader()),
Handle(THREAD, klass->protection_domain()), true, CHECK_false);
if (log_is_enabled(Debug, class, resolve)) {
! Verifier::trace_class_resolution(obj, klass());
}
- KlassHandle this_class(THREAD, obj);
-
if (this_class->is_interface() && (!from_field_is_protected ||
from_name != vmSymbols::java_lang_Object())) {
// If we are not trying to access a protected field or method in
// java.lang.Object then, for arrays, we only allow assignability
// to interfaces java.lang.Cloneable and java.io.Serializable.
--- 40,59 ----
ShouldNotReachHere();
return bogus_type();
}
}
! bool VerificationType::resolve_and_check_assignability(InstanceKlass* klass, Symbol* name,
Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object, TRAPS) {
HandleMark hm(THREAD);
! Klass* this_class = SystemDictionary::resolve_or_fail(
name, Handle(THREAD, klass->class_loader()),
Handle(THREAD, klass->protection_domain()), true, CHECK_false);
if (log_is_enabled(Debug, class, resolve)) {
! Verifier::trace_class_resolution(this_class, klass);
}
if (this_class->is_interface() && (!from_field_is_protected ||
from_name != vmSymbols::java_lang_Object())) {
// If we are not trying to access a protected field or method in
// java.lang.Object then, for arrays, we only allow assignability
// to interfaces java.lang.Cloneable and java.io.Serializable.
*** 66,87 ****
} else if (from_is_object) {
Klass* from_class = SystemDictionary::resolve_or_fail(
from_name, Handle(THREAD, klass->class_loader()),
Handle(THREAD, klass->protection_domain()), true, CHECK_false);
if (log_is_enabled(Debug, class, resolve)) {
! Verifier::trace_class_resolution(from_class, klass());
}
! return InstanceKlass::cast(from_class)->is_subclass_of(this_class());
}
return false;
}
bool VerificationType::is_reference_assignable_from(
const VerificationType& from, ClassVerifier* context,
bool from_field_is_protected, TRAPS) const {
! instanceKlassHandle klass = context->current_class();
if (from.is_null()) {
// null is assignable to any reference
return true;
} else if (is_null()) {
return false;
--- 64,85 ----
} else if (from_is_object) {
Klass* from_class = SystemDictionary::resolve_or_fail(
from_name, Handle(THREAD, klass->class_loader()),
Handle(THREAD, klass->protection_domain()), true, CHECK_false);
if (log_is_enabled(Debug, class, resolve)) {
! Verifier::trace_class_resolution(from_class, klass);
}
! return InstanceKlass::cast(from_class)->is_subclass_of(this_class);
}
return false;
}
bool VerificationType::is_reference_assignable_from(
const VerificationType& from, ClassVerifier* context,
bool from_field_is_protected, TRAPS) const {
! InstanceKlass* klass = context->current_class();
if (from.is_null()) {
// null is assignable to any reference
return true;
} else if (is_null()) {
return false;
*** 92,110 ****
if (name() == vmSymbols::java_lang_Object()) {
// any object or array is assignable to java.lang.Object
return true;
}
! if (DumpSharedSpaces && SystemDictionaryShared::add_verification_constraint(klass(),
name(), from.name(), from_field_is_protected, from.is_array(),
from.is_object())) {
// If add_verification_constraint() returns true, the resolution/check should be
// delayed until runtime.
return true;
}
! return resolve_and_check_assignability(klass(), name(), from.name(),
from_field_is_protected, from.is_array(), from.is_object(), THREAD);
} else if (is_array() && from.is_array()) {
VerificationType comp_this = get_component(context, CHECK_false);
VerificationType comp_from = from.get_component(context, CHECK_false);
if (!comp_this.is_bogus() && !comp_from.is_bogus()) {
--- 90,108 ----
if (name() == vmSymbols::java_lang_Object()) {
// any object or array is assignable to java.lang.Object
return true;
}
! if (DumpSharedSpaces && SystemDictionaryShared::add_verification_constraint(klass,
name(), from.name(), from_field_is_protected, from.is_array(),
from.is_object())) {
// If add_verification_constraint() returns true, the resolution/check should be
// delayed until runtime.
return true;
}
! return resolve_and_check_assignability(klass, name(), from.name(),
from_field_is_protected, from.is_array(), from.is_object(), THREAD);
} else if (is_array() && from.is_array()) {
VerificationType comp_this = get_component(context, CHECK_false);
VerificationType comp_from = from.get_component(context, CHECK_false);
if (!comp_this.is_bogus() && !comp_from.is_bogus()) {
< prev index next >