798 799 // Side-effects: populates the _local_interfaces field 800 void ClassFileParser::parse_interfaces(const ClassFileStream* const stream, 801 const int itfs_len, 802 ConstantPool* const cp, 803 bool* const has_nonstatic_concrete_methods, 804 TRAPS) { 805 assert(stream != NULL, "invariant"); 806 assert(cp != NULL, "invariant"); 807 assert(has_nonstatic_concrete_methods != NULL, "invariant"); 808 809 if (itfs_len == 0) { 810 _local_interfaces = Universe::the_empty_klass_array(); 811 } else { 812 assert(itfs_len > 0, "only called for len>0"); 813 _local_interfaces = MetadataFactory::new_array<Klass*>(_loader_data, itfs_len, NULL, CHECK); 814 815 int index; 816 for (index = 0; index < itfs_len; index++) { 817 const u2 interface_index = stream->get_u2(CHECK); 818 KlassHandle interf; 819 check_property( 820 valid_klass_reference_at(interface_index), 821 "Interface name has bad constant pool index %u in class file %s", 822 interface_index, CHECK); 823 if (cp->tag_at(interface_index).is_klass()) { 824 interf = KlassHandle(THREAD, cp->resolved_klass_at(interface_index)); 825 } else { 826 Symbol* const unresolved_klass = cp->klass_name_at(interface_index); 827 828 // Don't need to check legal name because it's checked when parsing constant pool. 829 // But need to make sure it's not an array type. 830 guarantee_property(unresolved_klass->byte_at(0) != JVM_SIGNATURE_ARRAY, 831 "Bad interface name in class file %s", CHECK); 832 833 // Call resolve_super so classcircularity is checked 834 const Klass* const k = 835 SystemDictionary::resolve_super_or_fail(_class_name, 836 unresolved_klass, 837 Handle(THREAD, _loader_data->class_loader()), 838 _protection_domain, 839 false, 840 CHECK); 841 interf = KlassHandle(THREAD, k); 842 } 843 844 if (!interf()->is_interface()) { 845 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), 846 "Implementing class"); 847 } 848 849 if (InstanceKlass::cast(interf())->has_nonstatic_concrete_methods()) { 850 *has_nonstatic_concrete_methods = true; 851 } 852 _local_interfaces->at_put(index, interf()); 853 } 854 855 if (!_need_verify || itfs_len <= 1) { 856 return; 857 } 858 859 // Check if there's any duplicates in interfaces 860 ResourceMark rm(THREAD); 861 NameSigHash** interface_names = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, 862 NameSigHash*, 863 HASH_ROW_SIZE); 864 initialize_hashtable(interface_names); 865 bool dup = false; 866 const Symbol* name = NULL; 867 { 868 debug_only(NoSafepointVerifier nsv;) 869 for (index = 0; index < itfs_len; index++) { 870 const Klass* const k = _local_interfaces->at(index); 871 name = InstanceKlass::cast(k)->name(); 872 // If no duplicates, add (name, NULL) in hashtable interface_names. | 798 799 // Side-effects: populates the _local_interfaces field 800 void ClassFileParser::parse_interfaces(const ClassFileStream* const stream, 801 const int itfs_len, 802 ConstantPool* const cp, 803 bool* const has_nonstatic_concrete_methods, 804 TRAPS) { 805 assert(stream != NULL, "invariant"); 806 assert(cp != NULL, "invariant"); 807 assert(has_nonstatic_concrete_methods != NULL, "invariant"); 808 809 if (itfs_len == 0) { 810 _local_interfaces = Universe::the_empty_klass_array(); 811 } else { 812 assert(itfs_len > 0, "only called for len>0"); 813 _local_interfaces = MetadataFactory::new_array<Klass*>(_loader_data, itfs_len, NULL, CHECK); 814 815 int index; 816 for (index = 0; index < itfs_len; index++) { 817 const u2 interface_index = stream->get_u2(CHECK); 818 Klass* interf; 819 check_property( 820 valid_klass_reference_at(interface_index), 821 "Interface name has bad constant pool index %u in class file %s", 822 interface_index, CHECK); 823 if (cp->tag_at(interface_index).is_klass()) { 824 interf = cp->resolved_klass_at(interface_index); 825 } else { 826 Symbol* const unresolved_klass = cp->klass_name_at(interface_index); 827 828 // Don't need to check legal name because it's checked when parsing constant pool. 829 // But need to make sure it's not an array type. 830 guarantee_property(unresolved_klass->byte_at(0) != JVM_SIGNATURE_ARRAY, 831 "Bad interface name in class file %s", CHECK); 832 833 // Call resolve_super so classcircularity is checked 834 interf = SystemDictionary::resolve_super_or_fail( 835 _class_name, 836 unresolved_klass, 837 Handle(THREAD, _loader_data->class_loader()), 838 _protection_domain, 839 false, 840 CHECK); 841 } 842 843 if (!interf->is_interface()) { 844 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), 845 "Implementing class"); 846 } 847 848 if (InstanceKlass::cast(interf)->has_nonstatic_concrete_methods()) { 849 *has_nonstatic_concrete_methods = true; 850 } 851 _local_interfaces->at_put(index, interf); 852 } 853 854 if (!_need_verify || itfs_len <= 1) { 855 return; 856 } 857 858 // Check if there's any duplicates in interfaces 859 ResourceMark rm(THREAD); 860 NameSigHash** interface_names = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, 861 NameSigHash*, 862 HASH_ROW_SIZE); 863 initialize_hashtable(interface_names); 864 bool dup = false; 865 const Symbol* name = NULL; 866 { 867 debug_only(NoSafepointVerifier nsv;) 868 for (index = 0; index < itfs_len; index++) { 869 const Klass* const k = _local_interfaces->at(index); 870 name = InstanceKlass::cast(k)->name(); 871 // If no duplicates, add (name, NULL) in hashtable interface_names. |