202 else { |
202 else { |
203 ShouldNotReachHere(); |
203 ShouldNotReachHere(); |
204 } |
204 } |
205 break; |
205 break; |
206 } |
206 } |
|
207 case JVM_CONSTANT_Dynamic : { |
|
208 if (_major_version < Verifier::DYNAMICCONSTANT_MAJOR_VERSION) { |
|
209 classfile_parse_error( |
|
210 "Class file version does not support constant tag %u in class file %s", |
|
211 tag, CHECK); |
|
212 } |
|
213 cfs->guarantee_more(5, CHECK); // bsm_index, nt, tag/access_flags |
|
214 const u2 bootstrap_specifier_index = cfs->get_u2_fast(); |
|
215 const u2 name_and_type_index = cfs->get_u2_fast(); |
|
216 if (_max_bootstrap_specifier_index < (int) bootstrap_specifier_index) { |
|
217 _max_bootstrap_specifier_index = (int) bootstrap_specifier_index; // collect for later |
|
218 } |
|
219 cp->dynamic_constant_at_put(index, bootstrap_specifier_index, name_and_type_index); |
|
220 break; |
|
221 } |
207 case JVM_CONSTANT_InvokeDynamic : { |
222 case JVM_CONSTANT_InvokeDynamic : { |
208 if (_major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { |
223 if (_major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { |
209 classfile_parse_error( |
224 classfile_parse_error( |
210 "Class file version does not support constant tag %u in class file %s", |
225 "Class file version does not support constant tag %u in class file %s", |
211 tag, CHECK); |
226 tag, CHECK); |
534 check_property(valid_symbol_at(ref_index), |
549 check_property(valid_symbol_at(ref_index), |
535 "Invalid constant pool index %u in class file %s", |
550 "Invalid constant pool index %u in class file %s", |
536 ref_index, CHECK); |
551 ref_index, CHECK); |
537 break; |
552 break; |
538 } |
553 } |
|
554 case JVM_CONSTANT_Dynamic: { |
|
555 const int name_and_type_ref_index = |
|
556 cp->invoke_dynamic_name_and_type_ref_index_at(index); |
|
557 |
|
558 check_property(valid_cp_range(name_and_type_ref_index, length) && |
|
559 cp->tag_at(name_and_type_ref_index).is_name_and_type(), |
|
560 "Invalid constant pool index %u in class file %s", |
|
561 name_and_type_ref_index, CHECK); |
|
562 // bootstrap specifier index must be checked later, |
|
563 // when BootstrapMethods attr is available |
|
564 |
|
565 // Mark the constant pool as having a CONSTANT_Dynamic_info structure |
|
566 cp->set_has_dynamic_constant(); |
|
567 break; |
|
568 } |
539 case JVM_CONSTANT_InvokeDynamic: { |
569 case JVM_CONSTANT_InvokeDynamic: { |
540 const int name_and_type_ref_index = |
570 const int name_and_type_ref_index = |
541 cp->invoke_dynamic_name_and_type_ref_index_at(index); |
571 cp->invoke_dynamic_name_and_type_ref_index_at(index); |
542 |
572 |
543 check_property(valid_cp_range(name_and_type_ref_index, length) && |
573 check_property(valid_cp_range(name_and_type_ref_index, length) && |
622 verify_legal_method_signature(name, sig, CHECK); |
652 verify_legal_method_signature(name, sig, CHECK); |
623 } else { |
653 } else { |
624 // Format check field name and signature |
654 // Format check field name and signature |
625 verify_legal_field_name(name, CHECK); |
655 verify_legal_field_name(name, CHECK); |
626 verify_legal_field_signature(name, sig, CHECK); |
656 verify_legal_field_signature(name, sig, CHECK); |
|
657 } |
|
658 } |
|
659 break; |
|
660 } |
|
661 case JVM_CONSTANT_Dynamic: { |
|
662 const int name_and_type_ref_index = |
|
663 cp->name_and_type_ref_index_at(index); |
|
664 // already verified to be utf8 |
|
665 const int name_ref_index = |
|
666 cp->name_ref_index_at(name_and_type_ref_index); |
|
667 // already verified to be utf8 |
|
668 const int signature_ref_index = |
|
669 cp->signature_ref_index_at(name_and_type_ref_index); |
|
670 const Symbol* const name = cp->symbol_at(name_ref_index); |
|
671 const Symbol* const signature = cp->symbol_at(signature_ref_index); |
|
672 if (_need_verify) { |
|
673 // CONSTANT_Dynamic's name and signature are verified above, when iterating NameAndType_info. |
|
674 // Need only to be sure signature is non-zero length and the right type. |
|
675 if (signature->utf8_length() == 0 || |
|
676 signature->byte_at(0) == JVM_SIGNATURE_FUNC) { |
|
677 throwIllegalSignature("CONSTANT_Dynamic", name, signature, CHECK); |
627 } |
678 } |
628 } |
679 } |
629 break; |
680 break; |
630 } |
681 } |
631 case JVM_CONSTANT_InvokeDynamic: |
682 case JVM_CONSTANT_InvokeDynamic: |