src/share/vm/classfile/classFileParser.cpp

changeset 2742
ed69575596ac
parent 2698
38fea01eb669
child 2743
758ba0bf7bcc
equal deleted inserted replaced
2741:55973726c600 2742:ed69575596ac
168 cp->method_type_index_at_put(index, signature_index); 168 cp->method_type_index_at_put(index, signature_index);
169 } else { 169 } else {
170 ShouldNotReachHere(); 170 ShouldNotReachHere();
171 } 171 }
172 break; 172 break;
173 case JVM_CONSTANT_InvokeDynamicTrans : // this tag appears only in old classfiles
174 case JVM_CONSTANT_InvokeDynamic : 173 case JVM_CONSTANT_InvokeDynamic :
175 { 174 {
176 if (_major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { 175 if (_major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
177 classfile_parse_error( 176 classfile_parse_error(
178 "Class file version does not support constant tag %u in class file %s", 177 "Class file version does not support constant tag %u in class file %s",
184 tag, CHECK); 183 tag, CHECK);
185 } 184 }
186 cfs->guarantee_more(5, CHECK); // bsm_index, nt, tag/access_flags 185 cfs->guarantee_more(5, CHECK); // bsm_index, nt, tag/access_flags
187 u2 bootstrap_specifier_index = cfs->get_u2_fast(); 186 u2 bootstrap_specifier_index = cfs->get_u2_fast();
188 u2 name_and_type_index = cfs->get_u2_fast(); 187 u2 name_and_type_index = cfs->get_u2_fast();
189 if (tag == JVM_CONSTANT_InvokeDynamicTrans) {
190 if (!AllowTransitionalJSR292)
191 classfile_parse_error(
192 "This JVM does not support transitional InvokeDynamic tag %u in class file %s",
193 tag, CHECK);
194 cp->invoke_dynamic_trans_at_put(index, bootstrap_specifier_index, name_and_type_index);
195 break;
196 }
197 if (_max_bootstrap_specifier_index < (int) bootstrap_specifier_index) 188 if (_max_bootstrap_specifier_index < (int) bootstrap_specifier_index)
198 _max_bootstrap_specifier_index = (int) bootstrap_specifier_index; // collect for later 189 _max_bootstrap_specifier_index = (int) bootstrap_specifier_index; // collect for later
199 cp->invoke_dynamic_at_put(index, bootstrap_specifier_index, name_and_type_index); 190 cp->invoke_dynamic_at_put(index, bootstrap_specifier_index, name_and_type_index);
200 } 191 }
201 break; 192 break;
490 EnableInvokeDynamic, 481 EnableInvokeDynamic,
491 "Invalid constant pool index %u in class file %s", 482 "Invalid constant pool index %u in class file %s",
492 ref_index, CHECK_(nullHandle)); 483 ref_index, CHECK_(nullHandle));
493 } 484 }
494 break; 485 break;
495 case JVM_CONSTANT_InvokeDynamicTrans :
496 case JVM_CONSTANT_InvokeDynamic : 486 case JVM_CONSTANT_InvokeDynamic :
497 { 487 {
498 int name_and_type_ref_index = cp->invoke_dynamic_name_and_type_ref_index_at(index); 488 int name_and_type_ref_index = cp->invoke_dynamic_name_and_type_ref_index_at(index);
499 check_property(valid_cp_range(name_and_type_ref_index, length) && 489 check_property(valid_cp_range(name_and_type_ref_index, length) &&
500 cp->tag_at(name_and_type_ref_index).is_name_and_type(), 490 cp->tag_at(name_and_type_ref_index).is_name_and_type(),
501 "Invalid constant pool index %u in class file %s", 491 "Invalid constant pool index %u in class file %s",
502 name_and_type_ref_index, 492 name_and_type_ref_index,
503 CHECK_(nullHandle)); 493 CHECK_(nullHandle));
504 if (tag == JVM_CONSTANT_InvokeDynamicTrans) {
505 int bootstrap_method_ref_index = cp->invoke_dynamic_bootstrap_method_ref_index_at(index);
506 check_property(valid_cp_range(bootstrap_method_ref_index, length) &&
507 cp->tag_at(bootstrap_method_ref_index).is_method_handle(),
508 "Invalid constant pool index %u in class file %s",
509 bootstrap_method_ref_index,
510 CHECK_(nullHandle));
511 }
512 // bootstrap specifier index must be checked later, when BootstrapMethods attr is available 494 // bootstrap specifier index must be checked later, when BootstrapMethods attr is available
513 break; 495 break;
514 } 496 }
515 default: 497 default:
516 fatal(err_msg("bad constant pool tag value %u", 498 fatal(err_msg("bad constant pool tag value %u",
2781 word_sig_index = index; 2763 word_sig_index = index;
2782 break; 2764 break;
2783 } 2765 }
2784 } 2766 }
2785 2767
2786 if (AllowTransitionalJSR292 && word_sig_index == 0) return;
2787 if (word_sig_index == 0) 2768 if (word_sig_index == 0)
2788 THROW_MSG(vmSymbols::java_lang_VirtualMachineError(), 2769 THROW_MSG(vmSymbols::java_lang_VirtualMachineError(),
2789 "missing I or J signature (for vmentry) in java.lang.invoke.MethodHandle"); 2770 "missing I or J signature (for vmentry) in java.lang.invoke.MethodHandle");
2790 2771
2791 // Find vmentry field and change the signature. 2772 // Find vmentry field and change the signature.
2821 break; 2802 break;
2822 } 2803 }
2823 } 2804 }
2824 } 2805 }
2825 2806
2826 if (AllowTransitionalJSR292 && !found_vmentry) return;
2827 if (!found_vmentry) 2807 if (!found_vmentry)
2828 THROW_MSG(vmSymbols::java_lang_VirtualMachineError(), 2808 THROW_MSG(vmSymbols::java_lang_VirtualMachineError(),
2829 "missing vmentry byte field in java.lang.invoke.MethodHandle"); 2809 "missing vmentry byte field in java.lang.invoke.MethodHandle");
2830 } 2810 }
2831 2811
3190 nonstatic_field_size * heapOopSize; 3170 nonstatic_field_size * heapOopSize;
3191 next_nonstatic_field_offset = first_nonstatic_field_offset; 3171 next_nonstatic_field_offset = first_nonstatic_field_offset;
3192 3172
3193 // adjust the vmentry field declaration in java.lang.invoke.MethodHandle 3173 // adjust the vmentry field declaration in java.lang.invoke.MethodHandle
3194 if (EnableInvokeDynamic && class_name == vmSymbols::java_lang_invoke_MethodHandle() && class_loader.is_null()) { 3174 if (EnableInvokeDynamic && class_name == vmSymbols::java_lang_invoke_MethodHandle() && class_loader.is_null()) {
3195 java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
3196 }
3197 if (AllowTransitionalJSR292 &&
3198 EnableInvokeDynamic && class_name == vmSymbols::java_dyn_MethodHandle() && class_loader.is_null()) {
3199 java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
3200 }
3201 if (AllowTransitionalJSR292 &&
3202 EnableInvokeDynamic && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
3203 // allow vmentry field in MethodHandleImpl also
3204 java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle)); 3175 java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
3205 } 3176 }
3206 3177
3207 // Add a fake "discovered" field if it is not present 3178 // Add a fake "discovered" field if it is not present
3208 // for compatibility with earlier jdk's. 3179 // for compatibility with earlier jdk's.

mercurial