1 /*
2 * Copyright (c) 2003, 2016, 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 *
171 }
172 if (pos<0 && i<(chops-1)) return -1;
173 }
174 return pos+1;
175 }
176
177 VerificationType StackMapReader::parse_verification_type(u1* flags, TRAPS) {
178 u1 tag = _stream->get_u1(THREAD);
179 if (tag < (u1)ITEM_UninitializedThis) {
180 return VerificationType::from_tag(tag);
181 }
182 if (tag == ITEM_Object) {
183 u2 class_index = _stream->get_u2(THREAD);
184 int nconstants = _cp->length();
185 if ((class_index <= 0 || class_index >= nconstants) ||
186 (!_cp->tag_at(class_index).is_klass() &&
187 !_cp->tag_at(class_index).is_unresolved_klass())) {
188 _stream->stackmap_format_error("bad class index", THREAD);
189 return VerificationType::bogus_type();
190 }
191 return VerificationType::reference_type(_cp->klass_name_at(class_index));
192 }
193 if (tag == ITEM_UninitializedThis) {
194 if (flags != NULL) {
195 *flags |= FLAG_THIS_UNINIT;
196 }
197 return VerificationType::uninitialized_this_type();
198 }
199 if (tag == ITEM_Uninitialized) {
200 u2 offset = _stream->get_u2(THREAD);
201 if (offset >= _code_length ||
202 _code_data[offset] != ClassVerifier::NEW_OFFSET) {
203 _verifier->class_format_error(
204 "StackMapTable format error: bad offset for Uninitialized");
205 return VerificationType::bogus_type();
206 }
207 return VerificationType::uninitialized_type(offset);
208 }
209 _stream->stackmap_format_error("bad verification type", THREAD);
210 return VerificationType::bogus_type();
211 }
|
1 /*
2 * Copyright (c) 2003, 2018, 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 *
171 }
172 if (pos<0 && i<(chops-1)) return -1;
173 }
174 return pos+1;
175 }
176
177 VerificationType StackMapReader::parse_verification_type(u1* flags, TRAPS) {
178 u1 tag = _stream->get_u1(THREAD);
179 if (tag < (u1)ITEM_UninitializedThis) {
180 return VerificationType::from_tag(tag);
181 }
182 if (tag == ITEM_Object) {
183 u2 class_index = _stream->get_u2(THREAD);
184 int nconstants = _cp->length();
185 if ((class_index <= 0 || class_index >= nconstants) ||
186 (!_cp->tag_at(class_index).is_klass() &&
187 !_cp->tag_at(class_index).is_unresolved_klass())) {
188 _stream->stackmap_format_error("bad class index", THREAD);
189 return VerificationType::bogus_type();
190 }
191 Symbol* klass_name = _cp->klass_name_at(class_index);
192 if (klass_name->is_Q_signature()) {
193 Symbol* fund_name = klass_name->fundamental_name(THREAD);
194 if (fund_name == NULL) {
195 _stream->stackmap_format_error("TBD something bad happened", THREAD);
196 return VerificationType::bogus_type();
197 }
198 return VerificationType::valuetype_type(fund_name);
199 } else {
200 return VerificationType::reference_type(klass_name);
201 }
202 }
203 if (tag == ITEM_UninitializedThis) {
204 if (flags != NULL) {
205 *flags |= FLAG_THIS_UNINIT;
206 }
207 return VerificationType::uninitialized_this_type();
208 }
209 if (tag == ITEM_Uninitialized) {
210 u2 offset = _stream->get_u2(THREAD);
211 if (offset >= _code_length ||
212 _code_data[offset] != ClassVerifier::NEW_OFFSET) {
213 _verifier->class_format_error(
214 "StackMapTable format error: bad offset for Uninitialized");
215 return VerificationType::bogus_type();
216 }
217 return VerificationType::uninitialized_type(offset);
218 }
219 _stream->stackmap_format_error("bad verification type", THREAD);
220 return VerificationType::bogus_type();
221 }
|