Tue, 23 Nov 2010 13:22:55 -0800
6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg
1 /*
2 * Copyright (c) 1998, 2010, 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 *
23 */
25 #include "precompiled.hpp"
26 #include "classfile/classFileStream.hpp"
27 #include "classfile/javaClasses.hpp"
28 #include "classfile/stackMapTable.hpp"
29 #include "classfile/systemDictionary.hpp"
30 #include "classfile/verifier.hpp"
31 #include "classfile/vmSymbols.hpp"
32 #include "interpreter/bytecodeStream.hpp"
33 #include "memory/oopFactory.hpp"
34 #include "memory/resourceArea.hpp"
35 #include "oops/instanceKlass.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "oops/typeArrayOop.hpp"
38 #include "prims/jvm.h"
39 #include "runtime/fieldDescriptor.hpp"
40 #include "runtime/handles.inline.hpp"
41 #include "runtime/hpi.hpp"
42 #include "runtime/interfaceSupport.hpp"
43 #include "runtime/javaCalls.hpp"
44 #include "runtime/orderAccess.hpp"
45 #include "runtime/os.hpp"
46 #ifdef TARGET_ARCH_x86
47 # include "bytes_x86.hpp"
48 #endif
49 #ifdef TARGET_ARCH_sparc
50 # include "bytes_sparc.hpp"
51 #endif
52 #ifdef TARGET_ARCH_zero
53 # include "bytes_zero.hpp"
54 #endif
56 #define NOFAILOVER_MAJOR_VERSION 51
58 // Access to external entry for VerifyClassCodes - old byte code verifier
60 extern "C" {
61 typedef jboolean (*verify_byte_codes_fn_t)(JNIEnv *, jclass, char *, jint);
62 typedef jboolean (*verify_byte_codes_fn_new_t)(JNIEnv *, jclass, char *, jint, jint);
63 }
65 static void* volatile _verify_byte_codes_fn = NULL;
67 static volatile jint _is_new_verify_byte_codes_fn = (jint) true;
69 static void* verify_byte_codes_fn() {
70 if (_verify_byte_codes_fn == NULL) {
71 void *lib_handle = os::native_java_library();
72 void *func = hpi::dll_lookup(lib_handle, "VerifyClassCodesForMajorVersion");
73 OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func);
74 if (func == NULL) {
75 OrderAccess::release_store(&_is_new_verify_byte_codes_fn, false);
76 func = hpi::dll_lookup(lib_handle, "VerifyClassCodes");
77 OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func);
78 }
79 }
80 return (void*)_verify_byte_codes_fn;
81 }
84 // Methods in Verifier
86 bool Verifier::should_verify_for(oop class_loader, bool should_verify_class) {
87 return (class_loader == NULL || !should_verify_class) ?
88 BytecodeVerificationLocal : BytecodeVerificationRemote;
89 }
91 bool Verifier::relax_verify_for(oop loader) {
92 bool trusted = java_lang_ClassLoader::is_trusted_loader(loader);
93 bool need_verify =
94 // verifyAll
95 (BytecodeVerificationLocal && BytecodeVerificationRemote) ||
96 // verifyRemote
97 (!BytecodeVerificationLocal && BytecodeVerificationRemote && !trusted);
98 return !need_verify;
99 }
101 bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool should_verify_class, TRAPS) {
102 ResourceMark rm(THREAD);
103 HandleMark hm;
105 symbolHandle exception_name;
106 const size_t message_buffer_len = klass->name()->utf8_length() + 1024;
107 char* message_buffer = NEW_RESOURCE_ARRAY(char, message_buffer_len);
109 const char* klassName = klass->external_name();
111 // If the class should be verified, first see if we can use the split
112 // verifier. If not, or if verification fails and FailOverToOldVerifier
113 // is set, then call the inference verifier.
114 if (is_eligible_for_verification(klass, should_verify_class)) {
115 if (TraceClassInitialization) {
116 tty->print_cr("Start class verification for: %s", klassName);
117 }
118 if (UseSplitVerifier &&
119 klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) {
120 ClassVerifier split_verifier(
121 klass, message_buffer, message_buffer_len, THREAD);
122 split_verifier.verify_class(THREAD);
123 exception_name = split_verifier.result();
124 if (klass->major_version() < NOFAILOVER_MAJOR_VERSION &&
125 FailOverToOldVerifier && !HAS_PENDING_EXCEPTION &&
126 (exception_name == vmSymbols::java_lang_VerifyError() ||
127 exception_name == vmSymbols::java_lang_ClassFormatError())) {
128 if (TraceClassInitialization) {
129 tty->print_cr(
130 "Fail over class verification to old verifier for: %s", klassName);
131 }
132 exception_name = inference_verify(
133 klass, message_buffer, message_buffer_len, THREAD);
134 }
135 } else {
136 exception_name = inference_verify(
137 klass, message_buffer, message_buffer_len, THREAD);
138 }
140 if (TraceClassInitialization) {
141 if (HAS_PENDING_EXCEPTION) {
142 tty->print("Verification for %s has", klassName);
143 tty->print_cr(" exception pending %s ",
144 instanceKlass::cast(PENDING_EXCEPTION->klass())->external_name());
145 } else if (!exception_name.is_null()) {
146 tty->print_cr("Verification for %s failed", klassName);
147 }
148 tty->print_cr("End class verification for: %s", klassName);
149 }
150 }
152 if (HAS_PENDING_EXCEPTION) {
153 return false; // use the existing exception
154 } else if (exception_name.is_null()) {
155 return true; // verifcation succeeded
156 } else { // VerifyError or ClassFormatError to be created and thrown
157 ResourceMark rm(THREAD);
158 instanceKlassHandle kls =
159 SystemDictionary::resolve_or_fail(exception_name, true, CHECK_false);
160 while (!kls.is_null()) {
161 if (kls == klass) {
162 // If the class being verified is the exception we're creating
163 // or one of it's superclasses, we're in trouble and are going
164 // to infinitely recurse when we try to initialize the exception.
165 // So bail out here by throwing the preallocated VM error.
166 THROW_OOP_(Universe::virtual_machine_error_instance(), false);
167 }
168 kls = kls->super();
169 }
170 message_buffer[message_buffer_len - 1] = '\0'; // just to be sure
171 THROW_MSG_(exception_name, message_buffer, false);
172 }
173 }
175 bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class) {
176 symbolOop name = klass->name();
177 klassOop refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass();
179 return (should_verify_for(klass->class_loader(), should_verify_class) &&
180 // return if the class is a bootstrapping class
181 // or defineClass specified not to verify by default (flags override passed arg)
182 // We need to skip the following four for bootstraping
183 name != vmSymbols::java_lang_Object() &&
184 name != vmSymbols::java_lang_Class() &&
185 name != vmSymbols::java_lang_String() &&
186 name != vmSymbols::java_lang_Throwable() &&
188 // Can not verify the bytecodes for shared classes because they have
189 // already been rewritten to contain constant pool cache indices,
190 // which the verifier can't understand.
191 // Shared classes shouldn't have stackmaps either.
192 !klass()->is_shared() &&
194 // As of the fix for 4486457 we disable verification for all of the
195 // dynamically-generated bytecodes associated with the 1.4
196 // reflection implementation, not just those associated with
197 // sun/reflect/SerializationConstructorAccessor.
198 // NOTE: this is called too early in the bootstrapping process to be
199 // guarded by Universe::is_gte_jdk14x_version()/UseNewReflection.
200 (refl_magic_klass == NULL ||
201 !klass->is_subtype_of(refl_magic_klass) ||
202 VerifyReflectionBytecodes)
203 );
204 }
206 symbolHandle Verifier::inference_verify(
207 instanceKlassHandle klass, char* message, size_t message_len, TRAPS) {
208 JavaThread* thread = (JavaThread*)THREAD;
209 JNIEnv *env = thread->jni_environment();
211 void* verify_func = verify_byte_codes_fn();
213 if (verify_func == NULL) {
214 jio_snprintf(message, message_len, "Could not link verifier");
215 return vmSymbols::java_lang_VerifyError();
216 }
218 ResourceMark rm(THREAD);
219 if (ClassVerifier::_verify_verbose) {
220 tty->print_cr("Verifying class %s with old format", klass->external_name());
221 }
223 jclass cls = (jclass) JNIHandles::make_local(env, klass->java_mirror());
224 jint result;
226 {
227 HandleMark hm(thread);
228 ThreadToNativeFromVM ttn(thread);
229 // ThreadToNativeFromVM takes care of changing thread_state, so safepoint
230 // code knows that we have left the VM
232 if (_is_new_verify_byte_codes_fn) {
233 verify_byte_codes_fn_new_t func =
234 CAST_TO_FN_PTR(verify_byte_codes_fn_new_t, verify_func);
235 result = (*func)(env, cls, message, (int)message_len,
236 klass->major_version());
237 } else {
238 verify_byte_codes_fn_t func =
239 CAST_TO_FN_PTR(verify_byte_codes_fn_t, verify_func);
240 result = (*func)(env, cls, message, (int)message_len);
241 }
242 }
244 JNIHandles::destroy_local(cls);
246 // These numbers are chosen so that VerifyClassCodes interface doesn't need
247 // to be changed (still return jboolean (unsigned char)), and result is
248 // 1 when verification is passed.
249 symbolHandle nh(NULL);
250 if (result == 0) {
251 return vmSymbols::java_lang_VerifyError();
252 } else if (result == 1) {
253 return nh; // verified.
254 } else if (result == 2) {
255 THROW_MSG_(vmSymbols::java_lang_OutOfMemoryError(), message, nh);
256 } else if (result == 3) {
257 return vmSymbols::java_lang_ClassFormatError();
258 } else {
259 ShouldNotReachHere();
260 return nh;
261 }
262 }
264 // Methods in ClassVerifier
266 bool ClassVerifier::_verify_verbose = false;
268 ClassVerifier::ClassVerifier(
269 instanceKlassHandle klass, char* msg, size_t msg_len, TRAPS)
270 : _thread(THREAD), _exception_type(symbolHandle()), _message(msg),
271 _message_buffer_len(msg_len), _klass(klass) {
272 _this_type = VerificationType::reference_type(klass->name());
273 }
275 ClassVerifier::~ClassVerifier() {
276 }
278 VerificationType ClassVerifier::object_type() const {
279 return VerificationType::reference_type(vmSymbols::java_lang_Object());
280 }
282 void ClassVerifier::verify_class(TRAPS) {
283 if (_verify_verbose) {
284 tty->print_cr("Verifying class %s with new format",
285 _klass->external_name());
286 }
288 objArrayHandle methods(THREAD, _klass->methods());
289 int num_methods = methods->length();
291 for (int index = 0; index < num_methods; index++) {
292 // Check for recursive re-verification before each method.
293 if (was_recursively_verified()) return;
295 methodOop m = (methodOop)methods->obj_at(index);
296 if (m->is_native() || m->is_abstract()) {
297 // If m is native or abstract, skip it. It is checked in class file
298 // parser that methods do not override a final method.
299 continue;
300 }
301 verify_method(methodHandle(THREAD, m), CHECK_VERIFY(this));
302 }
304 if (_verify_verbose || TraceClassInitialization) {
305 if (was_recursively_verified())
306 tty->print_cr("Recursive verification detected for: %s",
307 _klass->external_name());
308 }
309 }
311 void ClassVerifier::verify_method(methodHandle m, TRAPS) {
312 ResourceMark rm(THREAD);
313 _method = m; // initialize _method
314 if (_verify_verbose) {
315 tty->print_cr("Verifying method %s", m->name_and_sig_as_C_string());
316 }
318 const char* bad_type_msg = "Bad type on operand stack in %s";
320 int32_t max_stack = m->max_stack();
321 int32_t max_locals = m->max_locals();
322 constantPoolHandle cp(THREAD, m->constants());
324 if (!SignatureVerifier::is_valid_method_signature(m->signature())) {
325 class_format_error("Invalid method signature");
326 return;
327 }
329 // Initial stack map frame: offset is 0, stack is initially empty.
330 StackMapFrame current_frame(max_locals, max_stack, this);
331 // Set initial locals
332 VerificationType return_type = current_frame.set_locals_from_arg(
333 m, current_type(), CHECK_VERIFY(this));
335 int32_t stackmap_index = 0; // index to the stackmap array
337 u4 code_length = m->code_size();
339 // Scan the bytecode and map each instruction's start offset to a number.
340 char* code_data = generate_code_data(m, code_length, CHECK_VERIFY(this));
342 int ex_min = code_length;
343 int ex_max = -1;
344 // Look through each item on the exception table. Each of the fields must refer
345 // to a legal instruction.
346 verify_exception_handler_table(
347 code_length, code_data, ex_min, ex_max, CHECK_VERIFY(this));
349 // Look through each entry on the local variable table and make sure
350 // its range of code array offsets is valid. (4169817)
351 if (m->has_localvariable_table()) {
352 verify_local_variable_table(code_length, code_data, CHECK_VERIFY(this));
353 }
355 typeArrayHandle stackmap_data(THREAD, m->stackmap_data());
356 StackMapStream stream(stackmap_data);
357 StackMapReader reader(this, &stream, code_data, code_length, THREAD);
358 StackMapTable stackmap_table(&reader, ¤t_frame, max_locals, max_stack,
359 code_data, code_length, CHECK_VERIFY(this));
361 if (_verify_verbose) {
362 stackmap_table.print();
363 }
365 RawBytecodeStream bcs(m);
367 // Scan the byte code linearly from the start to the end
368 bool no_control_flow = false; // Set to true when there is no direct control
369 // flow from current instruction to the next
370 // instruction in sequence
371 Bytecodes::Code opcode;
372 while (!bcs.is_last_bytecode()) {
373 // Check for recursive re-verification before each bytecode.
374 if (was_recursively_verified()) return;
376 opcode = bcs.raw_next();
377 u2 bci = bcs.bci();
379 // Set current frame's offset to bci
380 current_frame.set_offset(bci);
382 // Make sure every offset in stackmap table point to the beginning to
383 // an instruction. Match current_frame to stackmap_table entry with
384 // the same offset if exists.
385 stackmap_index = verify_stackmap_table(
386 stackmap_index, bci, ¤t_frame, &stackmap_table,
387 no_control_flow, CHECK_VERIFY(this));
389 bool this_uninit = false; // Set to true when invokespecial <init> initialized 'this'
391 // Merge with the next instruction
392 {
393 u2 index;
394 int target;
395 VerificationType type, type2;
396 VerificationType atype;
398 #ifndef PRODUCT
399 if (_verify_verbose) {
400 current_frame.print();
401 tty->print_cr("offset = %d, opcode = %s", bci, Bytecodes::name(opcode));
402 }
403 #endif
405 // Make sure wide instruction is in correct format
406 if (bcs.is_wide()) {
407 if (opcode != Bytecodes::_iinc && opcode != Bytecodes::_iload &&
408 opcode != Bytecodes::_aload && opcode != Bytecodes::_lload &&
409 opcode != Bytecodes::_istore && opcode != Bytecodes::_astore &&
410 opcode != Bytecodes::_lstore && opcode != Bytecodes::_fload &&
411 opcode != Bytecodes::_dload && opcode != Bytecodes::_fstore &&
412 opcode != Bytecodes::_dstore) {
413 verify_error(bci, "Bad wide instruction");
414 return;
415 }
416 }
418 switch (opcode) {
419 case Bytecodes::_nop :
420 no_control_flow = false; break;
421 case Bytecodes::_aconst_null :
422 current_frame.push_stack(
423 VerificationType::null_type(), CHECK_VERIFY(this));
424 no_control_flow = false; break;
425 case Bytecodes::_iconst_m1 :
426 case Bytecodes::_iconst_0 :
427 case Bytecodes::_iconst_1 :
428 case Bytecodes::_iconst_2 :
429 case Bytecodes::_iconst_3 :
430 case Bytecodes::_iconst_4 :
431 case Bytecodes::_iconst_5 :
432 current_frame.push_stack(
433 VerificationType::integer_type(), CHECK_VERIFY(this));
434 no_control_flow = false; break;
435 case Bytecodes::_lconst_0 :
436 case Bytecodes::_lconst_1 :
437 current_frame.push_stack_2(
438 VerificationType::long_type(),
439 VerificationType::long2_type(), CHECK_VERIFY(this));
440 no_control_flow = false; break;
441 case Bytecodes::_fconst_0 :
442 case Bytecodes::_fconst_1 :
443 case Bytecodes::_fconst_2 :
444 current_frame.push_stack(
445 VerificationType::float_type(), CHECK_VERIFY(this));
446 no_control_flow = false; break;
447 case Bytecodes::_dconst_0 :
448 case Bytecodes::_dconst_1 :
449 current_frame.push_stack_2(
450 VerificationType::double_type(),
451 VerificationType::double2_type(), CHECK_VERIFY(this));
452 no_control_flow = false; break;
453 case Bytecodes::_sipush :
454 case Bytecodes::_bipush :
455 current_frame.push_stack(
456 VerificationType::integer_type(), CHECK_VERIFY(this));
457 no_control_flow = false; break;
458 case Bytecodes::_ldc :
459 verify_ldc(
460 opcode, bcs.get_index_u1(), ¤t_frame,
461 cp, bci, CHECK_VERIFY(this));
462 no_control_flow = false; break;
463 case Bytecodes::_ldc_w :
464 case Bytecodes::_ldc2_w :
465 verify_ldc(
466 opcode, bcs.get_index_u2(), ¤t_frame,
467 cp, bci, CHECK_VERIFY(this));
468 no_control_flow = false; break;
469 case Bytecodes::_iload :
470 verify_iload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this));
471 no_control_flow = false; break;
472 case Bytecodes::_iload_0 :
473 case Bytecodes::_iload_1 :
474 case Bytecodes::_iload_2 :
475 case Bytecodes::_iload_3 :
476 index = opcode - Bytecodes::_iload_0;
477 verify_iload(index, ¤t_frame, CHECK_VERIFY(this));
478 no_control_flow = false; break;
479 case Bytecodes::_lload :
480 verify_lload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this));
481 no_control_flow = false; break;
482 case Bytecodes::_lload_0 :
483 case Bytecodes::_lload_1 :
484 case Bytecodes::_lload_2 :
485 case Bytecodes::_lload_3 :
486 index = opcode - Bytecodes::_lload_0;
487 verify_lload(index, ¤t_frame, CHECK_VERIFY(this));
488 no_control_flow = false; break;
489 case Bytecodes::_fload :
490 verify_fload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this));
491 no_control_flow = false; break;
492 case Bytecodes::_fload_0 :
493 case Bytecodes::_fload_1 :
494 case Bytecodes::_fload_2 :
495 case Bytecodes::_fload_3 :
496 index = opcode - Bytecodes::_fload_0;
497 verify_fload(index, ¤t_frame, CHECK_VERIFY(this));
498 no_control_flow = false; break;
499 case Bytecodes::_dload :
500 verify_dload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this));
501 no_control_flow = false; break;
502 case Bytecodes::_dload_0 :
503 case Bytecodes::_dload_1 :
504 case Bytecodes::_dload_2 :
505 case Bytecodes::_dload_3 :
506 index = opcode - Bytecodes::_dload_0;
507 verify_dload(index, ¤t_frame, CHECK_VERIFY(this));
508 no_control_flow = false; break;
509 case Bytecodes::_aload :
510 verify_aload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this));
511 no_control_flow = false; break;
512 case Bytecodes::_aload_0 :
513 case Bytecodes::_aload_1 :
514 case Bytecodes::_aload_2 :
515 case Bytecodes::_aload_3 :
516 index = opcode - Bytecodes::_aload_0;
517 verify_aload(index, ¤t_frame, CHECK_VERIFY(this));
518 no_control_flow = false; break;
519 case Bytecodes::_iaload :
520 type = current_frame.pop_stack(
521 VerificationType::integer_type(), CHECK_VERIFY(this));
522 atype = current_frame.pop_stack(
523 VerificationType::reference_check(), CHECK_VERIFY(this));
524 if (!atype.is_int_array()) {
525 verify_error(bci, bad_type_msg, "iaload");
526 return;
527 }
528 current_frame.push_stack(
529 VerificationType::integer_type(), CHECK_VERIFY(this));
530 no_control_flow = false; break;
531 case Bytecodes::_baload :
532 type = current_frame.pop_stack(
533 VerificationType::integer_type(), CHECK_VERIFY(this));
534 atype = current_frame.pop_stack(
535 VerificationType::reference_check(), CHECK_VERIFY(this));
536 if (!atype.is_bool_array() && !atype.is_byte_array()) {
537 verify_error(bci, bad_type_msg, "baload");
538 return;
539 }
540 current_frame.push_stack(
541 VerificationType::integer_type(), CHECK_VERIFY(this));
542 no_control_flow = false; break;
543 case Bytecodes::_caload :
544 type = current_frame.pop_stack(
545 VerificationType::integer_type(), CHECK_VERIFY(this));
546 atype = current_frame.pop_stack(
547 VerificationType::reference_check(), CHECK_VERIFY(this));
548 if (!atype.is_char_array()) {
549 verify_error(bci, bad_type_msg, "caload");
550 return;
551 }
552 current_frame.push_stack(
553 VerificationType::integer_type(), CHECK_VERIFY(this));
554 no_control_flow = false; break;
555 case Bytecodes::_saload :
556 type = current_frame.pop_stack(
557 VerificationType::integer_type(), CHECK_VERIFY(this));
558 atype = current_frame.pop_stack(
559 VerificationType::reference_check(), CHECK_VERIFY(this));
560 if (!atype.is_short_array()) {
561 verify_error(bci, bad_type_msg, "saload");
562 return;
563 }
564 current_frame.push_stack(
565 VerificationType::integer_type(), CHECK_VERIFY(this));
566 no_control_flow = false; break;
567 case Bytecodes::_laload :
568 type = current_frame.pop_stack(
569 VerificationType::integer_type(), CHECK_VERIFY(this));
570 atype = current_frame.pop_stack(
571 VerificationType::reference_check(), CHECK_VERIFY(this));
572 if (!atype.is_long_array()) {
573 verify_error(bci, bad_type_msg, "laload");
574 return;
575 }
576 current_frame.push_stack_2(
577 VerificationType::long_type(),
578 VerificationType::long2_type(), CHECK_VERIFY(this));
579 no_control_flow = false; break;
580 case Bytecodes::_faload :
581 type = current_frame.pop_stack(
582 VerificationType::integer_type(), CHECK_VERIFY(this));
583 atype = current_frame.pop_stack(
584 VerificationType::reference_check(), CHECK_VERIFY(this));
585 if (!atype.is_float_array()) {
586 verify_error(bci, bad_type_msg, "faload");
587 return;
588 }
589 current_frame.push_stack(
590 VerificationType::float_type(), CHECK_VERIFY(this));
591 no_control_flow = false; break;
592 case Bytecodes::_daload :
593 type = current_frame.pop_stack(
594 VerificationType::integer_type(), CHECK_VERIFY(this));
595 atype = current_frame.pop_stack(
596 VerificationType::reference_check(), CHECK_VERIFY(this));
597 if (!atype.is_double_array()) {
598 verify_error(bci, bad_type_msg, "daload");
599 return;
600 }
601 current_frame.push_stack_2(
602 VerificationType::double_type(),
603 VerificationType::double2_type(), CHECK_VERIFY(this));
604 no_control_flow = false; break;
605 case Bytecodes::_aaload : {
606 type = current_frame.pop_stack(
607 VerificationType::integer_type(), CHECK_VERIFY(this));
608 atype = current_frame.pop_stack(
609 VerificationType::reference_check(), CHECK_VERIFY(this));
610 if (!atype.is_reference_array()) {
611 verify_error(bci, bad_type_msg, "aaload");
612 return;
613 }
614 if (atype.is_null()) {
615 current_frame.push_stack(
616 VerificationType::null_type(), CHECK_VERIFY(this));
617 } else {
618 VerificationType component =
619 atype.get_component(CHECK_VERIFY(this));
620 current_frame.push_stack(component, CHECK_VERIFY(this));
621 }
622 no_control_flow = false; break;
623 }
624 case Bytecodes::_istore :
625 verify_istore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this));
626 no_control_flow = false; break;
627 case Bytecodes::_istore_0 :
628 case Bytecodes::_istore_1 :
629 case Bytecodes::_istore_2 :
630 case Bytecodes::_istore_3 :
631 index = opcode - Bytecodes::_istore_0;
632 verify_istore(index, ¤t_frame, CHECK_VERIFY(this));
633 no_control_flow = false; break;
634 case Bytecodes::_lstore :
635 verify_lstore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this));
636 no_control_flow = false; break;
637 case Bytecodes::_lstore_0 :
638 case Bytecodes::_lstore_1 :
639 case Bytecodes::_lstore_2 :
640 case Bytecodes::_lstore_3 :
641 index = opcode - Bytecodes::_lstore_0;
642 verify_lstore(index, ¤t_frame, CHECK_VERIFY(this));
643 no_control_flow = false; break;
644 case Bytecodes::_fstore :
645 verify_fstore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this));
646 no_control_flow = false; break;
647 case Bytecodes::_fstore_0 :
648 case Bytecodes::_fstore_1 :
649 case Bytecodes::_fstore_2 :
650 case Bytecodes::_fstore_3 :
651 index = opcode - Bytecodes::_fstore_0;
652 verify_fstore(index, ¤t_frame, CHECK_VERIFY(this));
653 no_control_flow = false; break;
654 case Bytecodes::_dstore :
655 verify_dstore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this));
656 no_control_flow = false; break;
657 case Bytecodes::_dstore_0 :
658 case Bytecodes::_dstore_1 :
659 case Bytecodes::_dstore_2 :
660 case Bytecodes::_dstore_3 :
661 index = opcode - Bytecodes::_dstore_0;
662 verify_dstore(index, ¤t_frame, CHECK_VERIFY(this));
663 no_control_flow = false; break;
664 case Bytecodes::_astore :
665 verify_astore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this));
666 no_control_flow = false; break;
667 case Bytecodes::_astore_0 :
668 case Bytecodes::_astore_1 :
669 case Bytecodes::_astore_2 :
670 case Bytecodes::_astore_3 :
671 index = opcode - Bytecodes::_astore_0;
672 verify_astore(index, ¤t_frame, CHECK_VERIFY(this));
673 no_control_flow = false; break;
674 case Bytecodes::_iastore :
675 type = current_frame.pop_stack(
676 VerificationType::integer_type(), CHECK_VERIFY(this));
677 type2 = current_frame.pop_stack(
678 VerificationType::integer_type(), CHECK_VERIFY(this));
679 atype = current_frame.pop_stack(
680 VerificationType::reference_check(), CHECK_VERIFY(this));
681 if (!atype.is_int_array()) {
682 verify_error(bci, bad_type_msg, "iastore");
683 return;
684 }
685 no_control_flow = false; break;
686 case Bytecodes::_bastore :
687 type = current_frame.pop_stack(
688 VerificationType::integer_type(), CHECK_VERIFY(this));
689 type2 = current_frame.pop_stack(
690 VerificationType::integer_type(), CHECK_VERIFY(this));
691 atype = current_frame.pop_stack(
692 VerificationType::reference_check(), CHECK_VERIFY(this));
693 if (!atype.is_bool_array() && !atype.is_byte_array()) {
694 verify_error(bci, bad_type_msg, "bastore");
695 return;
696 }
697 no_control_flow = false; break;
698 case Bytecodes::_castore :
699 current_frame.pop_stack(
700 VerificationType::integer_type(), CHECK_VERIFY(this));
701 current_frame.pop_stack(
702 VerificationType::integer_type(), CHECK_VERIFY(this));
703 atype = current_frame.pop_stack(
704 VerificationType::reference_check(), CHECK_VERIFY(this));
705 if (!atype.is_char_array()) {
706 verify_error(bci, bad_type_msg, "castore");
707 return;
708 }
709 no_control_flow = false; break;
710 case Bytecodes::_sastore :
711 current_frame.pop_stack(
712 VerificationType::integer_type(), CHECK_VERIFY(this));
713 current_frame.pop_stack(
714 VerificationType::integer_type(), CHECK_VERIFY(this));
715 atype = current_frame.pop_stack(
716 VerificationType::reference_check(), CHECK_VERIFY(this));
717 if (!atype.is_short_array()) {
718 verify_error(bci, bad_type_msg, "sastore");
719 return;
720 }
721 no_control_flow = false; break;
722 case Bytecodes::_lastore :
723 current_frame.pop_stack_2(
724 VerificationType::long2_type(),
725 VerificationType::long_type(), CHECK_VERIFY(this));
726 current_frame.pop_stack(
727 VerificationType::integer_type(), CHECK_VERIFY(this));
728 atype = current_frame.pop_stack(
729 VerificationType::reference_check(), CHECK_VERIFY(this));
730 if (!atype.is_long_array()) {
731 verify_error(bci, bad_type_msg, "lastore");
732 return;
733 }
734 no_control_flow = false; break;
735 case Bytecodes::_fastore :
736 current_frame.pop_stack(
737 VerificationType::float_type(), CHECK_VERIFY(this));
738 current_frame.pop_stack
739 (VerificationType::integer_type(), CHECK_VERIFY(this));
740 atype = current_frame.pop_stack(
741 VerificationType::reference_check(), CHECK_VERIFY(this));
742 if (!atype.is_float_array()) {
743 verify_error(bci, bad_type_msg, "fastore");
744 return;
745 }
746 no_control_flow = false; break;
747 case Bytecodes::_dastore :
748 current_frame.pop_stack_2(
749 VerificationType::double2_type(),
750 VerificationType::double_type(), CHECK_VERIFY(this));
751 current_frame.pop_stack(
752 VerificationType::integer_type(), CHECK_VERIFY(this));
753 atype = current_frame.pop_stack(
754 VerificationType::reference_check(), CHECK_VERIFY(this));
755 if (!atype.is_double_array()) {
756 verify_error(bci, bad_type_msg, "dastore");
757 return;
758 }
759 no_control_flow = false; break;
760 case Bytecodes::_aastore :
761 type = current_frame.pop_stack(object_type(), CHECK_VERIFY(this));
762 type2 = current_frame.pop_stack(
763 VerificationType::integer_type(), CHECK_VERIFY(this));
764 atype = current_frame.pop_stack(
765 VerificationType::reference_check(), CHECK_VERIFY(this));
766 // more type-checking is done at runtime
767 if (!atype.is_reference_array()) {
768 verify_error(bci, bad_type_msg, "aastore");
769 return;
770 }
771 // 4938384: relaxed constraint in JVMS 3nd edition.
772 no_control_flow = false; break;
773 case Bytecodes::_pop :
774 current_frame.pop_stack(
775 VerificationType::category1_check(), CHECK_VERIFY(this));
776 no_control_flow = false; break;
777 case Bytecodes::_pop2 :
778 type = current_frame.pop_stack(CHECK_VERIFY(this));
779 if (type.is_category1()) {
780 current_frame.pop_stack(
781 VerificationType::category1_check(), CHECK_VERIFY(this));
782 } else if (type.is_category2_2nd()) {
783 current_frame.pop_stack(
784 VerificationType::category2_check(), CHECK_VERIFY(this));
785 } else {
786 verify_error(bci, bad_type_msg, "pop2");
787 return;
788 }
789 no_control_flow = false; break;
790 case Bytecodes::_dup :
791 type = current_frame.pop_stack(
792 VerificationType::category1_check(), CHECK_VERIFY(this));
793 current_frame.push_stack(type, CHECK_VERIFY(this));
794 current_frame.push_stack(type, CHECK_VERIFY(this));
795 no_control_flow = false; break;
796 case Bytecodes::_dup_x1 :
797 type = current_frame.pop_stack(
798 VerificationType::category1_check(), CHECK_VERIFY(this));
799 type2 = current_frame.pop_stack(
800 VerificationType::category1_check(), CHECK_VERIFY(this));
801 current_frame.push_stack(type, CHECK_VERIFY(this));
802 current_frame.push_stack(type2, CHECK_VERIFY(this));
803 current_frame.push_stack(type, CHECK_VERIFY(this));
804 no_control_flow = false; break;
805 case Bytecodes::_dup_x2 :
806 {
807 VerificationType type3;
808 type = current_frame.pop_stack(
809 VerificationType::category1_check(), CHECK_VERIFY(this));
810 type2 = current_frame.pop_stack(CHECK_VERIFY(this));
811 if (type2.is_category1()) {
812 type3 = current_frame.pop_stack(
813 VerificationType::category1_check(), CHECK_VERIFY(this));
814 } else if (type2.is_category2_2nd()) {
815 type3 = current_frame.pop_stack(
816 VerificationType::category2_check(), CHECK_VERIFY(this));
817 } else {
818 verify_error(bci, bad_type_msg, "dup_x2");
819 return;
820 }
821 current_frame.push_stack(type, CHECK_VERIFY(this));
822 current_frame.push_stack(type3, CHECK_VERIFY(this));
823 current_frame.push_stack(type2, CHECK_VERIFY(this));
824 current_frame.push_stack(type, CHECK_VERIFY(this));
825 no_control_flow = false; break;
826 }
827 case Bytecodes::_dup2 :
828 type = current_frame.pop_stack(CHECK_VERIFY(this));
829 if (type.is_category1()) {
830 type2 = current_frame.pop_stack(
831 VerificationType::category1_check(), CHECK_VERIFY(this));
832 } else if (type.is_category2_2nd()) {
833 type2 = current_frame.pop_stack(
834 VerificationType::category2_check(), CHECK_VERIFY(this));
835 } else {
836 verify_error(bci, bad_type_msg, "dup2");
837 return;
838 }
839 current_frame.push_stack(type2, CHECK_VERIFY(this));
840 current_frame.push_stack(type, CHECK_VERIFY(this));
841 current_frame.push_stack(type2, CHECK_VERIFY(this));
842 current_frame.push_stack(type, CHECK_VERIFY(this));
843 no_control_flow = false; break;
844 case Bytecodes::_dup2_x1 :
845 {
846 VerificationType type3;
847 type = current_frame.pop_stack(CHECK_VERIFY(this));
848 if (type.is_category1()) {
849 type2 = current_frame.pop_stack(
850 VerificationType::category1_check(), CHECK_VERIFY(this));
851 } else if(type.is_category2_2nd()) {
852 type2 = current_frame.pop_stack
853 (VerificationType::category2_check(), CHECK_VERIFY(this));
854 } else {
855 verify_error(bci, bad_type_msg, "dup2_x1");
856 return;
857 }
858 type3 = current_frame.pop_stack(
859 VerificationType::category1_check(), CHECK_VERIFY(this));
860 current_frame.push_stack(type2, CHECK_VERIFY(this));
861 current_frame.push_stack(type, CHECK_VERIFY(this));
862 current_frame.push_stack(type3, CHECK_VERIFY(this));
863 current_frame.push_stack(type2, CHECK_VERIFY(this));
864 current_frame.push_stack(type, CHECK_VERIFY(this));
865 no_control_flow = false; break;
866 }
867 case Bytecodes::_dup2_x2 :
868 {
869 VerificationType type3, type4;
870 type = current_frame.pop_stack(CHECK_VERIFY(this));
871 if (type.is_category1()) {
872 type2 = current_frame.pop_stack(
873 VerificationType::category1_check(), CHECK_VERIFY(this));
874 } else if (type.is_category2_2nd()) {
875 type2 = current_frame.pop_stack(
876 VerificationType::category2_check(), CHECK_VERIFY(this));
877 } else {
878 verify_error(bci, bad_type_msg, "dup2_x2");
879 return;
880 }
881 type3 = current_frame.pop_stack(CHECK_VERIFY(this));
882 if (type3.is_category1()) {
883 type4 = current_frame.pop_stack(
884 VerificationType::category1_check(), CHECK_VERIFY(this));
885 } else if (type3.is_category2_2nd()) {
886 type4 = current_frame.pop_stack(
887 VerificationType::category2_check(), CHECK_VERIFY(this));
888 } else {
889 verify_error(bci, bad_type_msg, "dup2_x2");
890 return;
891 }
892 current_frame.push_stack(type2, CHECK_VERIFY(this));
893 current_frame.push_stack(type, CHECK_VERIFY(this));
894 current_frame.push_stack(type4, CHECK_VERIFY(this));
895 current_frame.push_stack(type3, CHECK_VERIFY(this));
896 current_frame.push_stack(type2, CHECK_VERIFY(this));
897 current_frame.push_stack(type, CHECK_VERIFY(this));
898 no_control_flow = false; break;
899 }
900 case Bytecodes::_swap :
901 type = current_frame.pop_stack(
902 VerificationType::category1_check(), CHECK_VERIFY(this));
903 type2 = current_frame.pop_stack(
904 VerificationType::category1_check(), CHECK_VERIFY(this));
905 current_frame.push_stack(type, CHECK_VERIFY(this));
906 current_frame.push_stack(type2, CHECK_VERIFY(this));
907 no_control_flow = false; break;
908 case Bytecodes::_iadd :
909 case Bytecodes::_isub :
910 case Bytecodes::_imul :
911 case Bytecodes::_idiv :
912 case Bytecodes::_irem :
913 case Bytecodes::_ishl :
914 case Bytecodes::_ishr :
915 case Bytecodes::_iushr :
916 case Bytecodes::_ior :
917 case Bytecodes::_ixor :
918 case Bytecodes::_iand :
919 current_frame.pop_stack(
920 VerificationType::integer_type(), CHECK_VERIFY(this));
921 // fall through
922 case Bytecodes::_ineg :
923 current_frame.pop_stack(
924 VerificationType::integer_type(), CHECK_VERIFY(this));
925 current_frame.push_stack(
926 VerificationType::integer_type(), CHECK_VERIFY(this));
927 no_control_flow = false; break;
928 case Bytecodes::_ladd :
929 case Bytecodes::_lsub :
930 case Bytecodes::_lmul :
931 case Bytecodes::_ldiv :
932 case Bytecodes::_lrem :
933 case Bytecodes::_land :
934 case Bytecodes::_lor :
935 case Bytecodes::_lxor :
936 current_frame.pop_stack_2(
937 VerificationType::long2_type(),
938 VerificationType::long_type(), CHECK_VERIFY(this));
939 // fall through
940 case Bytecodes::_lneg :
941 current_frame.pop_stack_2(
942 VerificationType::long2_type(),
943 VerificationType::long_type(), CHECK_VERIFY(this));
944 current_frame.push_stack_2(
945 VerificationType::long_type(),
946 VerificationType::long2_type(), CHECK_VERIFY(this));
947 no_control_flow = false; break;
948 case Bytecodes::_lshl :
949 case Bytecodes::_lshr :
950 case Bytecodes::_lushr :
951 current_frame.pop_stack(
952 VerificationType::integer_type(), CHECK_VERIFY(this));
953 current_frame.pop_stack_2(
954 VerificationType::long2_type(),
955 VerificationType::long_type(), CHECK_VERIFY(this));
956 current_frame.push_stack_2(
957 VerificationType::long_type(),
958 VerificationType::long2_type(), CHECK_VERIFY(this));
959 no_control_flow = false; break;
960 case Bytecodes::_fadd :
961 case Bytecodes::_fsub :
962 case Bytecodes::_fmul :
963 case Bytecodes::_fdiv :
964 case Bytecodes::_frem :
965 current_frame.pop_stack(
966 VerificationType::float_type(), CHECK_VERIFY(this));
967 // fall through
968 case Bytecodes::_fneg :
969 current_frame.pop_stack(
970 VerificationType::float_type(), CHECK_VERIFY(this));
971 current_frame.push_stack(
972 VerificationType::float_type(), CHECK_VERIFY(this));
973 no_control_flow = false; break;
974 case Bytecodes::_dadd :
975 case Bytecodes::_dsub :
976 case Bytecodes::_dmul :
977 case Bytecodes::_ddiv :
978 case Bytecodes::_drem :
979 current_frame.pop_stack_2(
980 VerificationType::double2_type(),
981 VerificationType::double_type(), CHECK_VERIFY(this));
982 // fall through
983 case Bytecodes::_dneg :
984 current_frame.pop_stack_2(
985 VerificationType::double2_type(),
986 VerificationType::double_type(), CHECK_VERIFY(this));
987 current_frame.push_stack_2(
988 VerificationType::double_type(),
989 VerificationType::double2_type(), CHECK_VERIFY(this));
990 no_control_flow = false; break;
991 case Bytecodes::_iinc :
992 verify_iinc(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this));
993 no_control_flow = false; break;
994 case Bytecodes::_i2l :
995 type = current_frame.pop_stack(
996 VerificationType::integer_type(), CHECK_VERIFY(this));
997 current_frame.push_stack_2(
998 VerificationType::long_type(),
999 VerificationType::long2_type(), CHECK_VERIFY(this));
1000 no_control_flow = false; break;
1001 case Bytecodes::_l2i :
1002 current_frame.pop_stack_2(
1003 VerificationType::long2_type(),
1004 VerificationType::long_type(), CHECK_VERIFY(this));
1005 current_frame.push_stack(
1006 VerificationType::integer_type(), CHECK_VERIFY(this));
1007 no_control_flow = false; break;
1008 case Bytecodes::_i2f :
1009 current_frame.pop_stack(
1010 VerificationType::integer_type(), CHECK_VERIFY(this));
1011 current_frame.push_stack(
1012 VerificationType::float_type(), CHECK_VERIFY(this));
1013 no_control_flow = false; break;
1014 case Bytecodes::_i2d :
1015 current_frame.pop_stack(
1016 VerificationType::integer_type(), CHECK_VERIFY(this));
1017 current_frame.push_stack_2(
1018 VerificationType::double_type(),
1019 VerificationType::double2_type(), CHECK_VERIFY(this));
1020 no_control_flow = false; break;
1021 case Bytecodes::_l2f :
1022 current_frame.pop_stack_2(
1023 VerificationType::long2_type(),
1024 VerificationType::long_type(), CHECK_VERIFY(this));
1025 current_frame.push_stack(
1026 VerificationType::float_type(), CHECK_VERIFY(this));
1027 no_control_flow = false; break;
1028 case Bytecodes::_l2d :
1029 current_frame.pop_stack_2(
1030 VerificationType::long2_type(),
1031 VerificationType::long_type(), CHECK_VERIFY(this));
1032 current_frame.push_stack_2(
1033 VerificationType::double_type(),
1034 VerificationType::double2_type(), CHECK_VERIFY(this));
1035 no_control_flow = false; break;
1036 case Bytecodes::_f2i :
1037 current_frame.pop_stack(
1038 VerificationType::float_type(), CHECK_VERIFY(this));
1039 current_frame.push_stack(
1040 VerificationType::integer_type(), CHECK_VERIFY(this));
1041 no_control_flow = false; break;
1042 case Bytecodes::_f2l :
1043 current_frame.pop_stack(
1044 VerificationType::float_type(), CHECK_VERIFY(this));
1045 current_frame.push_stack_2(
1046 VerificationType::long_type(),
1047 VerificationType::long2_type(), CHECK_VERIFY(this));
1048 no_control_flow = false; break;
1049 case Bytecodes::_f2d :
1050 current_frame.pop_stack(
1051 VerificationType::float_type(), CHECK_VERIFY(this));
1052 current_frame.push_stack_2(
1053 VerificationType::double_type(),
1054 VerificationType::double2_type(), CHECK_VERIFY(this));
1055 no_control_flow = false; break;
1056 case Bytecodes::_d2i :
1057 current_frame.pop_stack_2(
1058 VerificationType::double2_type(),
1059 VerificationType::double_type(), CHECK_VERIFY(this));
1060 current_frame.push_stack(
1061 VerificationType::integer_type(), CHECK_VERIFY(this));
1062 no_control_flow = false; break;
1063 case Bytecodes::_d2l :
1064 current_frame.pop_stack_2(
1065 VerificationType::double2_type(),
1066 VerificationType::double_type(), CHECK_VERIFY(this));
1067 current_frame.push_stack_2(
1068 VerificationType::long_type(),
1069 VerificationType::long2_type(), CHECK_VERIFY(this));
1070 no_control_flow = false; break;
1071 case Bytecodes::_d2f :
1072 current_frame.pop_stack_2(
1073 VerificationType::double2_type(),
1074 VerificationType::double_type(), CHECK_VERIFY(this));
1075 current_frame.push_stack(
1076 VerificationType::float_type(), CHECK_VERIFY(this));
1077 no_control_flow = false; break;
1078 case Bytecodes::_i2b :
1079 case Bytecodes::_i2c :
1080 case Bytecodes::_i2s :
1081 current_frame.pop_stack(
1082 VerificationType::integer_type(), CHECK_VERIFY(this));
1083 current_frame.push_stack(
1084 VerificationType::integer_type(), CHECK_VERIFY(this));
1085 no_control_flow = false; break;
1086 case Bytecodes::_lcmp :
1087 current_frame.pop_stack_2(
1088 VerificationType::long2_type(),
1089 VerificationType::long_type(), CHECK_VERIFY(this));
1090 current_frame.pop_stack_2(
1091 VerificationType::long2_type(),
1092 VerificationType::long_type(), CHECK_VERIFY(this));
1093 current_frame.push_stack(
1094 VerificationType::integer_type(), CHECK_VERIFY(this));
1095 no_control_flow = false; break;
1096 case Bytecodes::_fcmpl :
1097 case Bytecodes::_fcmpg :
1098 current_frame.pop_stack(
1099 VerificationType::float_type(), CHECK_VERIFY(this));
1100 current_frame.pop_stack(
1101 VerificationType::float_type(), CHECK_VERIFY(this));
1102 current_frame.push_stack(
1103 VerificationType::integer_type(), CHECK_VERIFY(this));
1104 no_control_flow = false; break;
1105 case Bytecodes::_dcmpl :
1106 case Bytecodes::_dcmpg :
1107 current_frame.pop_stack_2(
1108 VerificationType::double2_type(),
1109 VerificationType::double_type(), CHECK_VERIFY(this));
1110 current_frame.pop_stack_2(
1111 VerificationType::double2_type(),
1112 VerificationType::double_type(), CHECK_VERIFY(this));
1113 current_frame.push_stack(
1114 VerificationType::integer_type(), CHECK_VERIFY(this));
1115 no_control_flow = false; break;
1116 case Bytecodes::_if_icmpeq:
1117 case Bytecodes::_if_icmpne:
1118 case Bytecodes::_if_icmplt:
1119 case Bytecodes::_if_icmpge:
1120 case Bytecodes::_if_icmpgt:
1121 case Bytecodes::_if_icmple:
1122 current_frame.pop_stack(
1123 VerificationType::integer_type(), CHECK_VERIFY(this));
1124 // fall through
1125 case Bytecodes::_ifeq:
1126 case Bytecodes::_ifne:
1127 case Bytecodes::_iflt:
1128 case Bytecodes::_ifge:
1129 case Bytecodes::_ifgt:
1130 case Bytecodes::_ifle:
1131 current_frame.pop_stack(
1132 VerificationType::integer_type(), CHECK_VERIFY(this));
1133 target = bcs.dest();
1134 stackmap_table.check_jump_target(
1135 ¤t_frame, target, CHECK_VERIFY(this));
1136 no_control_flow = false; break;
1137 case Bytecodes::_if_acmpeq :
1138 case Bytecodes::_if_acmpne :
1139 current_frame.pop_stack(
1140 VerificationType::reference_check(), CHECK_VERIFY(this));
1141 // fall through
1142 case Bytecodes::_ifnull :
1143 case Bytecodes::_ifnonnull :
1144 current_frame.pop_stack(
1145 VerificationType::reference_check(), CHECK_VERIFY(this));
1146 target = bcs.dest();
1147 stackmap_table.check_jump_target
1148 (¤t_frame, target, CHECK_VERIFY(this));
1149 no_control_flow = false; break;
1150 case Bytecodes::_goto :
1151 target = bcs.dest();
1152 stackmap_table.check_jump_target(
1153 ¤t_frame, target, CHECK_VERIFY(this));
1154 no_control_flow = true; break;
1155 case Bytecodes::_goto_w :
1156 target = bcs.dest_w();
1157 stackmap_table.check_jump_target(
1158 ¤t_frame, target, CHECK_VERIFY(this));
1159 no_control_flow = true; break;
1160 case Bytecodes::_tableswitch :
1161 case Bytecodes::_lookupswitch :
1162 verify_switch(
1163 &bcs, code_length, code_data, ¤t_frame,
1164 &stackmap_table, CHECK_VERIFY(this));
1165 no_control_flow = true; break;
1166 case Bytecodes::_ireturn :
1167 type = current_frame.pop_stack(
1168 VerificationType::integer_type(), CHECK_VERIFY(this));
1169 verify_return_value(return_type, type, bci, CHECK_VERIFY(this));
1170 no_control_flow = true; break;
1171 case Bytecodes::_lreturn :
1172 type2 = current_frame.pop_stack(
1173 VerificationType::long2_type(), CHECK_VERIFY(this));
1174 type = current_frame.pop_stack(
1175 VerificationType::long_type(), CHECK_VERIFY(this));
1176 verify_return_value(return_type, type, bci, CHECK_VERIFY(this));
1177 no_control_flow = true; break;
1178 case Bytecodes::_freturn :
1179 type = current_frame.pop_stack(
1180 VerificationType::float_type(), CHECK_VERIFY(this));
1181 verify_return_value(return_type, type, bci, CHECK_VERIFY(this));
1182 no_control_flow = true; break;
1183 case Bytecodes::_dreturn :
1184 type2 = current_frame.pop_stack(
1185 VerificationType::double2_type(), CHECK_VERIFY(this));
1186 type = current_frame.pop_stack(
1187 VerificationType::double_type(), CHECK_VERIFY(this));
1188 verify_return_value(return_type, type, bci, CHECK_VERIFY(this));
1189 no_control_flow = true; break;
1190 case Bytecodes::_areturn :
1191 type = current_frame.pop_stack(
1192 VerificationType::reference_check(), CHECK_VERIFY(this));
1193 verify_return_value(return_type, type, bci, CHECK_VERIFY(this));
1194 no_control_flow = true; break;
1195 case Bytecodes::_return :
1196 if (return_type != VerificationType::bogus_type()) {
1197 verify_error(bci, "Method expects no return value");
1198 return;
1199 }
1200 // Make sure "this" has been initialized if current method is an
1201 // <init>
1202 if (_method->name() == vmSymbols::object_initializer_name() &&
1203 current_frame.flag_this_uninit()) {
1204 verify_error(bci,
1205 "Constructor must call super() or this() before return");
1206 return;
1207 }
1208 no_control_flow = true; break;
1209 case Bytecodes::_getstatic :
1210 case Bytecodes::_putstatic :
1211 case Bytecodes::_getfield :
1212 case Bytecodes::_putfield :
1213 verify_field_instructions(
1214 &bcs, ¤t_frame, cp, CHECK_VERIFY(this));
1215 no_control_flow = false; break;
1216 case Bytecodes::_invokevirtual :
1217 case Bytecodes::_invokespecial :
1218 case Bytecodes::_invokestatic :
1219 verify_invoke_instructions(
1220 &bcs, code_length, ¤t_frame,
1221 &this_uninit, return_type, cp, CHECK_VERIFY(this));
1222 no_control_flow = false; break;
1223 case Bytecodes::_invokeinterface :
1224 case Bytecodes::_invokedynamic :
1225 verify_invoke_instructions(
1226 &bcs, code_length, ¤t_frame,
1227 &this_uninit, return_type, cp, CHECK_VERIFY(this));
1228 no_control_flow = false; break;
1229 case Bytecodes::_new :
1230 {
1231 index = bcs.get_index_u2();
1232 verify_cp_class_type(index, cp, CHECK_VERIFY(this));
1233 VerificationType new_class_type =
1234 cp_index_to_type(index, cp, CHECK_VERIFY(this));
1235 if (!new_class_type.is_object()) {
1236 verify_error(bci, "Illegal new instruction");
1237 return;
1238 }
1239 type = VerificationType::uninitialized_type(bci);
1240 current_frame.push_stack(type, CHECK_VERIFY(this));
1241 no_control_flow = false; break;
1242 }
1243 case Bytecodes::_newarray :
1244 type = get_newarray_type(bcs.get_index(), bci, CHECK_VERIFY(this));
1245 current_frame.pop_stack(
1246 VerificationType::integer_type(), CHECK_VERIFY(this));
1247 current_frame.push_stack(type, CHECK_VERIFY(this));
1248 no_control_flow = false; break;
1249 case Bytecodes::_anewarray :
1250 verify_anewarray(
1251 bcs.get_index_u2(), cp, ¤t_frame, CHECK_VERIFY(this));
1252 no_control_flow = false; break;
1253 case Bytecodes::_arraylength :
1254 type = current_frame.pop_stack(
1255 VerificationType::reference_check(), CHECK_VERIFY(this));
1256 if (!(type.is_null() || type.is_array())) {
1257 verify_error(bci, bad_type_msg, "arraylength");
1258 }
1259 current_frame.push_stack(
1260 VerificationType::integer_type(), CHECK_VERIFY(this));
1261 no_control_flow = false; break;
1262 case Bytecodes::_checkcast :
1263 {
1264 index = bcs.get_index_u2();
1265 verify_cp_class_type(index, cp, CHECK_VERIFY(this));
1266 current_frame.pop_stack(object_type(), CHECK_VERIFY(this));
1267 VerificationType klass_type = cp_index_to_type(
1268 index, cp, CHECK_VERIFY(this));
1269 current_frame.push_stack(klass_type, CHECK_VERIFY(this));
1270 no_control_flow = false; break;
1271 }
1272 case Bytecodes::_instanceof : {
1273 index = bcs.get_index_u2();
1274 verify_cp_class_type(index, cp, CHECK_VERIFY(this));
1275 current_frame.pop_stack(object_type(), CHECK_VERIFY(this));
1276 current_frame.push_stack(
1277 VerificationType::integer_type(), CHECK_VERIFY(this));
1278 no_control_flow = false; break;
1279 }
1280 case Bytecodes::_monitorenter :
1281 case Bytecodes::_monitorexit :
1282 current_frame.pop_stack(
1283 VerificationType::reference_check(), CHECK_VERIFY(this));
1284 no_control_flow = false; break;
1285 case Bytecodes::_multianewarray :
1286 {
1287 index = bcs.get_index_u2();
1288 u2 dim = *(bcs.bcp()+3);
1289 verify_cp_class_type(index, cp, CHECK_VERIFY(this));
1290 VerificationType new_array_type =
1291 cp_index_to_type(index, cp, CHECK_VERIFY(this));
1292 if (!new_array_type.is_array()) {
1293 verify_error(bci,
1294 "Illegal constant pool index in multianewarray instruction");
1295 return;
1296 }
1297 if (dim < 1 || new_array_type.dimensions() < dim) {
1298 verify_error(bci,
1299 "Illegal dimension in multianewarray instruction");
1300 return;
1301 }
1302 for (int i = 0; i < dim; i++) {
1303 current_frame.pop_stack(
1304 VerificationType::integer_type(), CHECK_VERIFY(this));
1305 }
1306 current_frame.push_stack(new_array_type, CHECK_VERIFY(this));
1307 no_control_flow = false; break;
1308 }
1309 case Bytecodes::_athrow :
1310 type = VerificationType::reference_type(
1311 vmSymbols::java_lang_Throwable());
1312 current_frame.pop_stack(type, CHECK_VERIFY(this));
1313 no_control_flow = true; break;
1314 default:
1315 // We only need to check the valid bytecodes in class file.
1316 // And jsr and ret are not in the new class file format in JDK1.5.
1317 verify_error(bci, "Bad instruction");
1318 no_control_flow = false;
1319 return;
1320 } // end switch
1321 } // end Merge with the next instruction
1323 // Look for possible jump target in exception handlers and see if it
1324 // matches current_frame
1325 if (bci >= ex_min && bci < ex_max) {
1326 verify_exception_handler_targets(
1327 bci, this_uninit, ¤t_frame, &stackmap_table, CHECK_VERIFY(this));
1328 }
1329 } // end while
1331 // Make sure that control flow does not fall through end of the method
1332 if (!no_control_flow) {
1333 verify_error(code_length, "Control flow falls through code end");
1334 return;
1335 }
1336 }
1338 char* ClassVerifier::generate_code_data(methodHandle m, u4 code_length, TRAPS) {
1339 char* code_data = NEW_RESOURCE_ARRAY(char, code_length);
1340 memset(code_data, 0, sizeof(char) * code_length);
1341 RawBytecodeStream bcs(m);
1343 while (!bcs.is_last_bytecode()) {
1344 if (bcs.raw_next() != Bytecodes::_illegal) {
1345 int bci = bcs.bci();
1346 if (bcs.raw_code() == Bytecodes::_new) {
1347 code_data[bci] = NEW_OFFSET;
1348 } else {
1349 code_data[bci] = BYTECODE_OFFSET;
1350 }
1351 } else {
1352 verify_error(bcs.bci(), "Bad instruction");
1353 return NULL;
1354 }
1355 }
1357 return code_data;
1358 }
1360 void ClassVerifier::verify_exception_handler_table(u4 code_length, char* code_data, int& min, int& max, TRAPS) {
1361 typeArrayHandle exhandlers (THREAD, _method->exception_table());
1362 constantPoolHandle cp (THREAD, _method->constants());
1364 if (exhandlers() != NULL) {
1365 for(int i = 0; i < exhandlers->length();) {
1366 u2 start_pc = exhandlers->int_at(i++);
1367 u2 end_pc = exhandlers->int_at(i++);
1368 u2 handler_pc = exhandlers->int_at(i++);
1369 if (start_pc >= code_length || code_data[start_pc] == 0) {
1370 class_format_error("Illegal exception table start_pc %d", start_pc);
1371 return;
1372 }
1373 if (end_pc != code_length) { // special case: end_pc == code_length
1374 if (end_pc > code_length || code_data[end_pc] == 0) {
1375 class_format_error("Illegal exception table end_pc %d", end_pc);
1376 return;
1377 }
1378 }
1379 if (handler_pc >= code_length || code_data[handler_pc] == 0) {
1380 class_format_error("Illegal exception table handler_pc %d", handler_pc);
1381 return;
1382 }
1383 int catch_type_index = exhandlers->int_at(i++);
1384 if (catch_type_index != 0) {
1385 VerificationType catch_type = cp_index_to_type(
1386 catch_type_index, cp, CHECK_VERIFY(this));
1387 VerificationType throwable =
1388 VerificationType::reference_type(vmSymbols::java_lang_Throwable());
1389 bool is_subclass = throwable.is_assignable_from(
1390 catch_type, current_class(), CHECK_VERIFY(this));
1391 if (!is_subclass) {
1392 // 4286534: should throw VerifyError according to recent spec change
1393 verify_error(
1394 "Catch type is not a subclass of Throwable in handler %d",
1395 handler_pc);
1396 return;
1397 }
1398 }
1399 if (start_pc < min) min = start_pc;
1400 if (end_pc > max) max = end_pc;
1401 }
1402 }
1403 }
1405 void ClassVerifier::verify_local_variable_table(u4 code_length, char* code_data, TRAPS) {
1406 int localvariable_table_length = _method()->localvariable_table_length();
1407 if (localvariable_table_length > 0) {
1408 LocalVariableTableElement* table = _method()->localvariable_table_start();
1409 for (int i = 0; i < localvariable_table_length; i++) {
1410 u2 start_bci = table[i].start_bci;
1411 u2 length = table[i].length;
1413 if (start_bci >= code_length || code_data[start_bci] == 0) {
1414 class_format_error(
1415 "Illegal local variable table start_pc %d", start_bci);
1416 return;
1417 }
1418 u4 end_bci = (u4)(start_bci + length);
1419 if (end_bci != code_length) {
1420 if (end_bci >= code_length || code_data[end_bci] == 0) {
1421 class_format_error( "Illegal local variable table length %d", length);
1422 return;
1423 }
1424 }
1425 }
1426 }
1427 }
1429 u2 ClassVerifier::verify_stackmap_table(u2 stackmap_index, u2 bci,
1430 StackMapFrame* current_frame,
1431 StackMapTable* stackmap_table,
1432 bool no_control_flow, TRAPS) {
1433 if (stackmap_index < stackmap_table->get_frame_count()) {
1434 u2 this_offset = stackmap_table->get_offset(stackmap_index);
1435 if (no_control_flow && this_offset > bci) {
1436 verify_error(bci, "Expecting a stack map frame");
1437 return 0;
1438 }
1439 if (this_offset == bci) {
1440 // See if current stack map can be assigned to the frame in table.
1441 // current_frame is the stackmap frame got from the last instruction.
1442 // If matched, current_frame will be updated by this method.
1443 bool match = stackmap_table->match_stackmap(
1444 current_frame, this_offset, stackmap_index,
1445 !no_control_flow, true, CHECK_VERIFY_(this, 0));
1446 if (!match) {
1447 // report type error
1448 verify_error(bci, "Instruction type does not match stack map");
1449 return 0;
1450 }
1451 stackmap_index++;
1452 } else if (this_offset < bci) {
1453 // current_offset should have met this_offset.
1454 class_format_error("Bad stack map offset %d", this_offset);
1455 return 0;
1456 }
1457 } else if (no_control_flow) {
1458 verify_error(bci, "Expecting a stack map frame");
1459 return 0;
1460 }
1461 return stackmap_index;
1462 }
1464 void ClassVerifier::verify_exception_handler_targets(u2 bci, bool this_uninit, StackMapFrame* current_frame,
1465 StackMapTable* stackmap_table, TRAPS) {
1466 constantPoolHandle cp (THREAD, _method->constants());
1467 typeArrayHandle exhandlers (THREAD, _method->exception_table());
1468 if (exhandlers() != NULL) {
1469 for(int i = 0; i < exhandlers->length();) {
1470 u2 start_pc = exhandlers->int_at(i++);
1471 u2 end_pc = exhandlers->int_at(i++);
1472 u2 handler_pc = exhandlers->int_at(i++);
1473 int catch_type_index = exhandlers->int_at(i++);
1474 if(bci >= start_pc && bci < end_pc) {
1475 u1 flags = current_frame->flags();
1476 if (this_uninit) { flags |= FLAG_THIS_UNINIT; }
1478 ResourceMark rm(THREAD);
1479 StackMapFrame* new_frame = current_frame->frame_in_exception_handler(flags);
1480 if (catch_type_index != 0) {
1481 // We know that this index refers to a subclass of Throwable
1482 VerificationType catch_type = cp_index_to_type(
1483 catch_type_index, cp, CHECK_VERIFY(this));
1484 new_frame->push_stack(catch_type, CHECK_VERIFY(this));
1485 } else {
1486 VerificationType throwable =
1487 VerificationType::reference_type(vmSymbols::java_lang_Throwable());
1488 new_frame->push_stack(throwable, CHECK_VERIFY(this));
1489 }
1490 bool match = stackmap_table->match_stackmap(
1491 new_frame, handler_pc, true, false, CHECK_VERIFY(this));
1492 if (!match) {
1493 verify_error(bci,
1494 "Stack map does not match the one at exception handler %d",
1495 handler_pc);
1496 return;
1497 }
1498 }
1499 }
1500 }
1501 }
1503 void ClassVerifier::verify_cp_index(constantPoolHandle cp, int index, TRAPS) {
1504 int nconstants = cp->length();
1505 if ((index <= 0) || (index >= nconstants)) {
1506 verify_error("Illegal constant pool index %d in class %s",
1507 index, instanceKlass::cast(cp->pool_holder())->external_name());
1508 return;
1509 }
1510 }
1512 void ClassVerifier::verify_cp_type(
1513 int index, constantPoolHandle cp, unsigned int types, TRAPS) {
1515 // In some situations, bytecode rewriting may occur while we're verifying.
1516 // In this case, a constant pool cache exists and some indices refer to that
1517 // instead. Be sure we don't pick up such indices by accident.
1518 // We must check was_recursively_verified() before we get here.
1519 guarantee(cp->cache() == NULL, "not rewritten yet");
1521 verify_cp_index(cp, index, CHECK_VERIFY(this));
1522 unsigned int tag = cp->tag_at(index).value();
1523 if ((types & (1 << tag)) == 0) {
1524 verify_error(
1525 "Illegal type at constant pool entry %d in class %s",
1526 index, instanceKlass::cast(cp->pool_holder())->external_name());
1527 return;
1528 }
1529 }
1531 void ClassVerifier::verify_cp_class_type(
1532 int index, constantPoolHandle cp, TRAPS) {
1533 verify_cp_index(cp, index, CHECK_VERIFY(this));
1534 constantTag tag = cp->tag_at(index);
1535 if (!tag.is_klass() && !tag.is_unresolved_klass()) {
1536 verify_error("Illegal type at constant pool entry %d in class %s",
1537 index, instanceKlass::cast(cp->pool_holder())->external_name());
1538 return;
1539 }
1540 }
1542 void ClassVerifier::format_error_message(
1543 const char* fmt, int offset, va_list va) {
1544 ResourceMark rm(_thread);
1545 stringStream message(_message, _message_buffer_len);
1546 message.vprint(fmt, va);
1547 if (!_method.is_null()) {
1548 message.print(" in method %s", _method->name_and_sig_as_C_string());
1549 }
1550 if (offset != -1) {
1551 message.print(" at offset %d", offset);
1552 }
1553 }
1555 void ClassVerifier::verify_error(u2 offset, const char* fmt, ...) {
1556 _exception_type = vmSymbols::java_lang_VerifyError();
1557 va_list va;
1558 va_start(va, fmt);
1559 format_error_message(fmt, offset, va);
1560 va_end(va);
1561 }
1563 void ClassVerifier::verify_error(const char* fmt, ...) {
1564 _exception_type = vmSymbols::java_lang_VerifyError();
1565 va_list va;
1566 va_start(va, fmt);
1567 format_error_message(fmt, -1, va);
1568 va_end(va);
1569 }
1571 void ClassVerifier::class_format_error(const char* msg, ...) {
1572 _exception_type = vmSymbols::java_lang_ClassFormatError();
1573 va_list va;
1574 va_start(va, msg);
1575 format_error_message(msg, -1, va);
1576 va_end(va);
1577 }
1579 klassOop ClassVerifier::load_class(symbolHandle name, TRAPS) {
1580 // Get current loader and protection domain first.
1581 oop loader = current_class()->class_loader();
1582 oop protection_domain = current_class()->protection_domain();
1584 return SystemDictionary::resolve_or_fail(
1585 name, Handle(THREAD, loader), Handle(THREAD, protection_domain),
1586 true, CHECK_NULL);
1587 }
1589 bool ClassVerifier::is_protected_access(instanceKlassHandle this_class,
1590 klassOop target_class,
1591 symbolOop field_name,
1592 symbolOop field_sig,
1593 bool is_method) {
1594 No_Safepoint_Verifier nosafepoint;
1596 // If target class isn't a super class of this class, we don't worry about this case
1597 if (!this_class->is_subclass_of(target_class)) {
1598 return false;
1599 }
1600 // Check if the specified method or field is protected
1601 instanceKlass* target_instance = instanceKlass::cast(target_class);
1602 fieldDescriptor fd;
1603 if (is_method) {
1604 methodOop m = target_instance->uncached_lookup_method(field_name, field_sig);
1605 if (m != NULL && m->is_protected()) {
1606 if (!this_class->is_same_class_package(m->method_holder())) {
1607 return true;
1608 }
1609 }
1610 } else {
1611 klassOop member_klass = target_instance->find_field(field_name, field_sig, &fd);
1612 if(member_klass != NULL && fd.is_protected()) {
1613 if (!this_class->is_same_class_package(member_klass)) {
1614 return true;
1615 }
1616 }
1617 }
1618 return false;
1619 }
1621 void ClassVerifier::verify_ldc(
1622 int opcode, u2 index, StackMapFrame *current_frame,
1623 constantPoolHandle cp, u2 bci, TRAPS) {
1624 verify_cp_index(cp, index, CHECK_VERIFY(this));
1625 constantTag tag = cp->tag_at(index);
1626 unsigned int types;
1627 if (opcode == Bytecodes::_ldc || opcode == Bytecodes::_ldc_w) {
1628 if (!tag.is_unresolved_string() && !tag.is_unresolved_klass()) {
1629 types = (1 << JVM_CONSTANT_Integer) | (1 << JVM_CONSTANT_Float)
1630 | (1 << JVM_CONSTANT_String) | (1 << JVM_CONSTANT_Class)
1631 | (1 << JVM_CONSTANT_MethodHandle) | (1 << JVM_CONSTANT_MethodType);
1632 // Note: The class file parser already verified the legality of
1633 // MethodHandle and MethodType constants.
1634 verify_cp_type(index, cp, types, CHECK_VERIFY(this));
1635 }
1636 } else {
1637 assert(opcode == Bytecodes::_ldc2_w, "must be ldc2_w");
1638 types = (1 << JVM_CONSTANT_Double) | (1 << JVM_CONSTANT_Long);
1639 verify_cp_type(index, cp, types, CHECK_VERIFY(this));
1640 }
1641 if (tag.is_string() && cp->is_pseudo_string_at(index)) {
1642 current_frame->push_stack(object_type(), CHECK_VERIFY(this));
1643 } else if (tag.is_string() || tag.is_unresolved_string()) {
1644 current_frame->push_stack(
1645 VerificationType::reference_type(
1646 vmSymbols::java_lang_String()), CHECK_VERIFY(this));
1647 } else if (tag.is_klass() || tag.is_unresolved_klass()) {
1648 current_frame->push_stack(
1649 VerificationType::reference_type(
1650 vmSymbols::java_lang_Class()), CHECK_VERIFY(this));
1651 } else if (tag.is_int()) {
1652 current_frame->push_stack(
1653 VerificationType::integer_type(), CHECK_VERIFY(this));
1654 } else if (tag.is_float()) {
1655 current_frame->push_stack(
1656 VerificationType::float_type(), CHECK_VERIFY(this));
1657 } else if (tag.is_double()) {
1658 current_frame->push_stack_2(
1659 VerificationType::double_type(),
1660 VerificationType::double2_type(), CHECK_VERIFY(this));
1661 } else if (tag.is_long()) {
1662 current_frame->push_stack_2(
1663 VerificationType::long_type(),
1664 VerificationType::long2_type(), CHECK_VERIFY(this));
1665 } else if (tag.is_method_handle()) {
1666 current_frame->push_stack(
1667 VerificationType::reference_type(
1668 vmSymbols::java_dyn_MethodHandle()), CHECK_VERIFY(this));
1669 } else if (tag.is_method_type()) {
1670 current_frame->push_stack(
1671 VerificationType::reference_type(
1672 vmSymbols::java_dyn_MethodType()), CHECK_VERIFY(this));
1673 } else {
1674 verify_error(bci, "Invalid index in ldc");
1675 return;
1676 }
1677 }
1679 void ClassVerifier::verify_switch(
1680 RawBytecodeStream* bcs, u4 code_length, char* code_data,
1681 StackMapFrame* current_frame, StackMapTable* stackmap_table, TRAPS) {
1682 int bci = bcs->bci();
1683 address bcp = bcs->bcp();
1684 address aligned_bcp = (address) round_to((intptr_t)(bcp + 1), jintSize);
1686 // 4639449 & 4647081: padding bytes must be 0
1687 u2 padding_offset = 1;
1688 while ((bcp + padding_offset) < aligned_bcp) {
1689 if(*(bcp + padding_offset) != 0) {
1690 verify_error(bci, "Nonzero padding byte in lookswitch or tableswitch");
1691 return;
1692 }
1693 padding_offset++;
1694 }
1695 int default_offset = (int) Bytes::get_Java_u4(aligned_bcp);
1696 int keys, delta;
1697 current_frame->pop_stack(
1698 VerificationType::integer_type(), CHECK_VERIFY(this));
1699 if (bcs->raw_code() == Bytecodes::_tableswitch) {
1700 jint low = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize);
1701 jint high = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize);
1702 if (low > high) {
1703 verify_error(bci,
1704 "low must be less than or equal to high in tableswitch");
1705 return;
1706 }
1707 keys = high - low + 1;
1708 if (keys < 0) {
1709 verify_error(bci, "too many keys in tableswitch");
1710 return;
1711 }
1712 delta = 1;
1713 } else {
1714 keys = (int)Bytes::get_Java_u4(aligned_bcp + jintSize);
1715 if (keys < 0) {
1716 verify_error(bci, "number of keys in lookupswitch less than 0");
1717 return;
1718 }
1719 delta = 2;
1720 // Make sure that the lookupswitch items are sorted
1721 for (int i = 0; i < (keys - 1); i++) {
1722 jint this_key = Bytes::get_Java_u4(aligned_bcp + (2+2*i)*jintSize);
1723 jint next_key = Bytes::get_Java_u4(aligned_bcp + (2+2*i+2)*jintSize);
1724 if (this_key >= next_key) {
1725 verify_error(bci, "Bad lookupswitch instruction");
1726 return;
1727 }
1728 }
1729 }
1730 int target = bci + default_offset;
1731 stackmap_table->check_jump_target(current_frame, target, CHECK_VERIFY(this));
1732 for (int i = 0; i < keys; i++) {
1733 target = bci + (jint)Bytes::get_Java_u4(aligned_bcp+(3+i*delta)*jintSize);
1734 stackmap_table->check_jump_target(
1735 current_frame, target, CHECK_VERIFY(this));
1736 }
1737 }
1739 bool ClassVerifier::name_in_supers(
1740 symbolOop ref_name, instanceKlassHandle current) {
1741 klassOop super = current->super();
1742 while (super != NULL) {
1743 if (super->klass_part()->name() == ref_name) {
1744 return true;
1745 }
1746 super = super->klass_part()->super();
1747 }
1748 return false;
1749 }
1751 void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs,
1752 StackMapFrame* current_frame,
1753 constantPoolHandle cp,
1754 TRAPS) {
1755 u2 index = bcs->get_index_u2();
1756 verify_cp_type(index, cp, 1 << JVM_CONSTANT_Fieldref, CHECK_VERIFY(this));
1758 // Get field name and signature
1759 symbolHandle field_name = symbolHandle(THREAD, cp->name_ref_at(index));
1760 symbolHandle field_sig = symbolHandle(THREAD, cp->signature_ref_at(index));
1762 if (!SignatureVerifier::is_valid_type_signature(field_sig)) {
1763 class_format_error(
1764 "Invalid signature for field in class %s referenced "
1765 "from constant pool index %d", _klass->external_name(), index);
1766 return;
1767 }
1769 // Get referenced class type
1770 VerificationType ref_class_type = cp_ref_index_to_type(
1771 index, cp, CHECK_VERIFY(this));
1772 if (!ref_class_type.is_object()) {
1773 verify_error(
1774 "Expecting reference to class in class %s at constant pool index %d",
1775 _klass->external_name(), index);
1776 return;
1777 }
1778 VerificationType target_class_type = ref_class_type;
1780 assert(sizeof(VerificationType) == sizeof(uintptr_t),
1781 "buffer type must match VerificationType size");
1782 uintptr_t field_type_buffer[2];
1783 VerificationType* field_type = (VerificationType*)field_type_buffer;
1784 // If we make a VerificationType[2] array directly, the compiler calls
1785 // to the c-runtime library to do the allocation instead of just
1786 // stack allocating it. Plus it would run constructors. This shows up
1787 // in performance profiles.
1789 SignatureStream sig_stream(field_sig, false);
1790 VerificationType stack_object_type;
1791 int n = change_sig_to_verificationType(
1792 &sig_stream, field_type, CHECK_VERIFY(this));
1793 u2 bci = bcs->bci();
1794 bool is_assignable;
1795 switch (bcs->raw_code()) {
1796 case Bytecodes::_getstatic: {
1797 for (int i = 0; i < n; i++) {
1798 current_frame->push_stack(field_type[i], CHECK_VERIFY(this));
1799 }
1800 break;
1801 }
1802 case Bytecodes::_putstatic: {
1803 for (int i = n - 1; i >= 0; i--) {
1804 current_frame->pop_stack(field_type[i], CHECK_VERIFY(this));
1805 }
1806 break;
1807 }
1808 case Bytecodes::_getfield: {
1809 stack_object_type = current_frame->pop_stack(
1810 target_class_type, CHECK_VERIFY(this));
1811 for (int i = 0; i < n; i++) {
1812 current_frame->push_stack(field_type[i], CHECK_VERIFY(this));
1813 }
1814 goto check_protected;
1815 }
1816 case Bytecodes::_putfield: {
1817 for (int i = n - 1; i >= 0; i--) {
1818 current_frame->pop_stack(field_type[i], CHECK_VERIFY(this));
1819 }
1820 stack_object_type = current_frame->pop_stack(CHECK_VERIFY(this));
1822 // The JVMS 2nd edition allows field initialization before the superclass
1823 // initializer, if the field is defined within the current class.
1824 fieldDescriptor fd;
1825 if (stack_object_type == VerificationType::uninitialized_this_type() &&
1826 target_class_type.equals(current_type()) &&
1827 _klass->find_local_field(field_name(), field_sig(), &fd)) {
1828 stack_object_type = current_type();
1829 }
1830 is_assignable = target_class_type.is_assignable_from(
1831 stack_object_type, current_class(), CHECK_VERIFY(this));
1832 if (!is_assignable) {
1833 verify_error(bci, "Bad type on operand stack in putfield");
1834 return;
1835 }
1836 }
1837 check_protected: {
1838 if (_this_type == stack_object_type)
1839 break; // stack_object_type must be assignable to _current_class_type
1840 symbolHandle ref_class_name = symbolHandle(THREAD,
1841 cp->klass_name_at(cp->klass_ref_index_at(index)));
1842 if (!name_in_supers(ref_class_name(), current_class()))
1843 // stack_object_type must be assignable to _current_class_type since:
1844 // 1. stack_object_type must be assignable to ref_class.
1845 // 2. ref_class must be _current_class or a subclass of it. It can't
1846 // be a superclass of it. See revised JVMS 5.4.4.
1847 break;
1849 klassOop ref_class_oop = load_class(ref_class_name, CHECK);
1850 if (is_protected_access(current_class(), ref_class_oop, field_name(),
1851 field_sig(), false)) {
1852 // It's protected access, check if stack object is assignable to
1853 // current class.
1854 is_assignable = current_type().is_assignable_from(
1855 stack_object_type, current_class(), CHECK_VERIFY(this));
1856 if (!is_assignable) {
1857 verify_error(bci, "Bad access to protected data in getfield");
1858 return;
1859 }
1860 }
1861 break;
1862 }
1863 default: ShouldNotReachHere();
1864 }
1865 }
1867 void ClassVerifier::verify_invoke_init(
1868 RawBytecodeStream* bcs, VerificationType ref_class_type,
1869 StackMapFrame* current_frame, u4 code_length, bool *this_uninit,
1870 constantPoolHandle cp, TRAPS) {
1871 u2 bci = bcs->bci();
1872 VerificationType type = current_frame->pop_stack(
1873 VerificationType::reference_check(), CHECK_VERIFY(this));
1874 if (type == VerificationType::uninitialized_this_type()) {
1875 // The method must be an <init> method of either this class, or one of its
1876 // superclasses
1877 if (ref_class_type.name() != current_class()->name() &&
1878 !name_in_supers(ref_class_type.name(), current_class())) {
1879 verify_error(bci, "Bad <init> method call");
1880 return;
1881 }
1882 current_frame->initialize_object(type, current_type());
1883 *this_uninit = true;
1884 } else if (type.is_uninitialized()) {
1885 u2 new_offset = type.bci();
1886 address new_bcp = bcs->bcp() - bci + new_offset;
1887 if (new_offset > (code_length - 3) || (*new_bcp) != Bytecodes::_new) {
1888 verify_error(new_offset, "Expecting new instruction");
1889 return;
1890 }
1891 u2 new_class_index = Bytes::get_Java_u2(new_bcp + 1);
1892 verify_cp_class_type(new_class_index, cp, CHECK_VERIFY(this));
1894 // The method must be an <init> method of the indicated class
1895 VerificationType new_class_type = cp_index_to_type(
1896 new_class_index, cp, CHECK_VERIFY(this));
1897 if (!new_class_type.equals(ref_class_type)) {
1898 verify_error(bci, "Call to wrong <init> method");
1899 return;
1900 }
1901 // According to the VM spec, if the referent class is a superclass of the
1902 // current class, and is in a different runtime package, and the method is
1903 // protected, then the objectref must be the current class or a subclass
1904 // of the current class.
1905 VerificationType objectref_type = new_class_type;
1906 if (name_in_supers(ref_class_type.name(), current_class())) {
1907 klassOop ref_klass = load_class(
1908 ref_class_type.name(), CHECK_VERIFY(this));
1909 methodOop m = instanceKlass::cast(ref_klass)->uncached_lookup_method(
1910 vmSymbols::object_initializer_name(),
1911 cp->signature_ref_at(bcs->get_index_u2()));
1912 instanceKlassHandle mh(THREAD, m->method_holder());
1913 if (m->is_protected() && !mh->is_same_class_package(_klass())) {
1914 bool assignable = current_type().is_assignable_from(
1915 objectref_type, current_class(), CHECK_VERIFY(this));
1916 if (!assignable) {
1917 verify_error(bci, "Bad access to protected <init> method");
1918 return;
1919 }
1920 }
1921 }
1922 current_frame->initialize_object(type, new_class_type);
1923 } else {
1924 verify_error(bci, "Bad operand type when invoking <init>");
1925 return;
1926 }
1927 }
1929 void ClassVerifier::verify_invoke_instructions(
1930 RawBytecodeStream* bcs, u4 code_length, StackMapFrame* current_frame,
1931 bool *this_uninit, VerificationType return_type,
1932 constantPoolHandle cp, TRAPS) {
1933 // Make sure the constant pool item is the right type
1934 u2 index = bcs->get_index_u2();
1935 Bytecodes::Code opcode = bcs->raw_code();
1936 unsigned int types = (opcode == Bytecodes::_invokeinterface
1937 ? 1 << JVM_CONSTANT_InterfaceMethodref
1938 : opcode == Bytecodes::_invokedynamic
1939 ? ((AllowTransitionalJSR292 ? 1 << JVM_CONSTANT_NameAndType : 0)
1940 |1 << JVM_CONSTANT_InvokeDynamic)
1941 : 1 << JVM_CONSTANT_Methodref);
1942 verify_cp_type(index, cp, types, CHECK_VERIFY(this));
1944 // Get method name and signature
1945 symbolHandle method_name(THREAD, cp->name_ref_at(index));
1946 symbolHandle method_sig(THREAD, cp->signature_ref_at(index));
1948 if (!SignatureVerifier::is_valid_method_signature(method_sig)) {
1949 class_format_error(
1950 "Invalid method signature in class %s referenced "
1951 "from constant pool index %d", _klass->external_name(), index);
1952 return;
1953 }
1955 // Get referenced class type
1956 VerificationType ref_class_type;
1957 if (opcode == Bytecodes::_invokedynamic) {
1958 if (!EnableInvokeDynamic ||
1959 _klass->major_version() < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
1960 class_format_error(
1961 (!EnableInvokeDynamic ?
1962 "invokedynamic instructions not enabled in this JVM" :
1963 "invokedynamic instructions not supported by this class file version"),
1964 _klass->external_name());
1965 return;
1966 }
1967 } else {
1968 ref_class_type = cp_ref_index_to_type(index, cp, CHECK_VERIFY(this));
1969 }
1971 // For a small signature length, we just allocate 128 bytes instead
1972 // of parsing the signature once to find its size.
1973 // -3 is for '(', ')' and return descriptor; multiply by 2 is for
1974 // longs/doubles to be consertive.
1975 assert(sizeof(VerificationType) == sizeof(uintptr_t),
1976 "buffer type must match VerificationType size");
1977 uintptr_t on_stack_sig_types_buffer[128];
1978 // If we make a VerificationType[128] array directly, the compiler calls
1979 // to the c-runtime library to do the allocation instead of just
1980 // stack allocating it. Plus it would run constructors. This shows up
1981 // in performance profiles.
1983 VerificationType* sig_types;
1984 int size = (method_sig->utf8_length() - 3) * 2;
1985 if (size > 128) {
1986 // Long and double occupies two slots here.
1987 ArgumentSizeComputer size_it(method_sig);
1988 size = size_it.size();
1989 sig_types = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, VerificationType, size);
1990 } else{
1991 sig_types = (VerificationType*)on_stack_sig_types_buffer;
1992 }
1993 SignatureStream sig_stream(method_sig);
1994 int sig_i = 0;
1995 while (!sig_stream.at_return_type()) {
1996 sig_i += change_sig_to_verificationType(
1997 &sig_stream, &sig_types[sig_i], CHECK_VERIFY(this));
1998 sig_stream.next();
1999 }
2000 int nargs = sig_i;
2002 #ifdef ASSERT
2003 {
2004 ArgumentSizeComputer size_it(method_sig);
2005 assert(nargs == size_it.size(), "Argument sizes do not match");
2006 assert(nargs <= (method_sig->utf8_length() - 3) * 2, "estimate of max size isn't conservative enough");
2007 }
2008 #endif
2010 // Check instruction operands
2011 u2 bci = bcs->bci();
2012 if (opcode == Bytecodes::_invokeinterface) {
2013 address bcp = bcs->bcp();
2014 // 4905268: count operand in invokeinterface should be nargs+1, not nargs.
2015 // JSR202 spec: The count operand of an invokeinterface instruction is valid if it is
2016 // the difference between the size of the operand stack before and after the instruction
2017 // executes.
2018 if (*(bcp+3) != (nargs+1)) {
2019 verify_error(bci, "Inconsistent args count operand in invokeinterface");
2020 return;
2021 }
2022 if (*(bcp+4) != 0) {
2023 verify_error(bci, "Fourth operand byte of invokeinterface must be zero");
2024 return;
2025 }
2026 }
2028 if (opcode == Bytecodes::_invokedynamic) {
2029 address bcp = bcs->bcp();
2030 if (*(bcp+3) != 0 || *(bcp+4) != 0) {
2031 verify_error(bci, "Third and fourth operand bytes of invokedynamic must be zero");
2032 return;
2033 }
2034 }
2036 if (method_name->byte_at(0) == '<') {
2037 // Make sure <init> can only be invoked by invokespecial
2038 if (opcode != Bytecodes::_invokespecial ||
2039 method_name() != vmSymbols::object_initializer_name()) {
2040 verify_error(bci, "Illegal call to internal method");
2041 return;
2042 }
2043 } else if (opcode == Bytecodes::_invokespecial
2044 && !ref_class_type.equals(current_type())
2045 && !ref_class_type.equals(VerificationType::reference_type(
2046 current_class()->super()->klass_part()->name()))) {
2047 bool subtype = ref_class_type.is_assignable_from(
2048 current_type(), current_class(), CHECK_VERIFY(this));
2049 if (!subtype) {
2050 verify_error(bci, "Bad invokespecial instruction: "
2051 "current class isn't assignable to reference class.");
2052 return;
2053 }
2054 }
2055 // Match method descriptor with operand stack
2056 for (int i = nargs - 1; i >= 0; i--) { // Run backwards
2057 current_frame->pop_stack(sig_types[i], CHECK_VERIFY(this));
2058 }
2059 // Check objectref on operand stack
2060 if (opcode != Bytecodes::_invokestatic &&
2061 opcode != Bytecodes::_invokedynamic) {
2062 if (method_name() == vmSymbols::object_initializer_name()) { // <init> method
2063 verify_invoke_init(bcs, ref_class_type, current_frame,
2064 code_length, this_uninit, cp, CHECK_VERIFY(this));
2065 } else { // other methods
2066 // Ensures that target class is assignable to method class.
2067 if (opcode == Bytecodes::_invokespecial) {
2068 current_frame->pop_stack(current_type(), CHECK_VERIFY(this));
2069 } else if (opcode == Bytecodes::_invokevirtual) {
2070 VerificationType stack_object_type =
2071 current_frame->pop_stack(ref_class_type, CHECK_VERIFY(this));
2072 if (current_type() != stack_object_type) {
2073 assert(cp->cache() == NULL, "not rewritten yet");
2074 symbolHandle ref_class_name = symbolHandle(THREAD,
2075 cp->klass_name_at(cp->klass_ref_index_at(index)));
2076 // See the comments in verify_field_instructions() for
2077 // the rationale behind this.
2078 if (name_in_supers(ref_class_name(), current_class())) {
2079 klassOop ref_class = load_class(ref_class_name, CHECK);
2080 if (is_protected_access(
2081 _klass, ref_class, method_name(), method_sig(), true)) {
2082 // It's protected access, check if stack object is
2083 // assignable to current class.
2084 bool is_assignable = current_type().is_assignable_from(
2085 stack_object_type, current_class(), CHECK_VERIFY(this));
2086 if (!is_assignable) {
2087 if (ref_class_type.name() == vmSymbols::java_lang_Object()
2088 && stack_object_type.is_array()
2089 && method_name() == vmSymbols::clone_name()) {
2090 // Special case: arrays pretend to implement public Object
2091 // clone().
2092 } else {
2093 verify_error(bci,
2094 "Bad access to protected data in invokevirtual");
2095 return;
2096 }
2097 }
2098 }
2099 }
2100 }
2101 } else {
2102 assert(opcode == Bytecodes::_invokeinterface, "Unexpected opcode encountered");
2103 current_frame->pop_stack(ref_class_type, CHECK_VERIFY(this));
2104 }
2105 }
2106 }
2107 // Push the result type.
2108 if (sig_stream.type() != T_VOID) {
2109 if (method_name() == vmSymbols::object_initializer_name()) {
2110 // <init> method must have a void return type
2111 verify_error(bci, "Return type must be void in <init> method");
2112 return;
2113 }
2114 VerificationType return_type[2];
2115 int n = change_sig_to_verificationType(
2116 &sig_stream, return_type, CHECK_VERIFY(this));
2117 for (int i = 0; i < n; i++) {
2118 current_frame->push_stack(return_type[i], CHECK_VERIFY(this)); // push types backwards
2119 }
2120 }
2121 }
2123 VerificationType ClassVerifier::get_newarray_type(
2124 u2 index, u2 bci, TRAPS) {
2125 const char* from_bt[] = {
2126 NULL, NULL, NULL, NULL, "[Z", "[C", "[F", "[D", "[B", "[S", "[I", "[J",
2127 };
2128 if (index < T_BOOLEAN || index > T_LONG) {
2129 verify_error(bci, "Illegal newarray instruction");
2130 return VerificationType::bogus_type();
2131 }
2133 // from_bt[index] contains the array signature which has a length of 2
2134 symbolHandle sig = oopFactory::new_symbol_handle(
2135 from_bt[index], 2, CHECK_(VerificationType::bogus_type()));
2136 return VerificationType::reference_type(sig);
2137 }
2139 void ClassVerifier::verify_anewarray(
2140 u2 index, constantPoolHandle cp, StackMapFrame* current_frame, TRAPS) {
2141 verify_cp_class_type(index, cp, CHECK_VERIFY(this));
2142 current_frame->pop_stack(
2143 VerificationType::integer_type(), CHECK_VERIFY(this));
2145 VerificationType component_type =
2146 cp_index_to_type(index, cp, CHECK_VERIFY(this));
2147 ResourceMark rm(THREAD);
2148 int length;
2149 char* arr_sig_str;
2150 if (component_type.is_array()) { // it's an array
2151 const char* component_name = component_type.name()->as_utf8();
2152 // add one dimension to component
2153 length = (int)strlen(component_name) + 1;
2154 arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length);
2155 arr_sig_str[0] = '[';
2156 strncpy(&arr_sig_str[1], component_name, length - 1);
2157 } else { // it's an object or interface
2158 const char* component_name = component_type.name()->as_utf8();
2159 // add one dimension to component with 'L' prepended and ';' postpended.
2160 length = (int)strlen(component_name) + 3;
2161 arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length);
2162 arr_sig_str[0] = '[';
2163 arr_sig_str[1] = 'L';
2164 strncpy(&arr_sig_str[2], component_name, length - 2);
2165 arr_sig_str[length - 1] = ';';
2166 }
2167 symbolHandle arr_sig = oopFactory::new_symbol_handle(
2168 arr_sig_str, length, CHECK_VERIFY(this));
2169 VerificationType new_array_type = VerificationType::reference_type(arr_sig);
2170 current_frame->push_stack(new_array_type, CHECK_VERIFY(this));
2171 }
2173 void ClassVerifier::verify_iload(u2 index, StackMapFrame* current_frame, TRAPS) {
2174 current_frame->get_local(
2175 index, VerificationType::integer_type(), CHECK_VERIFY(this));
2176 current_frame->push_stack(
2177 VerificationType::integer_type(), CHECK_VERIFY(this));
2178 }
2180 void ClassVerifier::verify_lload(u2 index, StackMapFrame* current_frame, TRAPS) {
2181 current_frame->get_local_2(
2182 index, VerificationType::long_type(),
2183 VerificationType::long2_type(), CHECK_VERIFY(this));
2184 current_frame->push_stack_2(
2185 VerificationType::long_type(),
2186 VerificationType::long2_type(), CHECK_VERIFY(this));
2187 }
2189 void ClassVerifier::verify_fload(u2 index, StackMapFrame* current_frame, TRAPS) {
2190 current_frame->get_local(
2191 index, VerificationType::float_type(), CHECK_VERIFY(this));
2192 current_frame->push_stack(
2193 VerificationType::float_type(), CHECK_VERIFY(this));
2194 }
2196 void ClassVerifier::verify_dload(u2 index, StackMapFrame* current_frame, TRAPS) {
2197 current_frame->get_local_2(
2198 index, VerificationType::double_type(),
2199 VerificationType::double2_type(), CHECK_VERIFY(this));
2200 current_frame->push_stack_2(
2201 VerificationType::double_type(),
2202 VerificationType::double2_type(), CHECK_VERIFY(this));
2203 }
2205 void ClassVerifier::verify_aload(u2 index, StackMapFrame* current_frame, TRAPS) {
2206 VerificationType type = current_frame->get_local(
2207 index, VerificationType::reference_check(), CHECK_VERIFY(this));
2208 current_frame->push_stack(type, CHECK_VERIFY(this));
2209 }
2211 void ClassVerifier::verify_istore(u2 index, StackMapFrame* current_frame, TRAPS) {
2212 current_frame->pop_stack(
2213 VerificationType::integer_type(), CHECK_VERIFY(this));
2214 current_frame->set_local(
2215 index, VerificationType::integer_type(), CHECK_VERIFY(this));
2216 }
2218 void ClassVerifier::verify_lstore(u2 index, StackMapFrame* current_frame, TRAPS) {
2219 current_frame->pop_stack_2(
2220 VerificationType::long2_type(),
2221 VerificationType::long_type(), CHECK_VERIFY(this));
2222 current_frame->set_local_2(
2223 index, VerificationType::long_type(),
2224 VerificationType::long2_type(), CHECK_VERIFY(this));
2225 }
2227 void ClassVerifier::verify_fstore(u2 index, StackMapFrame* current_frame, TRAPS) {
2228 current_frame->pop_stack(VerificationType::float_type(), CHECK_VERIFY(this));
2229 current_frame->set_local(
2230 index, VerificationType::float_type(), CHECK_VERIFY(this));
2231 }
2233 void ClassVerifier::verify_dstore(u2 index, StackMapFrame* current_frame, TRAPS) {
2234 current_frame->pop_stack_2(
2235 VerificationType::double2_type(),
2236 VerificationType::double_type(), CHECK_VERIFY(this));
2237 current_frame->set_local_2(
2238 index, VerificationType::double_type(),
2239 VerificationType::double2_type(), CHECK_VERIFY(this));
2240 }
2242 void ClassVerifier::verify_astore(u2 index, StackMapFrame* current_frame, TRAPS) {
2243 VerificationType type = current_frame->pop_stack(
2244 VerificationType::reference_check(), CHECK_VERIFY(this));
2245 current_frame->set_local(index, type, CHECK_VERIFY(this));
2246 }
2248 void ClassVerifier::verify_iinc(u2 index, StackMapFrame* current_frame, TRAPS) {
2249 VerificationType type = current_frame->get_local(
2250 index, VerificationType::integer_type(), CHECK_VERIFY(this));
2251 current_frame->set_local(index, type, CHECK_VERIFY(this));
2252 }
2254 void ClassVerifier::verify_return_value(
2255 VerificationType return_type, VerificationType type, u2 bci, TRAPS) {
2256 if (return_type == VerificationType::bogus_type()) {
2257 verify_error(bci, "Method expects a return value");
2258 return;
2259 }
2260 bool match = return_type.is_assignable_from(type, _klass, CHECK_VERIFY(this));
2261 if (!match) {
2262 verify_error(bci, "Bad return type");
2263 return;
2264 }
2265 }