Mercurial > hg > truffle
comparison src/share/vm/classfile/classFileParser.cpp @ 1608:2389669474a6
Merge
author | jrose |
---|---|
date | Tue, 15 Jun 2010 15:57:36 -0700 |
parents | 3a9de63b2209 136b78722a08 |
children | 083fde3b838e |
comparison
equal
deleted
inserted
replaced
1594:b9bc732be7c0 | 1608:2389669474a6 |
---|---|
113 case JVM_CONSTANT_String : | 113 case JVM_CONSTANT_String : |
114 { | 114 { |
115 cfs->guarantee_more(3, CHECK); // string_index, tag/access_flags | 115 cfs->guarantee_more(3, CHECK); // string_index, tag/access_flags |
116 u2 string_index = cfs->get_u2_fast(); | 116 u2 string_index = cfs->get_u2_fast(); |
117 cp->string_index_at_put(index, string_index); | 117 cp->string_index_at_put(index, string_index); |
118 } | |
119 break; | |
120 case JVM_CONSTANT_MethodHandle : | |
121 case JVM_CONSTANT_MethodType : | |
122 if (!EnableMethodHandles || | |
123 _major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { | |
124 classfile_parse_error( | |
125 (!EnableInvokeDynamic ? | |
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"), | |
128 tag, CHECK); | |
129 } | |
130 if (tag == JVM_CONSTANT_MethodHandle) { | |
131 cfs->guarantee_more(4, CHECK); // ref_kind, method_index, tag/access_flags | |
132 u1 ref_kind = cfs->get_u1_fast(); | |
133 u2 method_index = cfs->get_u2_fast(); | |
134 cp->method_handle_index_at_put(index, ref_kind, method_index); | |
135 } else if (tag == JVM_CONSTANT_MethodType) { | |
136 cfs->guarantee_more(3, CHECK); // signature_index, tag/access_flags | |
137 u2 signature_index = cfs->get_u2_fast(); | |
138 cp->method_type_index_at_put(index, signature_index); | |
139 } else { | |
140 ShouldNotReachHere(); | |
118 } | 141 } |
119 break; | 142 break; |
120 case JVM_CONSTANT_Integer : | 143 case JVM_CONSTANT_Integer : |
121 { | 144 { |
122 cfs->guarantee_more(5, CHECK); // bytes, tag/access_flags | 145 cfs->guarantee_more(5, CHECK); // bytes, tag/access_flags |
333 cp->tag_at(string_index).is_utf8(), | 356 cp->tag_at(string_index).is_utf8(), |
334 "Invalid constant pool index %u in class file %s", | 357 "Invalid constant pool index %u in class file %s", |
335 string_index, CHECK_(nullHandle)); | 358 string_index, CHECK_(nullHandle)); |
336 symbolOop sym = cp->symbol_at(string_index); | 359 symbolOop sym = cp->symbol_at(string_index); |
337 cp->unresolved_string_at_put(index, sym); | 360 cp->unresolved_string_at_put(index, sym); |
361 } | |
362 break; | |
363 case JVM_CONSTANT_MethodHandle : | |
364 { | |
365 int ref_index = cp->method_handle_index_at(index); | |
366 check_property( | |
367 valid_cp_range(ref_index, length) && | |
368 EnableMethodHandles, | |
369 "Invalid constant pool index %u in class file %s", | |
370 ref_index, CHECK_(nullHandle)); | |
371 constantTag tag = cp->tag_at(ref_index); | |
372 int ref_kind = cp->method_handle_ref_kind_at(index); | |
373 switch (ref_kind) { | |
374 case JVM_REF_getField: | |
375 case JVM_REF_getStatic: | |
376 case JVM_REF_putField: | |
377 case JVM_REF_putStatic: | |
378 check_property( | |
379 tag.is_field(), | |
380 "Invalid constant pool index %u in class file %s (not a field)", | |
381 ref_index, CHECK_(nullHandle)); | |
382 break; | |
383 case JVM_REF_invokeVirtual: | |
384 case JVM_REF_invokeStatic: | |
385 case JVM_REF_invokeSpecial: | |
386 case JVM_REF_newInvokeSpecial: | |
387 check_property( | |
388 tag.is_method(), | |
389 "Invalid constant pool index %u in class file %s (not a method)", | |
390 ref_index, CHECK_(nullHandle)); | |
391 break; | |
392 case JVM_REF_invokeInterface: | |
393 check_property( | |
394 tag.is_interface_method(), | |
395 "Invalid constant pool index %u in class file %s (not an interface method)", | |
396 ref_index, CHECK_(nullHandle)); | |
397 break; | |
398 default: | |
399 classfile_parse_error( | |
400 "Bad method handle kind at constant pool index %u in class file %s", | |
401 index, CHECK_(nullHandle)); | |
402 } | |
403 // Keep the ref_index unchanged. It will be indirected at link-time. | |
404 } | |
405 break; | |
406 case JVM_CONSTANT_MethodType : | |
407 { | |
408 int ref_index = cp->method_type_index_at(index); | |
409 check_property( | |
410 valid_cp_range(ref_index, length) && | |
411 cp->tag_at(ref_index).is_utf8() && | |
412 EnableMethodHandles, | |
413 "Invalid constant pool index %u in class file %s", | |
414 ref_index, CHECK_(nullHandle)); | |
338 } | 415 } |
339 break; | 416 break; |
340 default: | 417 default: |
341 fatal(err_msg("bad constant pool tag value %u", | 418 fatal(err_msg("bad constant pool tag value %u", |
342 cp->tag_at(index).value())); | 419 cp->tag_at(index).value())); |
450 } | 527 } |
451 } | 528 } |
452 } | 529 } |
453 break; | 530 break; |
454 } | 531 } |
532 case JVM_CONSTANT_MethodHandle: { | |
533 int ref_index = cp->method_handle_index_at(index); | |
534 int ref_kind = cp->method_handle_ref_kind_at(index); | |
535 switch (ref_kind) { | |
536 case JVM_REF_invokeVirtual: | |
537 case JVM_REF_invokeStatic: | |
538 case JVM_REF_invokeSpecial: | |
539 case JVM_REF_newInvokeSpecial: | |
540 { | |
541 int name_and_type_ref_index = cp->name_and_type_ref_index_at(ref_index); | |
542 int name_ref_index = cp->name_ref_index_at(name_and_type_ref_index); | |
543 symbolHandle name(THREAD, cp->symbol_at(name_ref_index)); | |
544 if (ref_kind == JVM_REF_newInvokeSpecial) { | |
545 if (name() != vmSymbols::object_initializer_name()) { | |
546 classfile_parse_error( | |
547 "Bad constructor name at constant pool index %u in class file %s", | |
548 name_ref_index, CHECK_(nullHandle)); | |
549 } | |
550 } else { | |
551 if (name() == vmSymbols::object_initializer_name()) { | |
552 classfile_parse_error( | |
553 "Bad method name at constant pool index %u in class file %s", | |
554 name_ref_index, CHECK_(nullHandle)); | |
555 } | |
556 } | |
557 } | |
558 break; | |
559 // Other ref_kinds are already fully checked in previous pass. | |
560 } | |
561 break; | |
562 } | |
563 case JVM_CONSTANT_MethodType: { | |
564 symbolHandle no_name = vmSymbolHandles::type_name(); // place holder | |
565 symbolHandle signature(THREAD, cp->method_type_signature_at(index)); | |
566 verify_legal_method_signature(no_name, signature, CHECK_(nullHandle)); | |
567 break; | |
568 } | |
455 } // end of switch | 569 } // end of switch |
456 } // end of for | 570 } // end of for |
457 | 571 |
458 return cp; | 572 return cp; |
459 } | 573 } |
465 switch (cp->tag_at(index).value()) { | 579 switch (cp->tag_at(index).value()) { |
466 | 580 |
467 case JVM_CONSTANT_UnresolvedClass : | 581 case JVM_CONSTANT_UnresolvedClass : |
468 // Patching a class means pre-resolving it. | 582 // Patching a class means pre-resolving it. |
469 // The name in the constant pool is ignored. | 583 // The name in the constant pool is ignored. |
470 if (patch->klass() == SystemDictionary::Class_klass()) { // %%% java_lang_Class::is_instance | 584 if (java_lang_Class::is_instance(patch())) { |
471 guarantee_property(!java_lang_Class::is_primitive(patch()), | 585 guarantee_property(!java_lang_Class::is_primitive(patch()), |
472 "Illegal class patch at %d in class file %s", | 586 "Illegal class patch at %d in class file %s", |
473 index, CHECK); | 587 index, CHECK); |
474 cp->klass_at_put(index, java_lang_Class::as_klassOop(patch())); | 588 cp->klass_at_put(index, java_lang_Class::as_klassOop(patch())); |
475 } else { | 589 } else { |