< prev index next >

src/share/vm/classfile/classFileParser.cpp

Print this page




 846       }
 847 
 848       if (InstanceKlass::cast(interf())->has_default_methods()) {
 849         *has_default_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     {
 866       debug_only(No_Safepoint_Verifier nsv;)
 867       for (index = 0; index < itfs_len; index++) {
 868         const Klass* const k = _local_interfaces->at(index);
 869         const Symbol* const name = InstanceKlass::cast(k)->name();
 870         // If no duplicates, add (name, NULL) in hashtable interface_names.
 871         if (!put_after_lookup(name, NULL, interface_names)) {
 872           dup = true;
 873           break;
 874         }
 875       }
 876     }
 877     if (dup) {
 878       classfile_parse_error("Duplicate interface name in class file %s", CHECK);
 879     }
 880   }
 881 }
 882 
 883 void ClassFileParser::verify_constantvalue(const ConstantPool* const cp,
 884                                            int constantvalue_index,
 885                                            int signature_index,
 886                                            TRAPS) const {


1603   {
1604     int i = 0;
1605     for (; i < index * FieldInfo::field_slots; i++) {
1606       _fields->at_put(i, fa[i]);
1607     }
1608     for (int j = total_fields * FieldInfo::field_slots;
1609          j < generic_signature_slot; j++) {
1610       _fields->at_put(i++, fa[j]);
1611     }
1612     assert(_fields->length() == i, "");
1613   }
1614 
1615   if (_need_verify && length > 1) {
1616     // Check duplicated fields
1617     ResourceMark rm(THREAD);
1618     NameSigHash** names_and_sigs = NEW_RESOURCE_ARRAY_IN_THREAD(
1619       THREAD, NameSigHash*, HASH_ROW_SIZE);
1620     initialize_hashtable(names_and_sigs);
1621     bool dup = false;
1622     {
1623       debug_only(No_Safepoint_Verifier nsv;)
1624       for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) {
1625         const Symbol* const name = fs.name();
1626         const Symbol* const sig = fs.signature();
1627         // If no duplicates, add name/signature in hashtable names_and_sigs.
1628         if (!put_after_lookup(name, sig, names_and_sigs)) {
1629           dup = true;
1630           break;
1631         }
1632       }
1633     }
1634     if (dup) {
1635       classfile_parse_error("Duplicate field name&signature in class file %s",
1636                             CHECK);
1637     }
1638   }
1639 }
1640 
1641 
1642 static void copy_u2_with_conversion(u2* dest, const u2* src, int length) {
1643   while (length-- > 0) {


2868       if (method->is_final()) {
2869         *has_final_method = true;
2870       }
2871       // declares_default_methods: declares concrete instance methods, any access flags
2872       // used for interface initialization, and default method inheritance analysis
2873       if (is_interface && !(*declares_default_methods)
2874         && !method->is_abstract() && !method->is_static()) {
2875         *declares_default_methods = true;
2876       }
2877       _methods->at_put(index, method);
2878     }
2879 
2880     if (_need_verify && length > 1) {
2881       // Check duplicated methods
2882       ResourceMark rm(THREAD);
2883       NameSigHash** names_and_sigs = NEW_RESOURCE_ARRAY_IN_THREAD(
2884         THREAD, NameSigHash*, HASH_ROW_SIZE);
2885       initialize_hashtable(names_and_sigs);
2886       bool dup = false;
2887       {
2888         debug_only(No_Safepoint_Verifier nsv;)
2889         for (int i = 0; i < length; i++) {
2890           const Method* const m = _methods->at(i);
2891           // If no duplicates, add name/signature in hashtable names_and_sigs.
2892           if (!put_after_lookup(m->name(), m->signature(), names_and_sigs)) {
2893             dup = true;
2894             break;
2895           }
2896         }
2897       }
2898       if (dup) {
2899         classfile_parse_error("Duplicate method name&signature in class file %s",
2900                               CHECK);
2901       }
2902     }
2903   }
2904 }
2905 
2906 static const intArray* sort_methods(Array<Method*>* methods) {
2907   const int length = methods->length();
2908   // If JVMTI original method ordering or sharing is enabled we have to




 846       }
 847 
 848       if (InstanceKlass::cast(interf())->has_default_methods()) {
 849         *has_default_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     {
 866       debug_only(NoSafepointVerifier nsv;)
 867       for (index = 0; index < itfs_len; index++) {
 868         const Klass* const k = _local_interfaces->at(index);
 869         const Symbol* const name = InstanceKlass::cast(k)->name();
 870         // If no duplicates, add (name, NULL) in hashtable interface_names.
 871         if (!put_after_lookup(name, NULL, interface_names)) {
 872           dup = true;
 873           break;
 874         }
 875       }
 876     }
 877     if (dup) {
 878       classfile_parse_error("Duplicate interface name in class file %s", CHECK);
 879     }
 880   }
 881 }
 882 
 883 void ClassFileParser::verify_constantvalue(const ConstantPool* const cp,
 884                                            int constantvalue_index,
 885                                            int signature_index,
 886                                            TRAPS) const {


1603   {
1604     int i = 0;
1605     for (; i < index * FieldInfo::field_slots; i++) {
1606       _fields->at_put(i, fa[i]);
1607     }
1608     for (int j = total_fields * FieldInfo::field_slots;
1609          j < generic_signature_slot; j++) {
1610       _fields->at_put(i++, fa[j]);
1611     }
1612     assert(_fields->length() == i, "");
1613   }
1614 
1615   if (_need_verify && length > 1) {
1616     // Check duplicated fields
1617     ResourceMark rm(THREAD);
1618     NameSigHash** names_and_sigs = NEW_RESOURCE_ARRAY_IN_THREAD(
1619       THREAD, NameSigHash*, HASH_ROW_SIZE);
1620     initialize_hashtable(names_and_sigs);
1621     bool dup = false;
1622     {
1623       debug_only(NoSafepointVerifier nsv;)
1624       for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) {
1625         const Symbol* const name = fs.name();
1626         const Symbol* const sig = fs.signature();
1627         // If no duplicates, add name/signature in hashtable names_and_sigs.
1628         if (!put_after_lookup(name, sig, names_and_sigs)) {
1629           dup = true;
1630           break;
1631         }
1632       }
1633     }
1634     if (dup) {
1635       classfile_parse_error("Duplicate field name&signature in class file %s",
1636                             CHECK);
1637     }
1638   }
1639 }
1640 
1641 
1642 static void copy_u2_with_conversion(u2* dest, const u2* src, int length) {
1643   while (length-- > 0) {


2868       if (method->is_final()) {
2869         *has_final_method = true;
2870       }
2871       // declares_default_methods: declares concrete instance methods, any access flags
2872       // used for interface initialization, and default method inheritance analysis
2873       if (is_interface && !(*declares_default_methods)
2874         && !method->is_abstract() && !method->is_static()) {
2875         *declares_default_methods = true;
2876       }
2877       _methods->at_put(index, method);
2878     }
2879 
2880     if (_need_verify && length > 1) {
2881       // Check duplicated methods
2882       ResourceMark rm(THREAD);
2883       NameSigHash** names_and_sigs = NEW_RESOURCE_ARRAY_IN_THREAD(
2884         THREAD, NameSigHash*, HASH_ROW_SIZE);
2885       initialize_hashtable(names_and_sigs);
2886       bool dup = false;
2887       {
2888         debug_only(NoSafepointVerifier nsv;)
2889         for (int i = 0; i < length; i++) {
2890           const Method* const m = _methods->at(i);
2891           // If no duplicates, add name/signature in hashtable names_and_sigs.
2892           if (!put_after_lookup(m->name(), m->signature(), names_and_sigs)) {
2893             dup = true;
2894             break;
2895           }
2896         }
2897       }
2898       if (dup) {
2899         classfile_parse_error("Duplicate method name&signature in class file %s",
2900                               CHECK);
2901       }
2902     }
2903   }
2904 }
2905 
2906 static const intArray* sort_methods(Array<Method*>* methods) {
2907   const int length = methods->length();
2908   // If JVMTI original method ordering or sharing is enabled we have to


< prev index next >