comparison src/share/vm/classfile/classFileParser.cpp @ 1660:083fde3b838e

6964498: JSR 292 invokedynamic sites need local bootstrap methods Summary: Add JVM_CONSTANT_InvokeDynamic records to constant pool to determine per-instruction BSMs. Reviewed-by: twisti
author jrose
date Thu, 15 Jul 2010 18:40:45 -0700
parents 2389669474a6
children 0e35fa8ebccd
comparison
equal deleted inserted replaced
1649:a528509c992b 1660:083fde3b838e
120 case JVM_CONSTANT_MethodHandle : 120 case JVM_CONSTANT_MethodHandle :
121 case JVM_CONSTANT_MethodType : 121 case JVM_CONSTANT_MethodType :
122 if (!EnableMethodHandles || 122 if (!EnableMethodHandles ||
123 _major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { 123 _major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
124 classfile_parse_error( 124 classfile_parse_error(
125 (!EnableInvokeDynamic ? 125 (!EnableMethodHandles ?
126 "This JVM does not support constant tag %u in class file %s" : 126 "This JVM does not support constant tag %u in class file %s" :
127 "Class file version does not support constant tag %u in class file %s"), 127 "Class file version does not support constant tag %u in class file %s"),
128 tag, CHECK); 128 tag, CHECK);
129 } 129 }
130 if (tag == JVM_CONSTANT_MethodHandle) { 130 if (tag == JVM_CONSTANT_MethodHandle) {
136 cfs->guarantee_more(3, CHECK); // signature_index, tag/access_flags 136 cfs->guarantee_more(3, CHECK); // signature_index, tag/access_flags
137 u2 signature_index = cfs->get_u2_fast(); 137 u2 signature_index = cfs->get_u2_fast();
138 cp->method_type_index_at_put(index, signature_index); 138 cp->method_type_index_at_put(index, signature_index);
139 } else { 139 } else {
140 ShouldNotReachHere(); 140 ShouldNotReachHere();
141 }
142 break;
143 case JVM_CONSTANT_InvokeDynamic :
144 {
145 if (!EnableInvokeDynamic ||
146 _major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
147 classfile_parse_error(
148 (!EnableInvokeDynamic ?
149 "This JVM does not support constant tag %u in class file %s" :
150 "Class file version does not support constant tag %u in class file %s"),
151 tag, CHECK);
152 }
153 cfs->guarantee_more(5, CHECK); // bsm_index, name_and_type_index, tag/access_flags
154 u2 bootstrap_method_index = cfs->get_u2_fast();
155 u2 name_and_type_index = cfs->get_u2_fast();
156 cp->invoke_dynamic_at_put(index, bootstrap_method_index, name_and_type_index);
141 } 157 }
142 break; 158 break;
143 case JVM_CONSTANT_Integer : 159 case JVM_CONSTANT_Integer :
144 { 160 {
145 cfs->guarantee_more(5, CHECK); // bytes, tag/access_flags 161 cfs->guarantee_more(5, CHECK); // bytes, tag/access_flags
412 EnableMethodHandles, 428 EnableMethodHandles,
413 "Invalid constant pool index %u in class file %s", 429 "Invalid constant pool index %u in class file %s",
414 ref_index, CHECK_(nullHandle)); 430 ref_index, CHECK_(nullHandle));
415 } 431 }
416 break; 432 break;
433 case JVM_CONSTANT_InvokeDynamic :
434 {
435 int bootstrap_method_ref_index = cp->invoke_dynamic_bootstrap_method_ref_index_at(index);
436 int name_and_type_ref_index = cp->invoke_dynamic_name_and_type_ref_index_at(index);
437 check_property((bootstrap_method_ref_index == 0 && AllowTransitionalJSR292)
438 ||
439 (valid_cp_range(bootstrap_method_ref_index, length) &&
440 cp->tag_at(bootstrap_method_ref_index).is_method_handle()),
441 "Invalid constant pool index %u in class file %s",
442 bootstrap_method_ref_index,
443 CHECK_(nullHandle));
444 check_property(valid_cp_range(name_and_type_ref_index, length) &&
445 cp->tag_at(name_and_type_ref_index).is_name_and_type(),
446 "Invalid constant pool index %u in class file %s",
447 name_and_type_ref_index,
448 CHECK_(nullHandle));
449 break;
450 }
417 default: 451 default:
418 fatal(err_msg("bad constant pool tag value %u", 452 fatal(err_msg("bad constant pool tag value %u",
419 cp->tag_at(index).value())); 453 cp->tag_at(index).value()));
420 ShouldNotReachHere(); 454 ShouldNotReachHere();
421 break; 455 break;