92 // We need check the class hierarchy to check assignability
93 if (name() == vmSymbols::java_lang_Object()) {
94 // any object or array is assignable to java.lang.Object
95 return true;
96 }
97
98 if (DumpSharedSpaces && SystemDictionaryShared::add_verification_constraint(klass,
99 name(), from.name(), from_field_is_protected, from.is_array(),
100 from.is_object())) {
101 // If add_verification_constraint() returns true, the resolution/check should be
102 // delayed until runtime.
103 return true;
104 }
105
106 return resolve_and_check_assignability(klass, name(), from.name(),
107 from_field_is_protected, from.is_array(), from.is_object(), THREAD);
108 } else if (is_array() && from.is_array()) {
109 VerificationType comp_this = get_component(context, CHECK_false);
110 VerificationType comp_from = from.get_component(context, CHECK_false);
111
112 // This code implements non-covariance between value type arrays and both
113 // arrays of objects and arrays of interface types. If covariance is
114 // supported for value type arrays then this code should be removed.
115 if (comp_from.is_valuetype() && !comp_this.is_null() && comp_this.is_reference()) {
116 // An array of value types is not assignable to an array of java.lang.Objects.
117 if (comp_this.name() == vmSymbols::java_lang_Object()) {
118 return false;
119 }
120
121 // Need to load 'comp_this' to see if it is an interface.
122 InstanceKlass* klass = context->current_class();
123 {
124 HandleMark hm(THREAD);
125 Klass* comp_this_class = SystemDictionary::resolve_or_fail(
126 comp_this.name(), Handle(THREAD, klass->class_loader()),
127 Handle(THREAD, klass->protection_domain()), true, CHECK_false);
128 klass->class_loader_data()->record_dependency(comp_this_class);
129 if (log_is_enabled(Debug, class, resolve)) {
130 Verifier::trace_class_resolution(comp_this_class, klass);
131 }
132 // An array of value types is not assignable to an array of interface types.
133 if (comp_this_class->is_interface()) {
134 return false;
135 }
136 }
137 }
138
139 if (!comp_this.is_bogus() && !comp_from.is_bogus()) {
140 return comp_this.is_component_assignable_from(comp_from, context,
141 from_field_is_protected, THREAD);
142 }
143 }
144 return false;
145 }
146
147 bool VerificationType::is_valuetype_assignable_from(const VerificationType& from) const {
148 // Check that 'from' is not null, is a value type, and is the same value type.
149 assert(is_valuetype(), "called with a non-valuetype type");
150 assert(!is_null(), "valuetype is not null");
151 assert(name() != vmSymbols::java_lang_Object(), "java.lang.Object is a value type?");
152 return (!from.is_null() && from.is_valuetype() && name() == from.name());
153 }
154
155 bool VerificationType::is_ref_assignable_from_value_type(const VerificationType& from, ClassVerifier* context, TRAPS) const {
156 assert(!from.is_null(), "Value type should not be null");
157 if (!is_null() && (name()->is_same_fundamental_type(from.name()) ||
158 name() == vmSymbols::java_lang_Object())) {
|
92 // We need check the class hierarchy to check assignability
93 if (name() == vmSymbols::java_lang_Object()) {
94 // any object or array is assignable to java.lang.Object
95 return true;
96 }
97
98 if (DumpSharedSpaces && SystemDictionaryShared::add_verification_constraint(klass,
99 name(), from.name(), from_field_is_protected, from.is_array(),
100 from.is_object())) {
101 // If add_verification_constraint() returns true, the resolution/check should be
102 // delayed until runtime.
103 return true;
104 }
105
106 return resolve_and_check_assignability(klass, name(), from.name(),
107 from_field_is_protected, from.is_array(), from.is_object(), THREAD);
108 } else if (is_array() && from.is_array()) {
109 VerificationType comp_this = get_component(context, CHECK_false);
110 VerificationType comp_from = from.get_component(context, CHECK_false);
111
112 /*
113 // This code implements non-covariance between value type arrays and both
114 // arrays of objects and arrays of interface types. If covariance is
115 // supported for value type arrays then this code should be removed.
116 if (comp_from.is_valuetype() && !comp_this.is_null() && comp_this.is_reference()) {
117 // An array of value types is not assignable to an array of java.lang.Objects.
118 if (comp_this.name() == vmSymbols::java_lang_Object()) {
119 return false;
120 }
121
122 // Need to load 'comp_this' to see if it is an interface.
123 InstanceKlass* klass = context->current_class();
124 {
125 HandleMark hm(THREAD);
126 Klass* comp_this_class = SystemDictionary::resolve_or_fail(
127 comp_this.name(), Handle(THREAD, klass->class_loader()),
128 Handle(THREAD, klass->protection_domain()), true, CHECK_false);
129 klass->class_loader_data()->record_dependency(comp_this_class);
130 if (log_is_enabled(Debug, class, resolve)) {
131 Verifier::trace_class_resolution(comp_this_class, klass);
132 }
133 // An array of value types is not assignable to an array of interface types.
134 if (comp_this_class->is_interface()) {
135 return false;
136 }
137 }
138 }
139 */
140 if (!comp_this.is_bogus() && !comp_from.is_bogus()) {
141 return comp_this.is_component_assignable_from(comp_from, context,
142 from_field_is_protected, THREAD);
143 }
144 }
145 return false;
146 }
147
148 bool VerificationType::is_valuetype_assignable_from(const VerificationType& from) const {
149 // Check that 'from' is not null, is a value type, and is the same value type.
150 assert(is_valuetype(), "called with a non-valuetype type");
151 assert(!is_null(), "valuetype is not null");
152 assert(name() != vmSymbols::java_lang_Object(), "java.lang.Object is a value type?");
153 return (!from.is_null() && from.is_valuetype() && name() == from.name());
154 }
155
156 bool VerificationType::is_ref_assignable_from_value_type(const VerificationType& from, ClassVerifier* context, TRAPS) const {
157 assert(!from.is_null(), "Value type should not be null");
158 if (!is_null() && (name()->is_same_fundamental_type(from.name()) ||
159 name() == vmSymbols::java_lang_Object())) {
|