1 /*
2 * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
117
118 #if INCLUDE_CDS
119 if (CDSConfig::is_dumping_archive()) {
120 bool skip_assignability_check = false;
121 SystemDictionaryShared::add_verification_constraint(context->current_class(),
122 name(), from.name(), from_field_is_protected, from.is_array(),
123 from.is_object(), &skip_assignability_check);
124 if (skip_assignability_check) {
125 // We are not able to resolve name() or from.name(). The actual assignability check
126 // will be delayed until runtime.
127 return true;
128 }
129 }
130 #endif
131 return resolve_and_check_assignability(context->current_class(), name(), from.name(),
132 from_field_is_protected, from.is_array(),
133 from.is_object(), this_is_interface, THREAD);
134 } else if (is_array() && from.is_array()) {
135 VerificationType comp_this = get_component(context);
136 VerificationType comp_from = from.get_component(context);
137 if (!comp_this.is_bogus() && !comp_from.is_bogus()) {
138 return comp_this.is_component_assignable_from(comp_from, context,
139 from_field_is_protected, THREAD);
140 }
141 }
142 return false;
143 }
144
145 VerificationType VerificationType::get_component(ClassVerifier *context) const {
146 assert(is_array() && name()->utf8_length() >= 2, "Must be a valid array");
147 SignatureStream ss(name(), false);
148 ss.skip_array_prefix(1);
149 switch (ss.type()) {
150 case T_BOOLEAN: return VerificationType(Boolean);
151 case T_BYTE: return VerificationType(Byte);
152 case T_CHAR: return VerificationType(Char);
153 case T_SHORT: return VerificationType(Short);
154 case T_INT: return VerificationType(Integer);
155 case T_LONG: return VerificationType(Long);
156 case T_FLOAT: return VerificationType(Float);
|
1 /*
2 * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
117
118 #if INCLUDE_CDS
119 if (CDSConfig::is_dumping_archive()) {
120 bool skip_assignability_check = false;
121 SystemDictionaryShared::add_verification_constraint(context->current_class(),
122 name(), from.name(), from_field_is_protected, from.is_array(),
123 from.is_object(), &skip_assignability_check);
124 if (skip_assignability_check) {
125 // We are not able to resolve name() or from.name(). The actual assignability check
126 // will be delayed until runtime.
127 return true;
128 }
129 }
130 #endif
131 return resolve_and_check_assignability(context->current_class(), name(), from.name(),
132 from_field_is_protected, from.is_array(),
133 from.is_object(), this_is_interface, THREAD);
134 } else if (is_array() && from.is_array()) {
135 VerificationType comp_this = get_component(context);
136 VerificationType comp_from = from.get_component(context);
137
138 if (!comp_this.is_bogus() && !comp_from.is_bogus()) {
139 return comp_this.is_component_assignable_from(comp_from, context,
140 from_field_is_protected, THREAD);
141 }
142 }
143 return false;
144 }
145
146 VerificationType VerificationType::get_component(ClassVerifier *context) const {
147 assert(is_array() && name()->utf8_length() >= 2, "Must be a valid array");
148 SignatureStream ss(name(), false);
149 ss.skip_array_prefix(1);
150 switch (ss.type()) {
151 case T_BOOLEAN: return VerificationType(Boolean);
152 case T_BYTE: return VerificationType(Byte);
153 case T_CHAR: return VerificationType(Char);
154 case T_SHORT: return VerificationType(Short);
155 case T_INT: return VerificationType(Integer);
156 case T_LONG: return VerificationType(Long);
157 case T_FLOAT: return VerificationType(Float);
|