comparison src/share/vm/classfile/classFileParser.cpp @ 2177:3582bf76420e

6990754: Use native memory and reference counting to implement SymbolTable Summary: move symbols from permgen into C heap and reference count them Reviewed-by: never, acorn, jmasa, stefank
author coleenp
date Thu, 27 Jan 2011 16:11:27 -0800
parents ef3c5db0b3ae
children c5a923563727
comparison
equal deleted inserted replaced
2176:27e4ea99855d 2177:3582bf76420e
39 #include "oops/instanceKlass.hpp" 39 #include "oops/instanceKlass.hpp"
40 #include "oops/klass.inline.hpp" 40 #include "oops/klass.inline.hpp"
41 #include "oops/klassOop.hpp" 41 #include "oops/klassOop.hpp"
42 #include "oops/klassVtable.hpp" 42 #include "oops/klassVtable.hpp"
43 #include "oops/methodOop.hpp" 43 #include "oops/methodOop.hpp"
44 #include "oops/symbolOop.hpp" 44 #include "oops/symbol.hpp"
45 #include "prims/jvmtiExport.hpp" 45 #include "prims/jvmtiExport.hpp"
46 #include "runtime/javaCalls.hpp" 46 #include "runtime/javaCalls.hpp"
47 #include "runtime/perfData.hpp" 47 #include "runtime/perfData.hpp"
48 #include "runtime/reflection.hpp" 48 #include "runtime/reflection.hpp"
49 #include "runtime/signature.hpp" 49 #include "runtime/signature.hpp"
265 utf8_buffer = (u1*) str; 265 utf8_buffer = (u1*) str;
266 utf8_length = (int) strlen(str); 266 utf8_length = (int) strlen(str);
267 } 267 }
268 268
269 unsigned int hash; 269 unsigned int hash;
270 symbolOop result = SymbolTable::lookup_only((char*)utf8_buffer, utf8_length, hash); 270 Symbol* result = SymbolTable::lookup_only((char*)utf8_buffer, utf8_length, hash);
271 if (result == NULL) { 271 if (result == NULL) {
272 names[names_count] = (char*)utf8_buffer; 272 names[names_count] = (char*)utf8_buffer;
273 lengths[names_count] = utf8_length; 273 lengths[names_count] = utf8_length;
274 indices[names_count] = index; 274 indices[names_count] = index;
275 hashValues[names_count++] = hash; 275 hashValues[names_count++] = hash;
276 if (names_count == SymbolTable::symbol_alloc_batch_size) { 276 if (names_count == SymbolTable::symbol_alloc_batch_size) {
277 oopFactory::new_symbols(cp, names_count, names, lengths, indices, hashValues, CHECK); 277 SymbolTable::new_symbols(cp, names_count, names, lengths, indices, hashValues, CHECK);
278 names_count = 0; 278 names_count = 0;
279 } 279 }
280 } else { 280 } else {
281 cp->symbol_at_put(index, result); 281 cp->symbol_at_put(index, result);
282 } 282 }
289 } 289 }
290 } 290 }
291 291
292 // Allocate the remaining symbols 292 // Allocate the remaining symbols
293 if (names_count > 0) { 293 if (names_count > 0) {
294 oopFactory::new_symbols(cp, names_count, names, lengths, indices, hashValues, CHECK); 294 SymbolTable::new_symbols(cp, names_count, names, lengths, indices, hashValues, CHECK);
295 } 295 }
296 296
297 // Copy _current pointer of local copy back to stream(). 297 // Copy _current pointer of local copy back to stream().
298 #ifdef ASSERT 298 #ifdef ASSERT
299 assert(cfs0->current() == old_current, "non-exclusive use of stream()"); 299 assert(cfs0->current() == old_current, "non-exclusive use of stream()");
300 #endif 300 #endif
301 cfs0->set_current(cfs1.current()); 301 cfs0->set_current(cfs1.current());
302 } 302 }
303
304 // This class unreferences constant pool symbols if an error has occurred
305 // while parsing the class before it is assigned into the class.
306 // If it gets an error after that it is unloaded and the constant pool will
307 // be cleaned up then.
308 class ConstantPoolCleaner : public StackObj {
309 constantPoolHandle _cphandle;
310 bool _in_error;
311 public:
312 ConstantPoolCleaner(constantPoolHandle cp) : _cphandle(cp), _in_error(true) {}
313 ~ConstantPoolCleaner() {
314 if (_in_error && _cphandle.not_null()) {
315 _cphandle->unreference_symbols();
316 }
317 }
318 void set_in_error(bool clean) { _in_error = clean; }
319 };
303 320
304 bool inline valid_cp_range(int index, int length) { return (index > 0 && index < length); } 321 bool inline valid_cp_range(int index, int length) { return (index > 0 && index < length); }
305 322
306 constantPoolHandle ClassFileParser::parse_constant_pool(TRAPS) { 323 constantPoolHandle ClassFileParser::parse_constant_pool(TRAPS) {
307 ClassFileStream* cfs = stream(); 324 ClassFileStream* cfs = stream();
317 methodOopDesc::IsSafeConc, 334 methodOopDesc::IsSafeConc,
318 CHECK_(nullHandle)); 335 CHECK_(nullHandle));
319 constantPoolHandle cp (THREAD, constant_pool); 336 constantPoolHandle cp (THREAD, constant_pool);
320 337
321 cp->set_partially_loaded(); // Enables heap verify to work on partial constantPoolOops 338 cp->set_partially_loaded(); // Enables heap verify to work on partial constantPoolOops
339 ConstantPoolCleaner cp_in_error(cp); // set constant pool to be cleaned up.
322 340
323 // parsing constant pool entries 341 // parsing constant pool entries
324 parse_constant_pool_entries(cp, length, CHECK_(nullHandle)); 342 parse_constant_pool_entries(cp, length, CHECK_(nullHandle));
325 343
326 int index = 1; // declared outside of loops for portability 344 int index = 1; // declared outside of loops for portability
409 check_property( 427 check_property(
410 valid_cp_range(string_index, length) && 428 valid_cp_range(string_index, length) &&
411 cp->tag_at(string_index).is_utf8(), 429 cp->tag_at(string_index).is_utf8(),
412 "Invalid constant pool index %u in class file %s", 430 "Invalid constant pool index %u in class file %s",
413 string_index, CHECK_(nullHandle)); 431 string_index, CHECK_(nullHandle));
414 symbolOop sym = cp->symbol_at(string_index); 432 Symbol* sym = cp->symbol_at(string_index);
415 cp->unresolved_string_at_put(index, sym); 433 cp->unresolved_string_at_put(index, sym);
416 } 434 }
417 break; 435 break;
418 case JVM_CONSTANT_MethodHandle : 436 case JVM_CONSTANT_MethodHandle :
419 { 437 {
524 index, CHECK_(nullHandle)); 542 index, CHECK_(nullHandle));
525 } 543 }
526 } 544 }
527 545
528 if (!_need_verify) { 546 if (!_need_verify) {
547 cp_in_error.set_in_error(false);
529 return cp; 548 return cp;
530 } 549 }
531 550
532 // second verification pass - checks the strings are of the right format. 551 // second verification pass - checks the strings are of the right format.
533 // but not yet to the other entries 552 // but not yet to the other entries
534 for (index = 1; index < length; index++) { 553 for (index = 1; index < length; index++) {
535 jbyte tag = cp->tag_at(index).value(); 554 jbyte tag = cp->tag_at(index).value();
536 switch (tag) { 555 switch (tag) {
537 case JVM_CONSTANT_UnresolvedClass: { 556 case JVM_CONSTANT_UnresolvedClass: {
538 symbolHandle class_name(THREAD, cp->unresolved_klass_at(index)); 557 Symbol* class_name = cp->unresolved_klass_at(index);
539 // check the name, even if _cp_patches will overwrite it 558 // check the name, even if _cp_patches will overwrite it
540 verify_legal_class_name(class_name, CHECK_(nullHandle)); 559 verify_legal_class_name(class_name, CHECK_(nullHandle));
541 break; 560 break;
542 } 561 }
543 case JVM_CONSTANT_NameAndType: { 562 case JVM_CONSTANT_NameAndType: {
544 if (_need_verify && _major_version >= JAVA_7_VERSION) { 563 if (_need_verify && _major_version >= JAVA_7_VERSION) {
545 int sig_index = cp->signature_ref_index_at(index); 564 int sig_index = cp->signature_ref_index_at(index);
546 int name_index = cp->name_ref_index_at(index); 565 int name_index = cp->name_ref_index_at(index);
547 symbolHandle name(THREAD, cp->symbol_at(name_index)); 566 Symbol* name = cp->symbol_at(name_index);
548 symbolHandle sig(THREAD, cp->symbol_at(sig_index)); 567 Symbol* sig = cp->symbol_at(sig_index);
549 if (sig->byte_at(0) == JVM_SIGNATURE_FUNC) { 568 if (sig->byte_at(0) == JVM_SIGNATURE_FUNC) {
550 verify_legal_method_signature(name, sig, CHECK_(nullHandle)); 569 verify_legal_method_signature(name, sig, CHECK_(nullHandle));
551 } else { 570 } else {
552 verify_legal_field_signature(name, sig, CHECK_(nullHandle)); 571 verify_legal_field_signature(name, sig, CHECK_(nullHandle));
553 } 572 }
560 int name_and_type_ref_index = cp->name_and_type_ref_index_at(index); 579 int name_and_type_ref_index = cp->name_and_type_ref_index_at(index);
561 // already verified to be utf8 580 // already verified to be utf8
562 int name_ref_index = cp->name_ref_index_at(name_and_type_ref_index); 581 int name_ref_index = cp->name_ref_index_at(name_and_type_ref_index);
563 // already verified to be utf8 582 // already verified to be utf8
564 int signature_ref_index = cp->signature_ref_index_at(name_and_type_ref_index); 583 int signature_ref_index = cp->signature_ref_index_at(name_and_type_ref_index);
565 symbolHandle name(THREAD, cp->symbol_at(name_ref_index)); 584 Symbol* name = cp->symbol_at(name_ref_index);
566 symbolHandle signature(THREAD, cp->symbol_at(signature_ref_index)); 585 Symbol* signature = cp->symbol_at(signature_ref_index);
567 if (tag == JVM_CONSTANT_Fieldref) { 586 if (tag == JVM_CONSTANT_Fieldref) {
568 verify_legal_field_name(name, CHECK_(nullHandle)); 587 verify_legal_field_name(name, CHECK_(nullHandle));
569 if (_need_verify && _major_version >= JAVA_7_VERSION) { 588 if (_need_verify && _major_version >= JAVA_7_VERSION) {
570 // Signature is verified above, when iterating NameAndType_info. 589 // Signature is verified above, when iterating NameAndType_info.
571 // Need only to be sure it's the right type. 590 // Need only to be sure it's the right type.
588 } else { 607 } else {
589 verify_legal_method_signature(name, signature, CHECK_(nullHandle)); 608 verify_legal_method_signature(name, signature, CHECK_(nullHandle));
590 } 609 }
591 if (tag == JVM_CONSTANT_Methodref) { 610 if (tag == JVM_CONSTANT_Methodref) {
592 // 4509014: If a class method name begins with '<', it must be "<init>". 611 // 4509014: If a class method name begins with '<', it must be "<init>".
593 assert(!name.is_null(), "method name in constant pool is null"); 612 assert(name != NULL, "method name in constant pool is null");
594 unsigned int name_len = name->utf8_length(); 613 unsigned int name_len = name->utf8_length();
595 assert(name_len > 0, "bad method name"); // already verified as legal name 614 assert(name_len > 0, "bad method name"); // already verified as legal name
596 if (name->byte_at(0) == '<') { 615 if (name->byte_at(0) == '<') {
597 if (name() != vmSymbols::object_initializer_name()) { 616 if (name != vmSymbols::object_initializer_name()) {
598 classfile_parse_error( 617 classfile_parse_error(
599 "Bad method name at constant pool index %u in class file %s", 618 "Bad method name at constant pool index %u in class file %s",
600 name_ref_index, CHECK_(nullHandle)); 619 name_ref_index, CHECK_(nullHandle));
601 } 620 }
602 } 621 }
613 case JVM_REF_invokeSpecial: 632 case JVM_REF_invokeSpecial:
614 case JVM_REF_newInvokeSpecial: 633 case JVM_REF_newInvokeSpecial:
615 { 634 {
616 int name_and_type_ref_index = cp->name_and_type_ref_index_at(ref_index); 635 int name_and_type_ref_index = cp->name_and_type_ref_index_at(ref_index);
617 int name_ref_index = cp->name_ref_index_at(name_and_type_ref_index); 636 int name_ref_index = cp->name_ref_index_at(name_and_type_ref_index);
618 symbolHandle name(THREAD, cp->symbol_at(name_ref_index)); 637 Symbol* name = cp->symbol_at(name_ref_index);
619 if (ref_kind == JVM_REF_newInvokeSpecial) { 638 if (ref_kind == JVM_REF_newInvokeSpecial) {
620 if (name() != vmSymbols::object_initializer_name()) { 639 if (name != vmSymbols::object_initializer_name()) {
621 classfile_parse_error( 640 classfile_parse_error(
622 "Bad constructor name at constant pool index %u in class file %s", 641 "Bad constructor name at constant pool index %u in class file %s",
623 name_ref_index, CHECK_(nullHandle)); 642 name_ref_index, CHECK_(nullHandle));
624 } 643 }
625 } else { 644 } else {
626 if (name() == vmSymbols::object_initializer_name()) { 645 if (name == vmSymbols::object_initializer_name()) {
627 classfile_parse_error( 646 classfile_parse_error(
628 "Bad method name at constant pool index %u in class file %s", 647 "Bad method name at constant pool index %u in class file %s",
629 name_ref_index, CHECK_(nullHandle)); 648 name_ref_index, CHECK_(nullHandle));
630 } 649 }
631 } 650 }
634 // Other ref_kinds are already fully checked in previous pass. 653 // Other ref_kinds are already fully checked in previous pass.
635 } 654 }
636 break; 655 break;
637 } 656 }
638 case JVM_CONSTANT_MethodType: { 657 case JVM_CONSTANT_MethodType: {
639 symbolHandle no_name = vmSymbolHandles::type_name(); // place holder 658 Symbol* no_name = vmSymbols::type_name(); // place holder
640 symbolHandle signature(THREAD, cp->method_type_signature_at(index)); 659 Symbol* signature = cp->method_type_signature_at(index);
641 verify_legal_method_signature(no_name, signature, CHECK_(nullHandle)); 660 verify_legal_method_signature(no_name, signature, CHECK_(nullHandle));
642 break; 661 break;
643 } 662 }
663 case JVM_CONSTANT_Utf8: {
664 assert(cp->symbol_at(index)->refcount() != 0, "count corrupted");
665 }
644 } // end of switch 666 } // end of switch
645 } // end of for 667 } // end of for
646 668
669 cp_in_error.set_in_error(false);
647 return cp; 670 return cp;
648 } 671 }
649 672
650 673
651 void ClassFileParser::patch_constant_pool(constantPoolHandle cp, int index, Handle patch, TRAPS) { 674 void ClassFileParser::patch_constant_pool(constantPoolHandle cp, int index, Handle patch, TRAPS) {
663 cp->klass_at_put(index, java_lang_Class::as_klassOop(patch())); 686 cp->klass_at_put(index, java_lang_Class::as_klassOop(patch()));
664 } else { 687 } else {
665 guarantee_property(java_lang_String::is_instance(patch()), 688 guarantee_property(java_lang_String::is_instance(patch()),
666 "Illegal class patch at %d in class file %s", 689 "Illegal class patch at %d in class file %s",
667 index, CHECK); 690 index, CHECK);
668 symbolHandle name = java_lang_String::as_symbol(patch(), CHECK); 691 Symbol* name = java_lang_String::as_symbol(patch(), CHECK);
669 cp->unresolved_klass_at_put(index, name()); 692 cp->unresolved_klass_at_put(index, name);
670 } 693 }
671 break; 694 break;
672 695
673 case JVM_CONSTANT_UnresolvedString : 696 case JVM_CONSTANT_UnresolvedString :
674 // Patching a string means pre-resolving it. 697 // Patching a string means pre-resolving it.
715 738
716 739
717 740
718 class NameSigHash: public ResourceObj { 741 class NameSigHash: public ResourceObj {
719 public: 742 public:
720 symbolOop _name; // name 743 Symbol* _name; // name
721 symbolOop _sig; // signature 744 Symbol* _sig; // signature
722 NameSigHash* _next; // Next entry in hash table 745 NameSigHash* _next; // Next entry in hash table
723 }; 746 };
724 747
725 748
726 #define HASH_ROW_SIZE 256 749 #define HASH_ROW_SIZE 256
727 750
728 unsigned int hash(symbolOop name, symbolOop sig) { 751 unsigned int hash(Symbol* name, Symbol* sig) {
729 unsigned int raw_hash = 0; 752 unsigned int raw_hash = 0;
730 raw_hash += ((unsigned int)(uintptr_t)name) >> (LogHeapWordSize + 2); 753 raw_hash += ((unsigned int)(uintptr_t)name) >> (LogHeapWordSize + 2);
731 raw_hash += ((unsigned int)(uintptr_t)sig) >> LogHeapWordSize; 754 raw_hash += ((unsigned int)(uintptr_t)sig) >> LogHeapWordSize;
732 755
733 return (raw_hash + (unsigned int)(uintptr_t)name) % HASH_ROW_SIZE; 756 return (raw_hash + (unsigned int)(uintptr_t)name) % HASH_ROW_SIZE;
740 763
741 // Return false if the name/sig combination is found in table. 764 // Return false if the name/sig combination is found in table.
742 // Return true if no duplicate is found. And name/sig is added as a new entry in table. 765 // Return true if no duplicate is found. And name/sig is added as a new entry in table.
743 // The old format checker uses heap sort to find duplicates. 766 // The old format checker uses heap sort to find duplicates.
744 // NOTE: caller should guarantee that GC doesn't happen during the life cycle 767 // NOTE: caller should guarantee that GC doesn't happen during the life cycle
745 // of table since we don't expect symbolOop's to move. 768 // of table since we don't expect Symbol*'s to move.
746 bool put_after_lookup(symbolOop name, symbolOop sig, NameSigHash** table) { 769 bool put_after_lookup(Symbol* name, Symbol* sig, NameSigHash** table) {
747 assert(name != NULL, "name in constant pool is NULL"); 770 assert(name != NULL, "name in constant pool is NULL");
748 771
749 // First lookup for duplicates 772 // First lookup for duplicates
750 int index = hash(name, sig); 773 int index = hash(name, sig);
751 NameSigHash* entry = table[index]; 774 NameSigHash* entry = table[index];
771 794
772 objArrayHandle ClassFileParser::parse_interfaces(constantPoolHandle cp, 795 objArrayHandle ClassFileParser::parse_interfaces(constantPoolHandle cp,
773 int length, 796 int length,
774 Handle class_loader, 797 Handle class_loader,
775 Handle protection_domain, 798 Handle protection_domain,
776 symbolHandle class_name, 799 Symbol* class_name,
777 TRAPS) { 800 TRAPS) {
778 ClassFileStream* cfs = stream(); 801 ClassFileStream* cfs = stream();
779 assert(length > 0, "only called for length>0"); 802 assert(length > 0, "only called for length>0");
780 objArrayHandle nullHandle; 803 objArrayHandle nullHandle;
781 objArrayOop interface_oop = oopFactory::new_system_objArray(length, CHECK_(nullHandle)); 804 objArrayOop interface_oop = oopFactory::new_system_objArray(length, CHECK_(nullHandle));
791 "Interface name has bad constant pool index %u in class file %s", 814 "Interface name has bad constant pool index %u in class file %s",
792 interface_index, CHECK_(nullHandle)); 815 interface_index, CHECK_(nullHandle));
793 if (cp->tag_at(interface_index).is_klass()) { 816 if (cp->tag_at(interface_index).is_klass()) {
794 interf = KlassHandle(THREAD, cp->resolved_klass_at(interface_index)); 817 interf = KlassHandle(THREAD, cp->resolved_klass_at(interface_index));
795 } else { 818 } else {
796 symbolHandle unresolved_klass (THREAD, cp->klass_name_at(interface_index)); 819 Symbol* unresolved_klass = cp->klass_name_at(interface_index);
797 820
798 // Don't need to check legal name because it's checked when parsing constant pool. 821 // Don't need to check legal name because it's checked when parsing constant pool.
799 // But need to make sure it's not an array type. 822 // But need to make sure it's not an array type.
800 guarantee_property(unresolved_klass->byte_at(0) != JVM_SIGNATURE_ARRAY, 823 guarantee_property(unresolved_klass->byte_at(0) != JVM_SIGNATURE_ARRAY,
801 "Bad interface name in class file %s", CHECK_(nullHandle)); 824 "Bad interface name in class file %s", CHECK_(nullHandle));
828 bool dup = false; 851 bool dup = false;
829 { 852 {
830 debug_only(No_Safepoint_Verifier nsv;) 853 debug_only(No_Safepoint_Verifier nsv;)
831 for (index = 0; index < length; index++) { 854 for (index = 0; index < length; index++) {
832 klassOop k = (klassOop)interfaces->obj_at(index); 855 klassOop k = (klassOop)interfaces->obj_at(index);
833 symbolOop name = instanceKlass::cast(k)->name(); 856 Symbol* name = instanceKlass::cast(k)->name();
834 // If no duplicates, add (name, NULL) in hashtable interface_names. 857 // If no duplicates, add (name, NULL) in hashtable interface_names.
835 if (!put_after_lookup(name, NULL, interface_names)) { 858 if (!put_after_lookup(name, NULL, interface_names)) {
836 dup = true; 859 dup = true;
837 break; 860 break;
838 } 861 }
906 check_property(valid_cp_range(attribute_name_index, cp->length()) && 929 check_property(valid_cp_range(attribute_name_index, cp->length()) &&
907 cp->tag_at(attribute_name_index).is_utf8(), 930 cp->tag_at(attribute_name_index).is_utf8(),
908 "Invalid field attribute index %u in class file %s", 931 "Invalid field attribute index %u in class file %s",
909 attribute_name_index, 932 attribute_name_index,
910 CHECK); 933 CHECK);
911 symbolOop attribute_name = cp->symbol_at(attribute_name_index); 934 Symbol* attribute_name = cp->symbol_at(attribute_name_index);
912 if (is_static && attribute_name == vmSymbols::tag_constant_value()) { 935 if (is_static && attribute_name == vmSymbols::tag_constant_value()) {
913 // ignore if non-static 936 // ignore if non-static
914 if (constantvalue_index != 0) { 937 if (constantvalue_index != 0) {
915 classfile_parse_error("Duplicate ConstantValue attribute in class file %s", CHECK); 938 classfile_parse_error("Duplicate ConstantValue attribute in class file %s", CHECK);
916 } 939 }
1029 int cp_size = cp->length(); 1052 int cp_size = cp->length();
1030 check_property( 1053 check_property(
1031 valid_cp_range(name_index, cp_size) && cp->tag_at(name_index).is_utf8(), 1054 valid_cp_range(name_index, cp_size) && cp->tag_at(name_index).is_utf8(),
1032 "Invalid constant pool index %u for field name in class file %s", 1055 "Invalid constant pool index %u for field name in class file %s",
1033 name_index, CHECK_(nullHandle)); 1056 name_index, CHECK_(nullHandle));
1034 symbolHandle name(THREAD, cp->symbol_at(name_index)); 1057 Symbol* name = cp->symbol_at(name_index);
1035 verify_legal_field_name(name, CHECK_(nullHandle)); 1058 verify_legal_field_name(name, CHECK_(nullHandle));
1036 1059
1037 u2 signature_index = cfs->get_u2_fast(); 1060 u2 signature_index = cfs->get_u2_fast();
1038 check_property( 1061 check_property(
1039 valid_cp_range(signature_index, cp_size) && 1062 valid_cp_range(signature_index, cp_size) &&
1040 cp->tag_at(signature_index).is_utf8(), 1063 cp->tag_at(signature_index).is_utf8(),
1041 "Invalid constant pool index %u for field signature in class file %s", 1064 "Invalid constant pool index %u for field signature in class file %s",
1042 signature_index, CHECK_(nullHandle)); 1065 signature_index, CHECK_(nullHandle));
1043 symbolHandle sig(THREAD, cp->symbol_at(signature_index)); 1066 Symbol* sig = cp->symbol_at(signature_index);
1044 verify_legal_field_signature(name, sig, CHECK_(nullHandle)); 1067 verify_legal_field_signature(name, sig, CHECK_(nullHandle));
1045 1068
1046 u2 constantvalue_index = 0; 1069 u2 constantvalue_index = 0;
1047 bool is_synthetic = false; 1070 bool is_synthetic = false;
1048 u2 generic_signature_index = 0; 1071 u2 generic_signature_index = 0;
1164 bool dup = false; 1187 bool dup = false;
1165 { 1188 {
1166 debug_only(No_Safepoint_Verifier nsv;) 1189 debug_only(No_Safepoint_Verifier nsv;)
1167 for (int i = 0; i < length*instanceKlass::next_offset; i += instanceKlass::next_offset) { 1190 for (int i = 0; i < length*instanceKlass::next_offset; i += instanceKlass::next_offset) {
1168 int name_index = fields->ushort_at(i + instanceKlass::name_index_offset); 1191 int name_index = fields->ushort_at(i + instanceKlass::name_index_offset);
1169 symbolOop name = cp->symbol_at(name_index); 1192 Symbol* name = cp->symbol_at(name_index);
1170 int sig_index = fields->ushort_at(i + instanceKlass::signature_index_offset); 1193 int sig_index = fields->ushort_at(i + instanceKlass::signature_index_offset);
1171 symbolOop sig = cp->symbol_at(sig_index); 1194 Symbol* sig = cp->symbol_at(sig_index);
1172 // If no duplicates, add name/signature in hashtable names_and_sigs. 1195 // If no duplicates, add name/signature in hashtable names_and_sigs.
1173 if (!put_after_lookup(name, sig, names_and_sigs)) { 1196 if (!put_after_lookup(name, sig, names_and_sigs)) {
1174 dup = true; 1197 dup = true;
1175 break; 1198 break;
1176 } 1199 }
1420 valid_cp_range(descriptor_index, cp_size) && 1443 valid_cp_range(descriptor_index, cp_size) &&
1421 cp->tag_at(descriptor_index).is_utf8(), 1444 cp->tag_at(descriptor_index).is_utf8(),
1422 "Signature index %u in %s has bad constant type in class file %s", 1445 "Signature index %u in %s has bad constant type in class file %s",
1423 descriptor_index, tbl_name, CHECK_NULL); 1446 descriptor_index, tbl_name, CHECK_NULL);
1424 1447
1425 symbolHandle name(THREAD, cp->symbol_at(name_index)); 1448 Symbol* name = cp->symbol_at(name_index);
1426 symbolHandle sig(THREAD, cp->symbol_at(descriptor_index)); 1449 Symbol* sig = cp->symbol_at(descriptor_index);
1427 verify_legal_field_name(name, CHECK_NULL); 1450 verify_legal_field_name(name, CHECK_NULL);
1428 u2 extra_slot = 0; 1451 u2 extra_slot = 0;
1429 if (!isLVTT) { 1452 if (!isLVTT) {
1430 verify_legal_field_signature(name, sig, CHECK_NULL); 1453 verify_legal_field_signature(name, sig, CHECK_NULL);
1431 1454
1432 // 4894874: check special cases for double and long local variables 1455 // 4894874: check special cases for double and long local variables
1433 if (sig() == vmSymbols::type_signature(T_DOUBLE) || 1456 if (sig == vmSymbols::type_signature(T_DOUBLE) ||
1434 sig() == vmSymbols::type_signature(T_LONG)) { 1457 sig == vmSymbols::type_signature(T_LONG)) {
1435 extra_slot = 1; 1458 extra_slot = 1;
1436 } 1459 }
1437 } 1460 }
1438 guarantee_property((index + extra_slot) < max_locals, 1461 guarantee_property((index + extra_slot) < max_locals,
1439 "Invalid index %u in %s in class file %s", 1462 "Invalid index %u in %s in class file %s",
1537 } 1560 }
1538 return checked_exceptions_start; 1561 return checked_exceptions_start;
1539 } 1562 }
1540 1563
1541 void ClassFileParser::throwIllegalSignature( 1564 void ClassFileParser::throwIllegalSignature(
1542 const char* type, symbolHandle name, symbolHandle sig, TRAPS) { 1565 const char* type, Symbol* name, Symbol* sig, TRAPS) {
1543 ResourceMark rm(THREAD); 1566 ResourceMark rm(THREAD);
1544 Exceptions::fthrow(THREAD_AND_LOCATION, 1567 Exceptions::fthrow(THREAD_AND_LOCATION,
1545 vmSymbols::java_lang_ClassFormatError(), 1568 vmSymbols::java_lang_ClassFormatError(),
1546 "%s \"%s\" in class %s has illegal signature \"%s\"", type, 1569 "%s \"%s\" in class %s has illegal signature \"%s\"", type,
1547 name->as_C_string(), _class_name->as_C_string(), sig->as_C_string()); 1570 name->as_C_string(), _class_name->as_C_string(), sig->as_C_string());
1578 check_property( 1601 check_property(
1579 valid_cp_range(name_index, cp_size) && 1602 valid_cp_range(name_index, cp_size) &&
1580 cp->tag_at(name_index).is_utf8(), 1603 cp->tag_at(name_index).is_utf8(),
1581 "Illegal constant pool index %u for method name in class file %s", 1604 "Illegal constant pool index %u for method name in class file %s",
1582 name_index, CHECK_(nullHandle)); 1605 name_index, CHECK_(nullHandle));
1583 symbolHandle name(THREAD, cp->symbol_at(name_index)); 1606 Symbol* name = cp->symbol_at(name_index);
1584 verify_legal_method_name(name, CHECK_(nullHandle)); 1607 verify_legal_method_name(name, CHECK_(nullHandle));
1585 1608
1586 u2 signature_index = cfs->get_u2_fast(); 1609 u2 signature_index = cfs->get_u2_fast();
1587 guarantee_property( 1610 guarantee_property(
1588 valid_cp_range(signature_index, cp_size) && 1611 valid_cp_range(signature_index, cp_size) &&
1589 cp->tag_at(signature_index).is_utf8(), 1612 cp->tag_at(signature_index).is_utf8(),
1590 "Illegal constant pool index %u for method signature in class file %s", 1613 "Illegal constant pool index %u for method signature in class file %s",
1591 signature_index, CHECK_(nullHandle)); 1614 signature_index, CHECK_(nullHandle));
1592 symbolHandle signature(THREAD, cp->symbol_at(signature_index)); 1615 Symbol* signature = cp->symbol_at(signature_index);
1593 1616
1594 AccessFlags access_flags; 1617 AccessFlags access_flags;
1595 if (name == vmSymbols::class_initializer_name()) { 1618 if (name == vmSymbols::class_initializer_name()) {
1596 // We ignore the access flags for a class initializer. (JVM Spec. p. 116) 1619 // We ignore the access flags for a class initializer. (JVM Spec. p. 116)
1597 flags = JVM_ACC_STATIC; 1620 flags = JVM_ACC_STATIC;
1658 valid_cp_range(method_attribute_name_index, cp_size) && 1681 valid_cp_range(method_attribute_name_index, cp_size) &&
1659 cp->tag_at(method_attribute_name_index).is_utf8(), 1682 cp->tag_at(method_attribute_name_index).is_utf8(),
1660 "Invalid method attribute name index %u in class file %s", 1683 "Invalid method attribute name index %u in class file %s",
1661 method_attribute_name_index, CHECK_(nullHandle)); 1684 method_attribute_name_index, CHECK_(nullHandle));
1662 1685
1663 symbolOop method_attribute_name = cp->symbol_at(method_attribute_name_index); 1686 Symbol* method_attribute_name = cp->symbol_at(method_attribute_name_index);
1664 if (method_attribute_name == vmSymbols::tag_code()) { 1687 if (method_attribute_name == vmSymbols::tag_code()) {
1665 // Parse Code attribute 1688 // Parse Code attribute
1666 if (_need_verify) { 1689 if (_need_verify) {
1667 guarantee_property(!access_flags.is_native() && !access_flags.is_abstract(), 1690 guarantee_property(!access_flags.is_native() && !access_flags.is_abstract(),
1668 "Code attribute in native or abstract methods in class file %s", 1691 "Code attribute in native or abstract methods in class file %s",
2055 annotation_default_length, 2078 annotation_default_length,
2056 NULL, 2079 NULL,
2057 0, 2080 0,
2058 CHECK_(nullHandle)); 2081 CHECK_(nullHandle));
2059 2082
2060 if (name() == vmSymbols::finalize_method_name() && 2083 if (name == vmSymbols::finalize_method_name() &&
2061 signature() == vmSymbols::void_method_signature()) { 2084 signature == vmSymbols::void_method_signature()) {
2062 if (m->is_empty_method()) { 2085 if (m->is_empty_method()) {
2063 _has_empty_finalizer = true; 2086 _has_empty_finalizer = true;
2064 } else { 2087 } else {
2065 _has_finalizer = true; 2088 _has_finalizer = true;
2066 } 2089 }
2067 } 2090 }
2068 if (name() == vmSymbols::object_initializer_name() && 2091 if (name == vmSymbols::object_initializer_name() &&
2069 signature() == vmSymbols::void_method_signature() && 2092 signature == vmSymbols::void_method_signature() &&
2070 m->is_vanilla_constructor()) { 2093 m->is_vanilla_constructor()) {
2071 _has_vanilla_constructor = true; 2094 _has_vanilla_constructor = true;
2072 } 2095 }
2073 2096
2074 if (EnableMethodHandles && (m->is_method_handle_invoke() || 2097 if (EnableMethodHandles && (m->is_method_handle_invoke() ||
2191 assert(!m->valid_vtable_index(), "vtable index should not be set"); 2214 assert(!m->valid_vtable_index(), "vtable index should not be set");
2192 m->set_vtable_index(index); 2215 m->set_vtable_index(index);
2193 } 2216 }
2194 } 2217 }
2195 // Sort method array by ascending method name (for faster lookups & vtable construction) 2218 // Sort method array by ascending method name (for faster lookups & vtable construction)
2196 // Note that the ordering is not alphabetical, see symbolOopDesc::fast_compare 2219 // Note that the ordering is not alphabetical, see Symbol::fast_compare
2197 methodOopDesc::sort_methods(methods(), 2220 methodOopDesc::sort_methods(methods(),
2198 methods_annotations(), 2221 methods_annotations(),
2199 methods_parameter_annotations(), 2222 methods_parameter_annotations(),
2200 methods_default_annotations()); 2223 methods_default_annotations());
2201 2224
2240 2263
2241 // Don't bother storing it if there is no way to retrieve it 2264 // Don't bother storing it if there is no way to retrieve it
2242 if (JvmtiExport::can_get_source_debug_extension()) { 2265 if (JvmtiExport::can_get_source_debug_extension()) {
2243 // Optimistically assume that only 1 byte UTF format is used 2266 // Optimistically assume that only 1 byte UTF format is used
2244 // (common case) 2267 // (common case)
2245 symbolOop sde_symbol = oopFactory::new_symbol((char*)sde_buffer, 2268 TempNewSymbol sde_symbol = SymbolTable::new_symbol((const char*)sde_buffer, length, CHECK);
2246 length, CHECK);
2247 k->set_source_debug_extension(sde_symbol); 2269 k->set_source_debug_extension(sde_symbol);
2270 // Note that set_source_debug_extension() increments the reference count
2271 // for its copy of the Symbol*, so use a TempNewSymbol here.
2248 } 2272 }
2249 // Got utf8 string, set stream position forward 2273 // Got utf8 string, set stream position forward
2250 cfs->skip_u1(length, CHECK); 2274 cfs->skip_u1(length, CHECK);
2251 } 2275 }
2252 2276
2438 check_property( 2462 check_property(
2439 valid_cp_range(attribute_name_index, cp->length()) && 2463 valid_cp_range(attribute_name_index, cp->length()) &&
2440 cp->tag_at(attribute_name_index).is_utf8(), 2464 cp->tag_at(attribute_name_index).is_utf8(),
2441 "Attribute name has bad constant pool index %u in class file %s", 2465 "Attribute name has bad constant pool index %u in class file %s",
2442 attribute_name_index, CHECK); 2466 attribute_name_index, CHECK);
2443 symbolOop tag = cp->symbol_at(attribute_name_index); 2467 Symbol* tag = cp->symbol_at(attribute_name_index);
2444 if (tag == vmSymbols::tag_source_file()) { 2468 if (tag == vmSymbols::tag_source_file()) {
2445 // Check for SourceFile tag 2469 // Check for SourceFile tag
2446 if (_need_verify) { 2470 if (_need_verify) {
2447 guarantee_property(attribute_length == 2, "Wrong SourceFile attribute length in class file %s", CHECK); 2471 guarantee_property(attribute_length == 2, "Wrong SourceFile attribute length in class file %s", CHECK);
2448 } 2472 }
2605 h_k()->long_field_put(fd->offset(), fd->long_initial_value()); 2629 h_k()->long_field_put(fd->offset(), fd->long_initial_value());
2606 break; 2630 break;
2607 case T_OBJECT: 2631 case T_OBJECT:
2608 { 2632 {
2609 #ifdef ASSERT 2633 #ifdef ASSERT
2610 symbolOop sym = oopFactory::new_symbol("Ljava/lang/String;", CHECK); 2634 TempNewSymbol sym = SymbolTable::new_symbol("Ljava/lang/String;", CHECK);
2611 assert(fd->signature() == sym, "just checking"); 2635 assert(fd->signature() == sym, "just checking");
2612 #endif 2636 #endif
2613 oop string = fd->string_initial_value(CHECK); 2637 oop string = fd->string_initial_value(CHECK);
2614 h_k()->obj_field_put(fd->offset(), string); 2638 h_k()->obj_field_put(fd->offset(), string);
2615 } 2639 }
2648 for (int i = 0; i < n; i += instanceKlass::next_offset ) { 2672 for (int i = 0; i < n; i += instanceKlass::next_offset ) {
2649 int name_index = 2673 int name_index =
2650 (*fields_ptr)()->ushort_at(i + instanceKlass::name_index_offset); 2674 (*fields_ptr)()->ushort_at(i + instanceKlass::name_index_offset);
2651 int sig_index = 2675 int sig_index =
2652 (*fields_ptr)()->ushort_at(i + instanceKlass::signature_index_offset); 2676 (*fields_ptr)()->ushort_at(i + instanceKlass::signature_index_offset);
2653 symbolOop f_name = cp->symbol_at(name_index); 2677 Symbol* f_name = cp->symbol_at(name_index);
2654 symbolOop f_sig = cp->symbol_at(sig_index); 2678 Symbol* f_sig = cp->symbol_at(sig_index);
2655 if (f_sig == vmSymbols::reference_signature() && reference_index == 0) { 2679 if (f_sig == vmSymbols::reference_signature() && reference_index == 0) {
2656 // Save the index for reference signature for later use. 2680 // Save the index for reference signature for later use.
2657 // The fake discovered field does not entries in the 2681 // The fake discovered field does not entries in the
2658 // constant pool so the index for its signature cannot 2682 // constant pool so the index for its signature cannot
2659 // be extracted from the constant pool. It will need 2683 // be extracted from the constant pool. It will need
2803 bool found_vmentry = false; 2827 bool found_vmentry = false;
2804 for (int i = 0; i < fields->length(); i += instanceKlass::next_offset) { 2828 for (int i = 0; i < fields->length(); i += instanceKlass::next_offset) {
2805 int name_index = fields->ushort_at(i + instanceKlass::name_index_offset); 2829 int name_index = fields->ushort_at(i + instanceKlass::name_index_offset);
2806 int sig_index = fields->ushort_at(i + instanceKlass::signature_index_offset); 2830 int sig_index = fields->ushort_at(i + instanceKlass::signature_index_offset);
2807 int acc_flags = fields->ushort_at(i + instanceKlass::access_flags_offset); 2831 int acc_flags = fields->ushort_at(i + instanceKlass::access_flags_offset);
2808 symbolOop f_name = cp->symbol_at(name_index); 2832 Symbol* f_name = cp->symbol_at(name_index);
2809 symbolOop f_sig = cp->symbol_at(sig_index); 2833 Symbol* f_sig = cp->symbol_at(sig_index);
2810
2811 if (f_name == vmSymbols::vmentry_name() && (acc_flags & JVM_ACC_STATIC) == 0) { 2834 if (f_name == vmSymbols::vmentry_name() && (acc_flags & JVM_ACC_STATIC) == 0) {
2812 if (f_sig == vmSymbols::machine_word_signature()) { 2835 if (f_sig == vmSymbols::machine_word_signature()) {
2813 // If the signature of vmentry is already changed, we're done. 2836 // If the signature of vmentry is already changed, we're done.
2814 found_vmentry = true; 2837 found_vmentry = true;
2815 break; 2838 break;
2839 THROW_MSG(vmSymbols::java_lang_VirtualMachineError(), 2862 THROW_MSG(vmSymbols::java_lang_VirtualMachineError(),
2840 "missing vmentry byte field in java.dyn.MethodHandle"); 2863 "missing vmentry byte field in java.dyn.MethodHandle");
2841 } 2864 }
2842 2865
2843 2866
2844 instanceKlassHandle ClassFileParser::parseClassFile(symbolHandle name, 2867 instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
2845 Handle class_loader, 2868 Handle class_loader,
2846 Handle protection_domain, 2869 Handle protection_domain,
2847 KlassHandle host_klass, 2870 KlassHandle host_klass,
2848 GrowableArray<Handle>* cp_patches, 2871 GrowableArray<Handle>* cp_patches,
2849 symbolHandle& parsed_name, 2872 TempNewSymbol& parsed_name,
2850 bool verify, 2873 bool verify,
2851 TRAPS) { 2874 TRAPS) {
2852 // So that JVMTI can cache class file in the state before retransformable agents 2875 // So that JVMTI can cache class file in the state before retransformable agents
2853 // have modified it 2876 // have modified it
2854 unsigned char *cached_class_file_bytes = NULL; 2877 unsigned char *cached_class_file_bytes = NULL;
2897 2920
2898 // Set the verify flag in stream 2921 // Set the verify flag in stream
2899 cfs->set_verify(_need_verify); 2922 cfs->set_verify(_need_verify);
2900 2923
2901 // Save the class file name for easier error message printing. 2924 // Save the class file name for easier error message printing.
2902 _class_name = name.not_null()? name : vmSymbolHandles::unknown_class_name(); 2925 _class_name = (name != NULL) ? name : vmSymbols::unknown_class_name();
2903 2926
2904 cfs->guarantee_more(8, CHECK_(nullHandle)); // magic, major, minor 2927 cfs->guarantee_more(8, CHECK_(nullHandle)); // magic, major, minor
2905 // Magic value 2928 // Magic value
2906 u4 magic = cfs->get_u4_fast(); 2929 u4 magic = cfs->get_u4_fast();
2907 guarantee_property(magic == JAVA_CLASSFILE_MAGIC, 2930 guarantee_property(magic == JAVA_CLASSFILE_MAGIC,
2912 u2 minor_version = cfs->get_u2_fast(); 2935 u2 minor_version = cfs->get_u2_fast();
2913 u2 major_version = cfs->get_u2_fast(); 2936 u2 major_version = cfs->get_u2_fast();
2914 2937
2915 // Check version numbers - we check this even with verifier off 2938 // Check version numbers - we check this even with verifier off
2916 if (!is_supported_version(major_version, minor_version)) { 2939 if (!is_supported_version(major_version, minor_version)) {
2917 if (name.is_null()) { 2940 if (name == NULL) {
2918 Exceptions::fthrow( 2941 Exceptions::fthrow(
2919 THREAD_AND_LOCATION, 2942 THREAD_AND_LOCATION,
2920 vmSymbolHandles::java_lang_UnsupportedClassVersionError(), 2943 vmSymbols::java_lang_UnsupportedClassVersionError(),
2921 "Unsupported major.minor version %u.%u", 2944 "Unsupported major.minor version %u.%u",
2922 major_version, 2945 major_version,
2923 minor_version); 2946 minor_version);
2924 } else { 2947 } else {
2925 ResourceMark rm(THREAD); 2948 ResourceMark rm(THREAD);
2926 Exceptions::fthrow( 2949 Exceptions::fthrow(
2927 THREAD_AND_LOCATION, 2950 THREAD_AND_LOCATION,
2928 vmSymbolHandles::java_lang_UnsupportedClassVersionError(), 2951 vmSymbols::java_lang_UnsupportedClassVersionError(),
2929 "%s : Unsupported major.minor version %u.%u", 2952 "%s : Unsupported major.minor version %u.%u",
2930 name->as_C_string(), 2953 name->as_C_string(),
2931 major_version, 2954 major_version,
2932 minor_version); 2955 minor_version);
2933 } 2956 }
2942 // Do not restrict it to jdk1.0 or jdk1.1 to maintain backward compatibility (4982376) 2965 // Do not restrict it to jdk1.0 or jdk1.1 to maintain backward compatibility (4982376)
2943 _relax_verify = Verifier::relax_verify_for(class_loader()); 2966 _relax_verify = Verifier::relax_verify_for(class_loader());
2944 2967
2945 // Constant pool 2968 // Constant pool
2946 constantPoolHandle cp = parse_constant_pool(CHECK_(nullHandle)); 2969 constantPoolHandle cp = parse_constant_pool(CHECK_(nullHandle));
2970 ConstantPoolCleaner error_handler(cp); // set constant pool to be cleaned up.
2971
2947 int cp_size = cp->length(); 2972 int cp_size = cp->length();
2948 2973
2949 cfs->guarantee_more(8, CHECK_(nullHandle)); // flags, this_class, super_class, infs_len 2974 cfs->guarantee_more(8, CHECK_(nullHandle)); // flags, this_class, super_class, infs_len
2950 2975
2951 // Access flags 2976 // Access flags
2966 valid_cp_range(this_class_index, cp_size) && 2991 valid_cp_range(this_class_index, cp_size) &&
2967 cp->tag_at(this_class_index).is_unresolved_klass(), 2992 cp->tag_at(this_class_index).is_unresolved_klass(),
2968 "Invalid this class index %u in constant pool in class file %s", 2993 "Invalid this class index %u in constant pool in class file %s",
2969 this_class_index, CHECK_(nullHandle)); 2994 this_class_index, CHECK_(nullHandle));
2970 2995
2971 symbolHandle class_name (THREAD, cp->unresolved_klass_at(this_class_index)); 2996 Symbol* class_name = cp->unresolved_klass_at(this_class_index);
2972 assert(class_name.not_null(), "class_name can't be null"); 2997 assert(class_name != NULL, "class_name can't be null");
2973 2998
2974 // It's important to set parsed_name *before* resolving the super class. 2999 // It's important to set parsed_name *before* resolving the super class.
2975 // (it's used for cleanup by the caller if parsing fails) 3000 // (it's used for cleanup by the caller if parsing fails)
2976 parsed_name = class_name; 3001 parsed_name = class_name;
3002 // parsed_name is returned and can be used if there's an error, so add to
3003 // its reference count. Caller will decrement the refcount.
3004 parsed_name->increment_refcount();
2977 3005
2978 // Update _class_name which could be null previously to be class_name 3006 // Update _class_name which could be null previously to be class_name
2979 _class_name = class_name; 3007 _class_name = class_name;
2980 3008
2981 // Don't need to check whether this class name is legal or not. 3009 // Don't need to check whether this class name is legal or not.
2991 3019
2992 // release all handles when parsing is done 3020 // release all handles when parsing is done
2993 { HandleMark hm(THREAD); 3021 { HandleMark hm(THREAD);
2994 3022
2995 // Checks if name in class file matches requested name 3023 // Checks if name in class file matches requested name
2996 if (name.not_null() && class_name() != name()) { 3024 if (name != NULL && class_name != name) {
2997 ResourceMark rm(THREAD); 3025 ResourceMark rm(THREAD);
2998 Exceptions::fthrow( 3026 Exceptions::fthrow(
2999 THREAD_AND_LOCATION, 3027 THREAD_AND_LOCATION,
3000 vmSymbolHandles::java_lang_NoClassDefFoundError(), 3028 vmSymbols::java_lang_NoClassDefFoundError(),
3001 "%s (wrong name: %s)", 3029 "%s (wrong name: %s)",
3002 name->as_C_string(), 3030 name->as_C_string(),
3003 class_name->as_C_string() 3031 class_name->as_C_string()
3004 ); 3032 );
3005 return nullHandle; 3033 return nullHandle;
3006 } 3034 }
3007 3035
3008 if (TraceClassLoadingPreorder) { 3036 if (TraceClassLoadingPreorder) {
3009 tty->print("[Loading %s", name()->as_klass_external_name()); 3037 tty->print("[Loading %s", name->as_klass_external_name());
3010 if (cfs->source() != NULL) tty->print(" from %s", cfs->source()); 3038 if (cfs->source() != NULL) tty->print(" from %s", cfs->source());
3011 tty->print_cr("]"); 3039 tty->print_cr("]");
3012 } 3040 }
3013 3041
3014 u2 super_class_index = cfs->get_u2_fast(); 3042 u2 super_class_index = cfs->get_u2_fast();
3015 if (super_class_index == 0) { 3043 if (super_class_index == 0) {
3016 check_property(class_name() == vmSymbols::java_lang_Object(), 3044 check_property(class_name == vmSymbols::java_lang_Object(),
3017 "Invalid superclass index %u in class file %s", 3045 "Invalid superclass index %u in class file %s",
3018 super_class_index, 3046 super_class_index,
3019 CHECK_(nullHandle)); 3047 CHECK_(nullHandle));
3020 } else { 3048 } else {
3021 check_property(valid_cp_range(super_class_index, cp_size) && 3049 check_property(valid_cp_range(super_class_index, cp_size) &&
3073 objArrayHandle methods_parameter_annotations(THREAD, methods_parameter_annotations_oop); 3101 objArrayHandle methods_parameter_annotations(THREAD, methods_parameter_annotations_oop);
3074 objArrayHandle methods_default_annotations(THREAD, methods_default_annotations_oop); 3102 objArrayHandle methods_default_annotations(THREAD, methods_default_annotations_oop);
3075 3103
3076 // We check super class after class file is parsed and format is checked 3104 // We check super class after class file is parsed and format is checked
3077 if (super_class_index > 0 && super_klass.is_null()) { 3105 if (super_class_index > 0 && super_klass.is_null()) {
3078 symbolHandle sk (THREAD, cp->klass_name_at(super_class_index)); 3106 Symbol* sk = cp->klass_name_at(super_class_index);
3079 if (access_flags.is_interface()) { 3107 if (access_flags.is_interface()) {
3080 // Before attempting to resolve the superclass, check for class format 3108 // Before attempting to resolve the superclass, check for class format
3081 // errors not checked yet. 3109 // errors not checked yet.
3082 guarantee_property(sk() == vmSymbols::java_lang_Object(), 3110 guarantee_property(sk == vmSymbols::java_lang_Object(),
3083 "Interfaces must have java.lang.Object as superclass in class file %s", 3111 "Interfaces must have java.lang.Object as superclass in class file %s",
3084 CHECK_(nullHandle)); 3112 CHECK_(nullHandle));
3085 } 3113 }
3086 klassOop k = SystemDictionary::resolve_super_or_fail(class_name, 3114 klassOop k = SystemDictionary::resolve_super_or_fail(class_name,
3087 sk, 3115 sk,
3098 if (super_klass.not_null()) { 3126 if (super_klass.not_null()) {
3099 if (super_klass->is_interface()) { 3127 if (super_klass->is_interface()) {
3100 ResourceMark rm(THREAD); 3128 ResourceMark rm(THREAD);
3101 Exceptions::fthrow( 3129 Exceptions::fthrow(
3102 THREAD_AND_LOCATION, 3130 THREAD_AND_LOCATION,
3103 vmSymbolHandles::java_lang_IncompatibleClassChangeError(), 3131 vmSymbols::java_lang_IncompatibleClassChangeError(),
3104 "class %s has interface %s as super class", 3132 "class %s has interface %s as super class",
3105 class_name->as_klass_external_name(), 3133 class_name->as_klass_external_name(),
3106 super_klass->external_name() 3134 super_klass->external_name()
3107 ); 3135 );
3108 return nullHandle; 3136 return nullHandle;
3191 first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() + 3219 first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() +
3192 nonstatic_field_size * heapOopSize; 3220 nonstatic_field_size * heapOopSize;
3193 next_nonstatic_field_offset = first_nonstatic_field_offset; 3221 next_nonstatic_field_offset = first_nonstatic_field_offset;
3194 3222
3195 // Add fake fields for java.lang.Class instances (also see below) 3223 // Add fake fields for java.lang.Class instances (also see below)
3196 if (class_name() == vmSymbols::java_lang_Class() && class_loader.is_null()) { 3224 if (class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
3197 java_lang_Class_fix_pre(&methods, &fac, CHECK_(nullHandle)); 3225 java_lang_Class_fix_pre(&methods, &fac, CHECK_(nullHandle));
3198 } 3226 }
3199 3227
3200 // adjust the vmentry field declaration in java.dyn.MethodHandle 3228 // adjust the vmentry field declaration in java.dyn.MethodHandle
3201 if (EnableMethodHandles && class_name() == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) { 3229 if (EnableMethodHandles && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
3202 java_dyn_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle)); 3230 java_dyn_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
3203 } 3231 }
3204 3232
3205 // Add a fake "discovered" field if it is not present 3233 // Add a fake "discovered" field if it is not present
3206 // for compatibility with earlier jdk's. 3234 // for compatibility with earlier jdk's.
3207 if (class_name() == vmSymbols::java_lang_ref_Reference() 3235 if (class_name == vmSymbols::java_lang_ref_Reference()
3208 && class_loader.is_null()) { 3236 && class_loader.is_null()) {
3209 java_lang_ref_Reference_fix_pre(&fields, cp, &fac, CHECK_(nullHandle)); 3237 java_lang_ref_Reference_fix_pre(&fields, cp, &fac, CHECK_(nullHandle));
3210 } 3238 }
3211 // end of "discovered" field compactibility fix 3239 // end of "discovered" field compactibility fix
3212 3240
3234 nonstatic_oop_counts = NEW_RESOURCE_ARRAY_IN_THREAD( 3262 nonstatic_oop_counts = NEW_RESOURCE_ARRAY_IN_THREAD(
3235 THREAD, unsigned int, nonstatic_oop_count + 1); 3263 THREAD, unsigned int, nonstatic_oop_count + 1);
3236 3264
3237 // Add fake fields for java.lang.Class instances (also see above). 3265 // Add fake fields for java.lang.Class instances (also see above).
3238 // FieldsAllocationStyle and CompactFields values will be reset to default. 3266 // FieldsAllocationStyle and CompactFields values will be reset to default.
3239 if(class_name() == vmSymbols::java_lang_Class() && class_loader.is_null()) { 3267 if(class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
3240 java_lang_Class_fix_post(&next_nonstatic_field_offset); 3268 java_lang_Class_fix_post(&next_nonstatic_field_offset);
3241 nonstatic_oop_offsets[0] = first_nonstatic_field_offset; 3269 nonstatic_oop_offsets[0] = first_nonstatic_field_offset;
3242 const uint fake_oop_count = (next_nonstatic_field_offset - 3270 const uint fake_oop_count = (next_nonstatic_field_offset -
3243 first_nonstatic_field_offset) / heapOopSize; 3271 first_nonstatic_field_offset) / heapOopSize;
3244 nonstatic_oop_counts[0] = fake_oop_count; 3272 nonstatic_oop_counts[0] = fake_oop_count;
3277 3305
3278 // The next classes have predefined hard-coded fields offsets 3306 // The next classes have predefined hard-coded fields offsets
3279 // (see in JavaClasses::compute_hard_coded_offsets()). 3307 // (see in JavaClasses::compute_hard_coded_offsets()).
3280 // Use default fields allocation order for them. 3308 // Use default fields allocation order for them.
3281 if( (allocation_style != 0 || compact_fields ) && class_loader.is_null() && 3309 if( (allocation_style != 0 || compact_fields ) && class_loader.is_null() &&
3282 (class_name() == vmSymbols::java_lang_AssertionStatusDirectives() || 3310 (class_name == vmSymbols::java_lang_AssertionStatusDirectives() ||
3283 class_name() == vmSymbols::java_lang_Class() || 3311 class_name == vmSymbols::java_lang_Class() ||
3284 class_name() == vmSymbols::java_lang_ClassLoader() || 3312 class_name == vmSymbols::java_lang_ClassLoader() ||
3285 class_name() == vmSymbols::java_lang_ref_Reference() || 3313 class_name == vmSymbols::java_lang_ref_Reference() ||
3286 class_name() == vmSymbols::java_lang_ref_SoftReference() || 3314 class_name == vmSymbols::java_lang_ref_SoftReference() ||
3287 class_name() == vmSymbols::java_lang_StackTraceElement() || 3315 class_name == vmSymbols::java_lang_StackTraceElement() ||
3288 class_name() == vmSymbols::java_lang_String() || 3316 class_name == vmSymbols::java_lang_String() ||
3289 class_name() == vmSymbols::java_lang_Throwable() || 3317 class_name == vmSymbols::java_lang_Throwable() ||
3290 class_name() == vmSymbols::java_lang_Boolean() || 3318 class_name == vmSymbols::java_lang_Boolean() ||
3291 class_name() == vmSymbols::java_lang_Character() || 3319 class_name == vmSymbols::java_lang_Character() ||
3292 class_name() == vmSymbols::java_lang_Float() || 3320 class_name == vmSymbols::java_lang_Float() ||
3293 class_name() == vmSymbols::java_lang_Double() || 3321 class_name == vmSymbols::java_lang_Double() ||
3294 class_name() == vmSymbols::java_lang_Byte() || 3322 class_name == vmSymbols::java_lang_Byte() ||
3295 class_name() == vmSymbols::java_lang_Short() || 3323 class_name == vmSymbols::java_lang_Short() ||
3296 class_name() == vmSymbols::java_lang_Integer() || 3324 class_name == vmSymbols::java_lang_Integer() ||
3297 class_name() == vmSymbols::java_lang_Long())) { 3325 class_name == vmSymbols::java_lang_Long())) {
3298 allocation_style = 0; // Allocate oops first 3326 allocation_style = 0; // Allocate oops first
3299 compact_fields = false; // Don't compact fields 3327 compact_fields = false; // Don't compact fields
3300 } 3328 }
3301 3329
3302 if( allocation_style == 0 ) { 3330 if( allocation_style == 0 ) {
3541 this_klass->set_class_loader(class_loader()); 3569 this_klass->set_class_loader(class_loader());
3542 this_klass->set_nonstatic_field_size(nonstatic_field_size); 3570 this_klass->set_nonstatic_field_size(nonstatic_field_size);
3543 this_klass->set_has_nonstatic_fields(has_nonstatic_fields); 3571 this_klass->set_has_nonstatic_fields(has_nonstatic_fields);
3544 this_klass->set_static_oop_field_size(fac.static_oop_count); 3572 this_klass->set_static_oop_field_size(fac.static_oop_count);
3545 cp->set_pool_holder(this_klass()); 3573 cp->set_pool_holder(this_klass());
3574 error_handler.set_in_error(false); // turn off error handler for cp
3546 this_klass->set_constants(cp()); 3575 this_klass->set_constants(cp());
3547 this_klass->set_local_interfaces(local_interfaces()); 3576 this_klass->set_local_interfaces(local_interfaces());
3548 this_klass->set_fields(fields()); 3577 this_klass->set_fields(fields());
3549 this_klass->set_methods(methods()); 3578 this_klass->set_methods(methods());
3550 if (has_final_method) { 3579 if (has_final_method) {
3933 if ((super != NULL) && 3962 if ((super != NULL) &&
3934 (!Reflection::verify_class_access(this_klass->as_klassOop(), super, false))) { 3963 (!Reflection::verify_class_access(this_klass->as_klassOop(), super, false))) {
3935 ResourceMark rm(THREAD); 3964 ResourceMark rm(THREAD);
3936 Exceptions::fthrow( 3965 Exceptions::fthrow(
3937 THREAD_AND_LOCATION, 3966 THREAD_AND_LOCATION,
3938 vmSymbolHandles::java_lang_IllegalAccessError(), 3967 vmSymbols::java_lang_IllegalAccessError(),
3939 "class %s cannot access its superclass %s", 3968 "class %s cannot access its superclass %s",
3940 this_klass->external_name(), 3969 this_klass->external_name(),
3941 instanceKlass::cast(super)->external_name() 3970 instanceKlass::cast(super)->external_name()
3942 ); 3971 );
3943 return; 3972 return;
3953 assert (k != NULL && Klass::cast(k)->is_interface(), "invalid interface"); 3982 assert (k != NULL && Klass::cast(k)->is_interface(), "invalid interface");
3954 if (!Reflection::verify_class_access(this_klass->as_klassOop(), k, false)) { 3983 if (!Reflection::verify_class_access(this_klass->as_klassOop(), k, false)) {
3955 ResourceMark rm(THREAD); 3984 ResourceMark rm(THREAD);
3956 Exceptions::fthrow( 3985 Exceptions::fthrow(
3957 THREAD_AND_LOCATION, 3986 THREAD_AND_LOCATION,
3958 vmSymbolHandles::java_lang_IllegalAccessError(), 3987 vmSymbols::java_lang_IllegalAccessError(),
3959 "class %s cannot access its superinterface %s", 3988 "class %s cannot access its superinterface %s",
3960 this_klass->external_name(), 3989 this_klass->external_name(),
3961 instanceKlass::cast(k)->external_name() 3990 instanceKlass::cast(k)->external_name()
3962 ); 3991 );
3963 return; 3992 return;
3977 // skip private, static and <init> methods 4006 // skip private, static and <init> methods
3978 if ((!m->is_private()) && 4007 if ((!m->is_private()) &&
3979 (!m->is_static()) && 4008 (!m->is_static()) &&
3980 (m->name() != vmSymbols::object_initializer_name())) { 4009 (m->name() != vmSymbols::object_initializer_name())) {
3981 4010
3982 symbolOop name = m->name(); 4011 Symbol* name = m->name();
3983 symbolOop signature = m->signature(); 4012 Symbol* signature = m->signature();
3984 klassOop k = this_klass->super(); 4013 klassOop k = this_klass->super();
3985 methodOop super_m = NULL; 4014 methodOop super_m = NULL;
3986 while (k != NULL) { 4015 while (k != NULL) {
3987 // skip supers that don't have final methods. 4016 // skip supers that don't have final methods.
3988 if (k->klass_part()->has_final_method()) { 4017 if (k->klass_part()->has_final_method()) {
4001 // this class can access super final method and therefore override 4030 // this class can access super final method and therefore override
4002 ) { 4031 ) {
4003 ResourceMark rm(THREAD); 4032 ResourceMark rm(THREAD);
4004 Exceptions::fthrow( 4033 Exceptions::fthrow(
4005 THREAD_AND_LOCATION, 4034 THREAD_AND_LOCATION,
4006 vmSymbolHandles::java_lang_VerifyError(), 4035 vmSymbols::java_lang_VerifyError(),
4007 "class %s overrides final method %s.%s", 4036 "class %s overrides final method %s.%s",
4008 this_klass->external_name(), 4037 this_klass->external_name(),
4009 name->as_C_string(), 4038 name->as_C_string(),
4010 signature->as_C_string() 4039 signature->as_C_string()
4011 ); 4040 );
4035 // if m is static and not the init method, throw a verify error 4064 // if m is static and not the init method, throw a verify error
4036 if ((m->is_static()) && (m->name() != vmSymbols::class_initializer_name())) { 4065 if ((m->is_static()) && (m->name() != vmSymbols::class_initializer_name())) {
4037 ResourceMark rm(THREAD); 4066 ResourceMark rm(THREAD);
4038 Exceptions::fthrow( 4067 Exceptions::fthrow(
4039 THREAD_AND_LOCATION, 4068 THREAD_AND_LOCATION,
4040 vmSymbolHandles::java_lang_VerifyError(), 4069 vmSymbols::java_lang_VerifyError(),
4041 "Illegal static method %s in interface %s", 4070 "Illegal static method %s in interface %s",
4042 m->name()->as_C_string(), 4071 m->name()->as_C_string(),
4043 this_klass->external_name() 4072 this_klass->external_name()
4044 ); 4073 );
4045 return; 4074 return;
4065 (is_interface && major_gte_15 && (is_super || is_enum)) || 4094 (is_interface && major_gte_15 && (is_super || is_enum)) ||
4066 (!is_interface && major_gte_15 && is_annotation)) { 4095 (!is_interface && major_gte_15 && is_annotation)) {
4067 ResourceMark rm(THREAD); 4096 ResourceMark rm(THREAD);
4068 Exceptions::fthrow( 4097 Exceptions::fthrow(
4069 THREAD_AND_LOCATION, 4098 THREAD_AND_LOCATION,
4070 vmSymbolHandles::java_lang_ClassFormatError(), 4099 vmSymbols::java_lang_ClassFormatError(),
4071 "Illegal class modifiers in class %s: 0x%X", 4100 "Illegal class modifiers in class %s: 0x%X",
4072 _class_name->as_C_string(), flags 4101 _class_name->as_C_string(), flags
4073 ); 4102 );
4074 return; 4103 return;
4075 } 4104 }
4125 4154
4126 if (is_illegal) { 4155 if (is_illegal) {
4127 ResourceMark rm(THREAD); 4156 ResourceMark rm(THREAD);
4128 Exceptions::fthrow( 4157 Exceptions::fthrow(
4129 THREAD_AND_LOCATION, 4158 THREAD_AND_LOCATION,
4130 vmSymbolHandles::java_lang_ClassFormatError(), 4159 vmSymbols::java_lang_ClassFormatError(),
4131 "Illegal field modifiers in class %s: 0x%X", 4160 "Illegal field modifiers in class %s: 0x%X",
4132 _class_name->as_C_string(), flags); 4161 _class_name->as_C_string(), flags);
4133 return; 4162 return;
4134 } 4163 }
4135 } 4164 }
4136 4165
4137 void ClassFileParser::verify_legal_method_modifiers( 4166 void ClassFileParser::verify_legal_method_modifiers(
4138 jint flags, bool is_interface, symbolHandle name, TRAPS) { 4167 jint flags, bool is_interface, Symbol* name, TRAPS) {
4139 if (!_need_verify) { return; } 4168 if (!_need_verify) { return; }
4140 4169
4141 const bool is_public = (flags & JVM_ACC_PUBLIC) != 0; 4170 const bool is_public = (flags & JVM_ACC_PUBLIC) != 0;
4142 const bool is_private = (flags & JVM_ACC_PRIVATE) != 0; 4171 const bool is_private = (flags & JVM_ACC_PRIVATE) != 0;
4143 const bool is_static = (flags & JVM_ACC_STATIC) != 0; 4172 const bool is_static = (flags & JVM_ACC_STATIC) != 0;
4178 4207
4179 if (is_illegal) { 4208 if (is_illegal) {
4180 ResourceMark rm(THREAD); 4209 ResourceMark rm(THREAD);
4181 Exceptions::fthrow( 4210 Exceptions::fthrow(
4182 THREAD_AND_LOCATION, 4211 THREAD_AND_LOCATION,
4183 vmSymbolHandles::java_lang_ClassFormatError(), 4212 vmSymbols::java_lang_ClassFormatError(),
4184 "Method %s in class %s has illegal modifiers: 0x%X", 4213 "Method %s in class %s has illegal modifiers: 0x%X",
4185 name->as_C_string(), _class_name->as_C_string(), flags); 4214 name->as_C_string(), _class_name->as_C_string(), flags);
4186 return; 4215 return;
4187 } 4216 }
4188 } 4217 }
4249 } // end of switch 4278 } // end of switch
4250 } // end of for 4279 } // end of for
4251 } 4280 }
4252 4281
4253 // Checks if name is a legal class name. 4282 // Checks if name is a legal class name.
4254 void ClassFileParser::verify_legal_class_name(symbolHandle name, TRAPS) { 4283 void ClassFileParser::verify_legal_class_name(Symbol* name, TRAPS) {
4255 if (!_need_verify || _relax_verify) { return; } 4284 if (!_need_verify || _relax_verify) { return; }
4256 4285
4257 char buf[fixed_buffer_size]; 4286 char buf[fixed_buffer_size];
4258 char* bytes = name->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size); 4287 char* bytes = name->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size);
4259 unsigned int length = name->utf8_length(); 4288 unsigned int length = name->utf8_length();
4279 } 4308 }
4280 if (!legal) { 4309 if (!legal) {
4281 ResourceMark rm(THREAD); 4310 ResourceMark rm(THREAD);
4282 Exceptions::fthrow( 4311 Exceptions::fthrow(
4283 THREAD_AND_LOCATION, 4312 THREAD_AND_LOCATION,
4284 vmSymbolHandles::java_lang_ClassFormatError(), 4313 vmSymbols::java_lang_ClassFormatError(),
4285 "Illegal class name \"%s\" in class file %s", bytes, 4314 "Illegal class name \"%s\" in class file %s", bytes,
4286 _class_name->as_C_string() 4315 _class_name->as_C_string()
4287 ); 4316 );
4288 return; 4317 return;
4289 } 4318 }
4290 } 4319 }
4291 4320
4292 // Checks if name is a legal field name. 4321 // Checks if name is a legal field name.
4293 void ClassFileParser::verify_legal_field_name(symbolHandle name, TRAPS) { 4322 void ClassFileParser::verify_legal_field_name(Symbol* name, TRAPS) {
4294 if (!_need_verify || _relax_verify) { return; } 4323 if (!_need_verify || _relax_verify) { return; }
4295 4324
4296 char buf[fixed_buffer_size]; 4325 char buf[fixed_buffer_size];
4297 char* bytes = name->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size); 4326 char* bytes = name->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size);
4298 unsigned int length = name->utf8_length(); 4327 unsigned int length = name->utf8_length();
4312 4341
4313 if (!legal) { 4342 if (!legal) {
4314 ResourceMark rm(THREAD); 4343 ResourceMark rm(THREAD);
4315 Exceptions::fthrow( 4344 Exceptions::fthrow(
4316 THREAD_AND_LOCATION, 4345 THREAD_AND_LOCATION,
4317 vmSymbolHandles::java_lang_ClassFormatError(), 4346 vmSymbols::java_lang_ClassFormatError(),
4318 "Illegal field name \"%s\" in class %s", bytes, 4347 "Illegal field name \"%s\" in class %s", bytes,
4319 _class_name->as_C_string() 4348 _class_name->as_C_string()
4320 ); 4349 );
4321 return; 4350 return;
4322 } 4351 }
4323 } 4352 }
4324 4353
4325 // Checks if name is a legal method name. 4354 // Checks if name is a legal method name.
4326 void ClassFileParser::verify_legal_method_name(symbolHandle name, TRAPS) { 4355 void ClassFileParser::verify_legal_method_name(Symbol* name, TRAPS) {
4327 if (!_need_verify || _relax_verify) { return; } 4356 if (!_need_verify || _relax_verify) { return; }
4328 4357
4329 assert(!name.is_null(), "method name is null"); 4358 assert(name != NULL, "method name is null");
4330 char buf[fixed_buffer_size]; 4359 char buf[fixed_buffer_size];
4331 char* bytes = name->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size); 4360 char* bytes = name->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size);
4332 unsigned int length = name->utf8_length(); 4361 unsigned int length = name->utf8_length();
4333 bool legal = false; 4362 bool legal = false;
4334 4363
4349 4378
4350 if (!legal) { 4379 if (!legal) {
4351 ResourceMark rm(THREAD); 4380 ResourceMark rm(THREAD);
4352 Exceptions::fthrow( 4381 Exceptions::fthrow(
4353 THREAD_AND_LOCATION, 4382 THREAD_AND_LOCATION,
4354 vmSymbolHandles::java_lang_ClassFormatError(), 4383 vmSymbols::java_lang_ClassFormatError(),
4355 "Illegal method name \"%s\" in class %s", bytes, 4384 "Illegal method name \"%s\" in class %s", bytes,
4356 _class_name->as_C_string() 4385 _class_name->as_C_string()
4357 ); 4386 );
4358 return; 4387 return;
4359 } 4388 }
4360 } 4389 }
4361 4390
4362 4391
4363 // Checks if signature is a legal field signature. 4392 // Checks if signature is a legal field signature.
4364 void ClassFileParser::verify_legal_field_signature(symbolHandle name, symbolHandle signature, TRAPS) { 4393 void ClassFileParser::verify_legal_field_signature(Symbol* name, Symbol* signature, TRAPS) {
4365 if (!_need_verify) { return; } 4394 if (!_need_verify) { return; }
4366 4395
4367 char buf[fixed_buffer_size]; 4396 char buf[fixed_buffer_size];
4368 char* bytes = signature->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size); 4397 char* bytes = signature->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size);
4369 unsigned int length = signature->utf8_length(); 4398 unsigned int length = signature->utf8_length();
4374 } 4403 }
4375 } 4404 }
4376 4405
4377 // Checks if signature is a legal method signature. 4406 // Checks if signature is a legal method signature.
4378 // Returns number of parameters 4407 // Returns number of parameters
4379 int ClassFileParser::verify_legal_method_signature(symbolHandle name, symbolHandle signature, TRAPS) { 4408 int ClassFileParser::verify_legal_method_signature(Symbol* name, Symbol* signature, TRAPS) {
4380 if (!_need_verify) { 4409 if (!_need_verify) {
4381 // make sure caller's args_size will be less than 0 even for non-static 4410 // make sure caller's args_size will be less than 0 even for non-static
4382 // method so it will be recomputed in compute_size_of_parameters(). 4411 // method so it will be recomputed in compute_size_of_parameters().
4383 return -2; 4412 return -2;
4384 } 4413 }
4506 args.push_int(unicode_ch); 4535 args.push_int(unicode_ch);
4507 4536
4508 // public static boolean isJavaIdentifierStart(char ch); 4537 // public static boolean isJavaIdentifierStart(char ch);
4509 JavaCalls::call_static(&result, 4538 JavaCalls::call_static(&result,
4510 klass, 4539 klass,
4511 vmSymbolHandles::isJavaIdentifierStart_name(), 4540 vmSymbols::isJavaIdentifierStart_name(),
4512 vmSymbolHandles::int_bool_signature(), 4541 vmSymbols::int_bool_signature(),
4513 &args, 4542 &args,
4514 THREAD); 4543 THREAD);
4515 4544
4516 if (HAS_PENDING_EXCEPTION) { 4545 if (HAS_PENDING_EXCEPTION) {
4517 CLEAR_PENDING_EXCEPTION; 4546 CLEAR_PENDING_EXCEPTION;
4523 4552
4524 if (not_first_ch) { 4553 if (not_first_ch) {
4525 // public static boolean isJavaIdentifierPart(char ch); 4554 // public static boolean isJavaIdentifierPart(char ch);
4526 JavaCalls::call_static(&result, 4555 JavaCalls::call_static(&result,
4527 klass, 4556 klass,
4528 vmSymbolHandles::isJavaIdentifierPart_name(), 4557 vmSymbols::isJavaIdentifierPart_name(),
4529 vmSymbolHandles::int_bool_signature(), 4558 vmSymbols::int_bool_signature(),
4530 &args, 4559 &args,
4531 THREAD); 4560 THREAD);
4532 4561
4533 if (HAS_PENDING_EXCEPTION) { 4562 if (HAS_PENDING_EXCEPTION) {
4534 CLEAR_PENDING_EXCEPTION; 4563 CLEAR_PENDING_EXCEPTION;