hotspot/src/share/vm/classfile/classFileParser.cpp
changeset 46554 aa1cfd918c4f
parent 46513 c61eea516a0a
child 46619 a3919f5e8d2b
equal deleted inserted replaced
45608:9927a9f16738 46554:aa1cfd918c4f
    62 #include "runtime/signature.hpp"
    62 #include "runtime/signature.hpp"
    63 #include "runtime/timer.hpp"
    63 #include "runtime/timer.hpp"
    64 #include "services/classLoadingService.hpp"
    64 #include "services/classLoadingService.hpp"
    65 #include "services/threadService.hpp"
    65 #include "services/threadService.hpp"
    66 #include "trace/traceMacros.hpp"
    66 #include "trace/traceMacros.hpp"
    67 #include "utilities/array.hpp"
    67 #include "utilities/bitMap.inline.hpp"
    68 #include "utilities/exceptions.hpp"
    68 #include "utilities/exceptions.hpp"
    69 #include "utilities/globalDefinitions.hpp"
    69 #include "utilities/globalDefinitions.hpp"
       
    70 #include "utilities/growableArray.hpp"
    70 #include "utilities/macros.hpp"
    71 #include "utilities/macros.hpp"
    71 #include "utilities/ostream.hpp"
    72 #include "utilities/ostream.hpp"
    72 #include "utilities/resourceHash.hpp"
    73 #include "utilities/resourceHash.hpp"
    73 #if INCLUDE_CDS
    74 #if INCLUDE_CDS
    74 #include "classfile/systemDictionaryShared.hpp"
    75 #include "classfile/systemDictionaryShared.hpp"
   258         break;
   259         break;
   259       }
   260       }
   260       case JVM_CONSTANT_Utf8 : {
   261       case JVM_CONSTANT_Utf8 : {
   261         cfs->guarantee_more(2, CHECK);  // utf8_length
   262         cfs->guarantee_more(2, CHECK);  // utf8_length
   262         u2  utf8_length = cfs->get_u2_fast();
   263         u2  utf8_length = cfs->get_u2_fast();
   263         const u1* utf8_buffer = cfs->get_u1_buffer();
   264         const u1* utf8_buffer = cfs->current();
   264         assert(utf8_buffer != NULL, "null utf8 buffer");
   265         assert(utf8_buffer != NULL, "null utf8 buffer");
   265         // Got utf8 string, guarantee utf8_length+1 bytes, set stream position forward.
   266         // Got utf8 string, guarantee utf8_length+1 bytes, set stream position forward.
   266         cfs->guarantee_more(utf8_length+1, CHECK);  // utf8 string, tag/access_flags
   267         cfs->guarantee_more(utf8_length+1, CHECK);  // utf8 string, tag/access_flags
   267         cfs->skip_u1_fast(utf8_length);
   268         cfs->skip_u1_fast(utf8_length);
   268 
   269 
   389     // a bad CP entry has been detected previously so stop parsing and just return.
   390     // a bad CP entry has been detected previously so stop parsing and just return.
   390     return;
   391     return;
   391   }
   392   }
   392 
   393 
   393   int index = 1;  // declared outside of loops for portability
   394   int index = 1;  // declared outside of loops for portability
       
   395   int num_klasses = 0;
   394 
   396 
   395   // first verification pass - validate cross references
   397   // first verification pass - validate cross references
   396   // and fixup class and string constants
   398   // and fixup class and string constants
   397   for (index = 1; index < length; index++) {          // Index 0 is unused
   399   for (index = 1; index < length; index++) {          // Index 0 is unused
   398     const jbyte tag = cp->tag_at(index).value();
   400     const jbyte tag = cp->tag_at(index).value();
   457       case JVM_CONSTANT_ClassIndex: {
   459       case JVM_CONSTANT_ClassIndex: {
   458         const int class_index = cp->klass_index_at(index);
   460         const int class_index = cp->klass_index_at(index);
   459         check_property(valid_symbol_at(class_index),
   461         check_property(valid_symbol_at(class_index),
   460           "Invalid constant pool index %u in class file %s",
   462           "Invalid constant pool index %u in class file %s",
   461           class_index, CHECK);
   463           class_index, CHECK);
   462         cp->unresolved_klass_at_put(index, cp->symbol_at(class_index));
   464         cp->unresolved_klass_at_put(index, class_index, num_klasses++);
   463         break;
   465         break;
   464       }
   466       }
   465       case JVM_CONSTANT_StringIndex: {
   467       case JVM_CONSTANT_StringIndex: {
   466         const int string_index = cp->string_index_at(index);
   468         const int string_index = cp->string_index_at(index);
   467         check_property(valid_symbol_at(string_index),
   469         check_property(valid_symbol_at(string_index),
   548         break;
   550         break;
   549       }
   551       }
   550     } // switch(tag)
   552     } // switch(tag)
   551   } // end of for
   553   } // end of for
   552 
   554 
       
   555   _first_patched_klass_resolved_index = num_klasses;
       
   556   cp->allocate_resolved_klasses(_loader_data, num_klasses + _max_num_patched_klasses, CHECK);
       
   557 
   553   if (_cp_patches != NULL) {
   558   if (_cp_patches != NULL) {
   554     // need to treat this_class specially...
   559     // need to treat this_class specially...
       
   560 
       
   561     // Add dummy utf8 entries in the space reserved for names of patched classes. We'll use "*"
       
   562     // for now. These will be replaced with actual names of the patched classes in patch_class().
       
   563     Symbol* s = vmSymbols::star_name();
       
   564     for (int n=_orig_cp_size; n<cp->length(); n++) {
       
   565       cp->symbol_at_put(n, s);
       
   566     }
       
   567 
   555     int this_class_index;
   568     int this_class_index;
   556     {
   569     {
   557       stream->guarantee_more(8, CHECK);  // flags, this_class, super_class, infs_len
   570       stream->guarantee_more(8, CHECK);  // flags, this_class, super_class, infs_len
   558       const u1* const mark = stream->current();
   571       const u1* const mark = stream->current();
   559       stream->skip_u2_fast(1); // skip flags
   572       stream->skip_u2_fast(1); // skip flags
   699       }
   712       }
   700     }  // switch(tag)
   713     }  // switch(tag)
   701   }  // end of for
   714   }  // end of for
   702 }
   715 }
   703 
   716 
       
   717 void ClassFileParser::patch_class(ConstantPool* cp, int class_index, Klass* k, Symbol* name) {
       
   718   int name_index = _orig_cp_size + _num_patched_klasses;
       
   719   int resolved_klass_index = _first_patched_klass_resolved_index + _num_patched_klasses;
       
   720 
       
   721   cp->klass_at_put(class_index, name_index, resolved_klass_index, k, name);
       
   722   _num_patched_klasses ++;
       
   723 }
       
   724 
   704 void ClassFileParser::patch_constant_pool(ConstantPool* cp,
   725 void ClassFileParser::patch_constant_pool(ConstantPool* cp,
   705                                           int index,
   726                                           int index,
   706                                           Handle patch,
   727                                           Handle patch,
   707                                           TRAPS) {
   728                                           TRAPS) {
   708   assert(cp != NULL, "invariant");
   729   assert(cp != NULL, "invariant");
   716       // The name in the constant pool is ignored.
   737       // The name in the constant pool is ignored.
   717       if (java_lang_Class::is_instance(patch())) {
   738       if (java_lang_Class::is_instance(patch())) {
   718         guarantee_property(!java_lang_Class::is_primitive(patch()),
   739         guarantee_property(!java_lang_Class::is_primitive(patch()),
   719                            "Illegal class patch at %d in class file %s",
   740                            "Illegal class patch at %d in class file %s",
   720                            index, CHECK);
   741                            index, CHECK);
   721         cp->klass_at_put(index, java_lang_Class::as_Klass(patch()));
   742         Klass* k = java_lang_Class::as_Klass(patch());
       
   743         patch_class(cp, index, k, k->name());
   722       } else {
   744       } else {
   723         guarantee_property(java_lang_String::is_instance(patch()),
   745         guarantee_property(java_lang_String::is_instance(patch()),
   724                            "Illegal class patch at %d in class file %s",
   746                            "Illegal class patch at %d in class file %s",
   725                            index, CHECK);
   747                            index, CHECK);
   726         Symbol* const name = java_lang_String::as_symbol(patch(), CHECK);
   748         Symbol* const name = java_lang_String::as_symbol(patch(), CHECK);
   727         cp->unresolved_klass_at_put(index, name);
   749         patch_class(cp, index, NULL, name);
   728       }
   750       }
   729       break;
   751       break;
   730     }
   752     }
   731 
   753 
   732     case JVM_CONSTANT_String: {
   754     case JVM_CONSTANT_String: {
   835     _local_interfaces = MetadataFactory::new_array<Klass*>(_loader_data, itfs_len, NULL, CHECK);
   857     _local_interfaces = MetadataFactory::new_array<Klass*>(_loader_data, itfs_len, NULL, CHECK);
   836 
   858 
   837     int index;
   859     int index;
   838     for (index = 0; index < itfs_len; index++) {
   860     for (index = 0; index < itfs_len; index++) {
   839       const u2 interface_index = stream->get_u2(CHECK);
   861       const u2 interface_index = stream->get_u2(CHECK);
   840       KlassHandle interf;
   862       Klass* interf;
   841       check_property(
   863       check_property(
   842         valid_klass_reference_at(interface_index),
   864         valid_klass_reference_at(interface_index),
   843         "Interface name has bad constant pool index %u in class file %s",
   865         "Interface name has bad constant pool index %u in class file %s",
   844         interface_index, CHECK);
   866         interface_index, CHECK);
   845       if (cp->tag_at(interface_index).is_klass()) {
   867       if (cp->tag_at(interface_index).is_klass()) {
   846         interf = KlassHandle(THREAD, cp->resolved_klass_at(interface_index));
   868         interf = cp->resolved_klass_at(interface_index);
   847       } else {
   869       } else {
   848         Symbol* const unresolved_klass  = cp->klass_name_at(interface_index);
   870         Symbol* const unresolved_klass  = cp->klass_name_at(interface_index);
   849 
   871 
   850         // Don't need to check legal name because it's checked when parsing constant pool.
   872         // Don't need to check legal name because it's checked when parsing constant pool.
   851         // But need to make sure it's not an array type.
   873         // But need to make sure it's not an array type.
   852         guarantee_property(unresolved_klass->byte_at(0) != JVM_SIGNATURE_ARRAY,
   874         guarantee_property(unresolved_klass->byte_at(0) != JVM_SIGNATURE_ARRAY,
   853                            "Bad interface name in class file %s", CHECK);
   875                            "Bad interface name in class file %s", CHECK);
   854 
   876 
   855         // Call resolve_super so classcircularity is checked
   877         // Call resolve_super so classcircularity is checked
   856         const Klass* const k =
   878         interf = SystemDictionary::resolve_super_or_fail(
   857           SystemDictionary::resolve_super_or_fail(_class_name,
   879                                                   _class_name,
   858                                                   unresolved_klass,
   880                                                   unresolved_klass,
   859                                                   _loader_data->class_loader(),
   881                                                   Handle(THREAD, _loader_data->class_loader()),
   860                                                   _protection_domain,
   882                                                   _protection_domain,
   861                                                   false,
   883                                                   false,
   862                                                   CHECK);
   884                                                   CHECK);
   863         interf = KlassHandle(THREAD, k);
   885       }
   864       }
   886 
   865 
   887       if (!interf->is_interface()) {
   866       if (!interf()->is_interface()) {
       
   867         THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(),
   888         THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(),
   868                    "Implementing class");
   889                    "Implementing class");
   869       }
   890       }
   870 
   891 
   871       if (InstanceKlass::cast(interf())->has_nonstatic_concrete_methods()) {
   892       if (InstanceKlass::cast(interf)->has_nonstatic_concrete_methods()) {
   872         *has_nonstatic_concrete_methods = true;
   893         *has_nonstatic_concrete_methods = true;
   873       }
   894       }
   874       _local_interfaces->at_put(index, interf());
   895       _local_interfaces->at_put(index, interf);
   875     }
   896     }
   876 
   897 
   877     if (!_need_verify || itfs_len <= 1) {
   898     if (!_need_verify || itfs_len <= 1) {
   878       return;
   899       return;
   879     }
   900     }
   883     NameSigHash** interface_names = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD,
   904     NameSigHash** interface_names = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD,
   884                                                                  NameSigHash*,
   905                                                                  NameSigHash*,
   885                                                                  HASH_ROW_SIZE);
   906                                                                  HASH_ROW_SIZE);
   886     initialize_hashtable(interface_names);
   907     initialize_hashtable(interface_names);
   887     bool dup = false;
   908     bool dup = false;
       
   909     const Symbol* name = NULL;
   888     {
   910     {
   889       debug_only(NoSafepointVerifier nsv;)
   911       debug_only(NoSafepointVerifier nsv;)
   890       for (index = 0; index < itfs_len; index++) {
   912       for (index = 0; index < itfs_len; index++) {
   891         const Klass* const k = _local_interfaces->at(index);
   913         const Klass* const k = _local_interfaces->at(index);
   892         const Symbol* const name = InstanceKlass::cast(k)->name();
   914         name = InstanceKlass::cast(k)->name();
   893         // If no duplicates, add (name, NULL) in hashtable interface_names.
   915         // If no duplicates, add (name, NULL) in hashtable interface_names.
   894         if (!put_after_lookup(name, NULL, interface_names)) {
   916         if (!put_after_lookup(name, NULL, interface_names)) {
   895           dup = true;
   917           dup = true;
   896           break;
   918           break;
   897         }
   919         }
   898       }
   920       }
   899     }
   921     }
   900     if (dup) {
   922     if (dup) {
   901       classfile_parse_error("Duplicate interface name in class file %s", CHECK);
   923       classfile_parse_error("Duplicate interface name \"%s\" in class file %s",
       
   924                              name->as_C_string(), CHECK);
   902     }
   925     }
   903   }
   926   }
   904 }
   927 }
   905 
   928 
   906 void ClassFileParser::verify_constantvalue(const ConstantPool* const cp,
   929 void ClassFileParser::verify_constantvalue(const ConstantPool* const cp,
  1280         if (runtime_visible_annotations != NULL) {
  1303         if (runtime_visible_annotations != NULL) {
  1281           classfile_parse_error(
  1304           classfile_parse_error(
  1282             "Multiple RuntimeVisibleAnnotations attributes for field in class file %s", CHECK);
  1305             "Multiple RuntimeVisibleAnnotations attributes for field in class file %s", CHECK);
  1283         }
  1306         }
  1284         runtime_visible_annotations_length = attribute_length;
  1307         runtime_visible_annotations_length = attribute_length;
  1285         runtime_visible_annotations = cfs->get_u1_buffer();
  1308         runtime_visible_annotations = cfs->current();
  1286         assert(runtime_visible_annotations != NULL, "null visible annotations");
  1309         assert(runtime_visible_annotations != NULL, "null visible annotations");
  1287         cfs->guarantee_more(runtime_visible_annotations_length, CHECK);
  1310         cfs->guarantee_more(runtime_visible_annotations_length, CHECK);
  1288         parse_annotations(cp,
  1311         parse_annotations(cp,
  1289                           runtime_visible_annotations,
  1312                           runtime_visible_annotations,
  1290                           runtime_visible_annotations_length,
  1313                           runtime_visible_annotations_length,
  1298             "Multiple RuntimeInvisibleAnnotations attributes for field in class file %s", CHECK);
  1321             "Multiple RuntimeInvisibleAnnotations attributes for field in class file %s", CHECK);
  1299         }
  1322         }
  1300         runtime_invisible_annotations_exists = true;
  1323         runtime_invisible_annotations_exists = true;
  1301         if (PreserveAllAnnotations) {
  1324         if (PreserveAllAnnotations) {
  1302           runtime_invisible_annotations_length = attribute_length;
  1325           runtime_invisible_annotations_length = attribute_length;
  1303           runtime_invisible_annotations = cfs->get_u1_buffer();
  1326           runtime_invisible_annotations = cfs->current();
  1304           assert(runtime_invisible_annotations != NULL, "null invisible annotations");
  1327           assert(runtime_invisible_annotations != NULL, "null invisible annotations");
  1305         }
  1328         }
  1306         cfs->skip_u1(attribute_length, CHECK);
  1329         cfs->skip_u1(attribute_length, CHECK);
  1307       } else if (attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) {
  1330       } else if (attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) {
  1308         if (runtime_visible_type_annotations != NULL) {
  1331         if (runtime_visible_type_annotations != NULL) {
  1309           classfile_parse_error(
  1332           classfile_parse_error(
  1310             "Multiple RuntimeVisibleTypeAnnotations attributes for field in class file %s", CHECK);
  1333             "Multiple RuntimeVisibleTypeAnnotations attributes for field in class file %s", CHECK);
  1311         }
  1334         }
  1312         runtime_visible_type_annotations_length = attribute_length;
  1335         runtime_visible_type_annotations_length = attribute_length;
  1313         runtime_visible_type_annotations = cfs->get_u1_buffer();
  1336         runtime_visible_type_annotations = cfs->current();
  1314         assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
  1337         assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
  1315         cfs->skip_u1(runtime_visible_type_annotations_length, CHECK);
  1338         cfs->skip_u1(runtime_visible_type_annotations_length, CHECK);
  1316       } else if (attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) {
  1339       } else if (attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) {
  1317         if (runtime_invisible_type_annotations_exists) {
  1340         if (runtime_invisible_type_annotations_exists) {
  1318           classfile_parse_error(
  1341           classfile_parse_error(
  1320         } else {
  1343         } else {
  1321           runtime_invisible_type_annotations_exists = true;
  1344           runtime_invisible_type_annotations_exists = true;
  1322         }
  1345         }
  1323         if (PreserveAllAnnotations) {
  1346         if (PreserveAllAnnotations) {
  1324           runtime_invisible_type_annotations_length = attribute_length;
  1347           runtime_invisible_type_annotations_length = attribute_length;
  1325           runtime_invisible_type_annotations = cfs->get_u1_buffer();
  1348           runtime_invisible_type_annotations = cfs->current();
  1326           assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
  1349           assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
  1327         }
  1350         }
  1328         cfs->skip_u1(attribute_length, CHECK);
  1351         cfs->skip_u1(attribute_length, CHECK);
  1329       } else {
  1352       } else {
  1330         cfs->skip_u1(attribute_length, CHECK);  // Skip unknown attributes
  1353         cfs->skip_u1(attribute_length, CHECK);  // Skip unknown attributes
  1652     ResourceMark rm(THREAD);
  1675     ResourceMark rm(THREAD);
  1653     NameSigHash** names_and_sigs = NEW_RESOURCE_ARRAY_IN_THREAD(
  1676     NameSigHash** names_and_sigs = NEW_RESOURCE_ARRAY_IN_THREAD(
  1654       THREAD, NameSigHash*, HASH_ROW_SIZE);
  1677       THREAD, NameSigHash*, HASH_ROW_SIZE);
  1655     initialize_hashtable(names_and_sigs);
  1678     initialize_hashtable(names_and_sigs);
  1656     bool dup = false;
  1679     bool dup = false;
       
  1680     const Symbol* name = NULL;
       
  1681     const Symbol* sig = NULL;
  1657     {
  1682     {
  1658       debug_only(NoSafepointVerifier nsv;)
  1683       debug_only(NoSafepointVerifier nsv;)
  1659       for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) {
  1684       for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) {
  1660         const Symbol* const name = fs.name();
  1685         name = fs.name();
  1661         const Symbol* const sig = fs.signature();
  1686         sig = fs.signature();
  1662         // If no duplicates, add name/signature in hashtable names_and_sigs.
  1687         // If no duplicates, add name/signature in hashtable names_and_sigs.
  1663         if (!put_after_lookup(name, sig, names_and_sigs)) {
  1688         if (!put_after_lookup(name, sig, names_and_sigs)) {
  1664           dup = true;
  1689           dup = true;
  1665           break;
  1690           break;
  1666         }
  1691         }
  1667       }
  1692       }
  1668     }
  1693     }
  1669     if (dup) {
  1694     if (dup) {
  1670       classfile_parse_error("Duplicate field name&signature in class file %s",
  1695       classfile_parse_error("Duplicate field name \"%s\" with signature \"%s\" in class file %s",
  1671                             CHECK);
  1696                              name->as_C_string(), sig->as_klass_external_name(), CHECK);
  1672     }
  1697     }
  1673   }
  1698   }
  1674 }
  1699 }
  1675 
  1700 
  1676 
  1701 
  1677 static void copy_u2_with_conversion(u2* dest, const u2* src, int length) {
  1702 const ClassFileParser::unsafe_u2* ClassFileParser::parse_exception_table(const ClassFileStream* const cfs,
  1678   while (length-- > 0) {
  1703                                                                          u4 code_length,
  1679     *dest++ = Bytes::get_Java_u2((u1*) (src++));
  1704                                                                          u4 exception_table_length,
  1680   }
  1705                                                                          TRAPS) {
  1681 }
       
  1682 
       
  1683 const u2* ClassFileParser::parse_exception_table(const ClassFileStream* const cfs,
       
  1684                                                  u4 code_length,
       
  1685                                                  u4 exception_table_length,
       
  1686                                                  TRAPS) {
       
  1687   assert(cfs != NULL, "invariant");
  1706   assert(cfs != NULL, "invariant");
  1688 
  1707 
  1689   const u2* const exception_table_start = cfs->get_u2_buffer();
  1708   const unsafe_u2* const exception_table_start = cfs->current();
  1690   assert(exception_table_start != NULL, "null exception table");
  1709   assert(exception_table_start != NULL, "null exception table");
  1691 
  1710 
  1692   cfs->guarantee_more(8 * exception_table_length, CHECK_NULL); // start_pc,
  1711   cfs->guarantee_more(8 * exception_table_length, CHECK_NULL); // start_pc,
  1693                                                                // end_pc,
  1712                                                                // end_pc,
  1694                                                                // handler_pc,
  1713                                                                // handler_pc,
  1802   lvt->slot                = Bytes::get_Java_u2((u1*) &src->slot);
  1821   lvt->slot                = Bytes::get_Java_u2((u1*) &src->slot);
  1803 }
  1822 }
  1804 
  1823 
  1805 // Function is used to parse both attributes:
  1824 // Function is used to parse both attributes:
  1806 // LocalVariableTable (LVT) and LocalVariableTypeTable (LVTT)
  1825 // LocalVariableTable (LVT) and LocalVariableTypeTable (LVTT)
  1807 const u2* ClassFileParser::parse_localvariable_table(const ClassFileStream* cfs,
  1826 const ClassFileParser::unsafe_u2* ClassFileParser::parse_localvariable_table(const ClassFileStream* cfs,
  1808                                                      u4 code_length,
  1827                                                                              u4 code_length,
  1809                                                      u2 max_locals,
  1828                                                                              u2 max_locals,
  1810                                                      u4 code_attribute_length,
  1829                                                                              u4 code_attribute_length,
  1811                                                      u2* const localvariable_table_length,
  1830                                                                              u2* const localvariable_table_length,
  1812                                                      bool isLVTT,
  1831                                                                              bool isLVTT,
  1813                                                      TRAPS) {
  1832                                                                              TRAPS) {
  1814   const char* const tbl_name = (isLVTT) ? "LocalVariableTypeTable" : "LocalVariableTable";
  1833   const char* const tbl_name = (isLVTT) ? "LocalVariableTypeTable" : "LocalVariableTable";
  1815   *localvariable_table_length = cfs->get_u2(CHECK_NULL);
  1834   *localvariable_table_length = cfs->get_u2(CHECK_NULL);
  1816   const unsigned int size =
  1835   const unsigned int size =
  1817     (*localvariable_table_length) * sizeof(Classfile_LVT_Element) / sizeof(u2);
  1836     (*localvariable_table_length) * sizeof(Classfile_LVT_Element) / sizeof(u2);
  1818 
  1837 
  1822   if (_need_verify) {
  1841   if (_need_verify) {
  1823     guarantee_property(code_attribute_length == (sizeof(*localvariable_table_length) + size * sizeof(u2)),
  1842     guarantee_property(code_attribute_length == (sizeof(*localvariable_table_length) + size * sizeof(u2)),
  1824                        "%s has wrong length in class file %s", tbl_name, CHECK_NULL);
  1843                        "%s has wrong length in class file %s", tbl_name, CHECK_NULL);
  1825   }
  1844   }
  1826 
  1845 
  1827   const u2* const localvariable_table_start = cfs->get_u2_buffer();
  1846   const unsafe_u2* const localvariable_table_start = cfs->current();
  1828   assert(localvariable_table_start != NULL, "null local variable table");
  1847   assert(localvariable_table_start != NULL, "null local variable table");
  1829   if (!_need_verify) {
  1848   if (!_need_verify) {
  1830     cfs->skip_u2_fast(size);
  1849     cfs->skip_u2_fast(size);
  1831   } else {
  1850   } else {
  1832     cfs->guarantee_more(size * 2, CHECK_NULL);
  1851     cfs->guarantee_more(size * 2, CHECK_NULL);
  1926 
  1945 
  1927   if (0 == code_attribute_length) {
  1946   if (0 == code_attribute_length) {
  1928     return NULL;
  1947     return NULL;
  1929   }
  1948   }
  1930 
  1949 
  1931   const u1* const stackmap_table_start = cfs->get_u1_buffer();
  1950   const u1* const stackmap_table_start = cfs->current();
  1932   assert(stackmap_table_start != NULL, "null stackmap table");
  1951   assert(stackmap_table_start != NULL, "null stackmap table");
  1933 
  1952 
  1934   // check code_attribute_length first
  1953   // check code_attribute_length first
  1935   cfs->skip_u1(code_attribute_length, CHECK_NULL);
  1954   cfs->skip_u1(code_attribute_length, CHECK_NULL);
  1936 
  1955 
  1938     return NULL;
  1957     return NULL;
  1939   }
  1958   }
  1940   return stackmap_table_start;
  1959   return stackmap_table_start;
  1941 }
  1960 }
  1942 
  1961 
  1943 const u2* ClassFileParser::parse_checked_exceptions(const ClassFileStream* const cfs,
  1962 const ClassFileParser::unsafe_u2* ClassFileParser::parse_checked_exceptions(const ClassFileStream* const cfs,
  1944                                                     u2* const checked_exceptions_length,
  1963                                                                             u2* const checked_exceptions_length,
  1945                                                     u4 method_attribute_length,
  1964                                                                             u4 method_attribute_length,
  1946                                                     TRAPS) {
  1965                                                                             TRAPS) {
  1947   assert(cfs != NULL, "invariant");
  1966   assert(cfs != NULL, "invariant");
  1948   assert(checked_exceptions_length != NULL, "invariant");
  1967   assert(checked_exceptions_length != NULL, "invariant");
  1949 
  1968 
  1950   cfs->guarantee_more(2, CHECK_NULL);  // checked_exceptions_length
  1969   cfs->guarantee_more(2, CHECK_NULL);  // checked_exceptions_length
  1951   *checked_exceptions_length = cfs->get_u2_fast();
  1970   *checked_exceptions_length = cfs->get_u2_fast();
  1952   const unsigned int size =
  1971   const unsigned int size =
  1953     (*checked_exceptions_length) * sizeof(CheckedExceptionElement) / sizeof(u2);
  1972     (*checked_exceptions_length) * sizeof(CheckedExceptionElement) / sizeof(u2);
  1954   const u2* const checked_exceptions_start = cfs->get_u2_buffer();
  1973   const unsafe_u2* const checked_exceptions_start = cfs->current();
  1955   assert(checked_exceptions_start != NULL, "null checked exceptions");
  1974   assert(checked_exceptions_start != NULL, "null checked exceptions");
  1956   if (!_need_verify) {
  1975   if (!_need_verify) {
  1957     cfs->skip_u2_fast(size);
  1976     cfs->skip_u2_fast(size);
  1958   } else {
  1977   } else {
  1959     // Verify each value in the checked exception table
  1978     // Verify each value in the checked exception table
  2116  *   - HotSpot internal LVT keeps natural ordering of class file LVT entries.
  2135  *   - HotSpot internal LVT keeps natural ordering of class file LVT entries.
  2117  */
  2136  */
  2118 void ClassFileParser::copy_localvariable_table(const ConstMethod* cm,
  2137 void ClassFileParser::copy_localvariable_table(const ConstMethod* cm,
  2119                                                int lvt_cnt,
  2138                                                int lvt_cnt,
  2120                                                u2* const localvariable_table_length,
  2139                                                u2* const localvariable_table_length,
  2121                                                const u2**const localvariable_table_start,
  2140                                                const unsafe_u2** const localvariable_table_start,
  2122                                                int lvtt_cnt,
  2141                                                int lvtt_cnt,
  2123                                                u2* const localvariable_type_table_length,
  2142                                                u2* const localvariable_type_table_length,
  2124                                                const u2**const localvariable_type_table_start,
  2143                                                const unsafe_u2** const localvariable_type_table_start,
  2125                                                TRAPS) {
  2144                                                TRAPS) {
  2126 
  2145 
  2127   ResourceMark rm(THREAD);
  2146   ResourceMark rm(THREAD);
  2128 
  2147 
  2129   typedef ResourceHashtable<LocalVariableTableElement, LocalVariableTableElement*,
  2148   typedef ResourceHashtable<LocalVariableTableElement, LocalVariableTableElement*,
  2314   u2 max_stack = 0;
  2333   u2 max_stack = 0;
  2315   u2 max_locals = 0;
  2334   u2 max_locals = 0;
  2316   u4 code_length = 0;
  2335   u4 code_length = 0;
  2317   const u1* code_start = 0;
  2336   const u1* code_start = 0;
  2318   u2 exception_table_length = 0;
  2337   u2 exception_table_length = 0;
  2319   const u2* exception_table_start = NULL;
  2338   const unsafe_u2* exception_table_start = NULL; // (potentially unaligned) pointer to array of u2 elements
  2320   Array<int>* exception_handlers = Universe::the_empty_int_array();
  2339   Array<int>* exception_handlers = Universe::the_empty_int_array();
  2321   u2 checked_exceptions_length = 0;
  2340   u2 checked_exceptions_length = 0;
  2322   const u2* checked_exceptions_start = NULL;
  2341   const unsafe_u2* checked_exceptions_start = NULL; // (potentially unaligned) pointer to array of u2 elements
  2323   CompressedLineNumberWriteStream* linenumber_table = NULL;
  2342   CompressedLineNumberWriteStream* linenumber_table = NULL;
  2324   int linenumber_table_length = 0;
  2343   int linenumber_table_length = 0;
  2325   int total_lvt_length = 0;
  2344   int total_lvt_length = 0;
  2326   u2 lvt_cnt = 0;
  2345   u2 lvt_cnt = 0;
  2327   u2 lvtt_cnt = 0;
  2346   u2 lvtt_cnt = 0;
  2328   bool lvt_allocated = false;
  2347   bool lvt_allocated = false;
  2329   u2 max_lvt_cnt = INITIAL_MAX_LVT_NUMBER;
  2348   u2 max_lvt_cnt = INITIAL_MAX_LVT_NUMBER;
  2330   u2 max_lvtt_cnt = INITIAL_MAX_LVT_NUMBER;
  2349   u2 max_lvtt_cnt = INITIAL_MAX_LVT_NUMBER;
  2331   u2* localvariable_table_length = NULL;
  2350   u2* localvariable_table_length = NULL;
  2332   const u2** localvariable_table_start = NULL;
  2351   const unsafe_u2** localvariable_table_start = NULL; // (potentially unaligned) pointer to array of LVT attributes
  2333   u2* localvariable_type_table_length = NULL;
  2352   u2* localvariable_type_table_length = NULL;
  2334   const u2** localvariable_type_table_start = NULL;
  2353   const unsafe_u2** localvariable_type_table_start = NULL; // (potentially unaligned) pointer to LVTT attributes
  2335   int method_parameters_length = -1;
  2354   int method_parameters_length = -1;
  2336   const u1* method_parameters_data = NULL;
  2355   const u1* method_parameters_data = NULL;
  2337   bool method_parameters_seen = false;
  2356   bool method_parameters_seen = false;
  2338   bool parsed_code_attribute = false;
  2357   bool parsed_code_attribute = false;
  2339   bool parsed_checked_exceptions_attribute = false;
  2358   bool parsed_checked_exceptions_attribute = false;
  2406         guarantee_property(code_length > 0 && code_length <= MAX_CODE_SIZE,
  2425         guarantee_property(code_length > 0 && code_length <= MAX_CODE_SIZE,
  2407                            "Invalid method Code length %u in class file %s",
  2426                            "Invalid method Code length %u in class file %s",
  2408                            code_length, CHECK_NULL);
  2427                            code_length, CHECK_NULL);
  2409       }
  2428       }
  2410       // Code pointer
  2429       // Code pointer
  2411       code_start = cfs->get_u1_buffer();
  2430       code_start = cfs->current();
  2412       assert(code_start != NULL, "null code start");
  2431       assert(code_start != NULL, "null code start");
  2413       cfs->guarantee_more(code_length, CHECK_NULL);
  2432       cfs->guarantee_more(code_length, CHECK_NULL);
  2414       cfs->skip_u1_fast(code_length);
  2433       cfs->skip_u1_fast(code_length);
  2415 
  2434 
  2416       // Exception handler table
  2435       // Exception handler table
  2470           // Parse local variable table
  2489           // Parse local variable table
  2471           if (!lvt_allocated) {
  2490           if (!lvt_allocated) {
  2472             localvariable_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
  2491             localvariable_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
  2473               THREAD, u2,  INITIAL_MAX_LVT_NUMBER);
  2492               THREAD, u2,  INITIAL_MAX_LVT_NUMBER);
  2474             localvariable_table_start = NEW_RESOURCE_ARRAY_IN_THREAD(
  2493             localvariable_table_start = NEW_RESOURCE_ARRAY_IN_THREAD(
  2475               THREAD, const u2*, INITIAL_MAX_LVT_NUMBER);
  2494               THREAD, const unsafe_u2*, INITIAL_MAX_LVT_NUMBER);
  2476             localvariable_type_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
  2495             localvariable_type_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
  2477               THREAD, u2,  INITIAL_MAX_LVT_NUMBER);
  2496               THREAD, u2,  INITIAL_MAX_LVT_NUMBER);
  2478             localvariable_type_table_start = NEW_RESOURCE_ARRAY_IN_THREAD(
  2497             localvariable_type_table_start = NEW_RESOURCE_ARRAY_IN_THREAD(
  2479               THREAD, const u2*, INITIAL_MAX_LVT_NUMBER);
  2498               THREAD, const unsafe_u2*, INITIAL_MAX_LVT_NUMBER);
  2480             lvt_allocated = true;
  2499             lvt_allocated = true;
  2481           }
  2500           }
  2482           if (lvt_cnt == max_lvt_cnt) {
  2501           if (lvt_cnt == max_lvt_cnt) {
  2483             max_lvt_cnt <<= 1;
  2502             max_lvt_cnt <<= 1;
  2484             localvariable_table_length = REALLOC_RESOURCE_ARRAY(u2, localvariable_table_length, lvt_cnt, max_lvt_cnt);
  2503             localvariable_table_length = REALLOC_RESOURCE_ARRAY(u2, localvariable_table_length, lvt_cnt, max_lvt_cnt);
  2485             localvariable_table_start  = REALLOC_RESOURCE_ARRAY(const u2*, localvariable_table_start, lvt_cnt, max_lvt_cnt);
  2504             localvariable_table_start  = REALLOC_RESOURCE_ARRAY(const unsafe_u2*, localvariable_table_start, lvt_cnt, max_lvt_cnt);
  2486           }
  2505           }
  2487           localvariable_table_start[lvt_cnt] =
  2506           localvariable_table_start[lvt_cnt] =
  2488             parse_localvariable_table(cfs,
  2507             parse_localvariable_table(cfs,
  2489                                       code_length,
  2508                                       code_length,
  2490                                       max_locals,
  2509                                       max_locals,
  2499                    cp->symbol_at(code_attribute_name_index) == vmSymbols::tag_local_variable_type_table()) {
  2518                    cp->symbol_at(code_attribute_name_index) == vmSymbols::tag_local_variable_type_table()) {
  2500           if (!lvt_allocated) {
  2519           if (!lvt_allocated) {
  2501             localvariable_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
  2520             localvariable_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
  2502               THREAD, u2,  INITIAL_MAX_LVT_NUMBER);
  2521               THREAD, u2,  INITIAL_MAX_LVT_NUMBER);
  2503             localvariable_table_start = NEW_RESOURCE_ARRAY_IN_THREAD(
  2522             localvariable_table_start = NEW_RESOURCE_ARRAY_IN_THREAD(
  2504               THREAD, const u2*, INITIAL_MAX_LVT_NUMBER);
  2523               THREAD, const unsafe_u2*, INITIAL_MAX_LVT_NUMBER);
  2505             localvariable_type_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
  2524             localvariable_type_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
  2506               THREAD, u2,  INITIAL_MAX_LVT_NUMBER);
  2525               THREAD, u2,  INITIAL_MAX_LVT_NUMBER);
  2507             localvariable_type_table_start = NEW_RESOURCE_ARRAY_IN_THREAD(
  2526             localvariable_type_table_start = NEW_RESOURCE_ARRAY_IN_THREAD(
  2508               THREAD, const u2*, INITIAL_MAX_LVT_NUMBER);
  2527               THREAD, const unsafe_u2*, INITIAL_MAX_LVT_NUMBER);
  2509             lvt_allocated = true;
  2528             lvt_allocated = true;
  2510           }
  2529           }
  2511           // Parse local variable type table
  2530           // Parse local variable type table
  2512           if (lvtt_cnt == max_lvtt_cnt) {
  2531           if (lvtt_cnt == max_lvtt_cnt) {
  2513             max_lvtt_cnt <<= 1;
  2532             max_lvtt_cnt <<= 1;
  2514             localvariable_type_table_length = REALLOC_RESOURCE_ARRAY(u2, localvariable_type_table_length, lvtt_cnt, max_lvtt_cnt);
  2533             localvariable_type_table_length = REALLOC_RESOURCE_ARRAY(u2, localvariable_type_table_length, lvtt_cnt, max_lvtt_cnt);
  2515             localvariable_type_table_start  = REALLOC_RESOURCE_ARRAY(const u2*, localvariable_type_table_start, lvtt_cnt, max_lvtt_cnt);
  2534             localvariable_type_table_start  = REALLOC_RESOURCE_ARRAY(const unsafe_u2*, localvariable_type_table_start, lvtt_cnt, max_lvtt_cnt);
  2516           }
  2535           }
  2517           localvariable_type_table_start[lvtt_cnt] =
  2536           localvariable_type_table_start[lvtt_cnt] =
  2518             parse_localvariable_table(cfs,
  2537             parse_localvariable_table(cfs,
  2519                                       code_length,
  2538                                       code_length,
  2520                                       max_locals,
  2539                                       max_locals,
  2567       if (method_attribute_length != real_length) {
  2586       if (method_attribute_length != real_length) {
  2568         classfile_parse_error(
  2587         classfile_parse_error(
  2569           "Invalid MethodParameters method attribute length %u in class file",
  2588           "Invalid MethodParameters method attribute length %u in class file",
  2570           method_attribute_length, CHECK_NULL);
  2589           method_attribute_length, CHECK_NULL);
  2571       }
  2590       }
  2572       method_parameters_data = cfs->get_u1_buffer();
  2591       method_parameters_data = cfs->current();
  2573       cfs->skip_u2_fast(method_parameters_length);
  2592       cfs->skip_u2_fast(method_parameters_length);
  2574       cfs->skip_u2_fast(method_parameters_length);
  2593       cfs->skip_u2_fast(method_parameters_length);
  2575       // ignore this attribute if it cannot be reflected
  2594       // ignore this attribute if it cannot be reflected
  2576       if (!SystemDictionary::Parameter_klass_loaded())
  2595       if (!SystemDictionary::Parameter_klass_loaded())
  2577         method_parameters_length = -1;
  2596         method_parameters_length = -1;
  2607           classfile_parse_error(
  2626           classfile_parse_error(
  2608             "Multiple RuntimeVisibleAnnotations attributes for method in class file %s",
  2627             "Multiple RuntimeVisibleAnnotations attributes for method in class file %s",
  2609             CHECK_NULL);
  2628             CHECK_NULL);
  2610         }
  2629         }
  2611         runtime_visible_annotations_length = method_attribute_length;
  2630         runtime_visible_annotations_length = method_attribute_length;
  2612         runtime_visible_annotations = cfs->get_u1_buffer();
  2631         runtime_visible_annotations = cfs->current();
  2613         assert(runtime_visible_annotations != NULL, "null visible annotations");
  2632         assert(runtime_visible_annotations != NULL, "null visible annotations");
  2614         cfs->guarantee_more(runtime_visible_annotations_length, CHECK_NULL);
  2633         cfs->guarantee_more(runtime_visible_annotations_length, CHECK_NULL);
  2615         parse_annotations(cp,
  2634         parse_annotations(cp,
  2616                           runtime_visible_annotations,
  2635                           runtime_visible_annotations,
  2617                           runtime_visible_annotations_length,
  2636                           runtime_visible_annotations_length,
  2626             CHECK_NULL);
  2645             CHECK_NULL);
  2627         }
  2646         }
  2628         runtime_invisible_annotations_exists = true;
  2647         runtime_invisible_annotations_exists = true;
  2629         if (PreserveAllAnnotations) {
  2648         if (PreserveAllAnnotations) {
  2630           runtime_invisible_annotations_length = method_attribute_length;
  2649           runtime_invisible_annotations_length = method_attribute_length;
  2631           runtime_invisible_annotations = cfs->get_u1_buffer();
  2650           runtime_invisible_annotations = cfs->current();
  2632           assert(runtime_invisible_annotations != NULL, "null invisible annotations");
  2651           assert(runtime_invisible_annotations != NULL, "null invisible annotations");
  2633         }
  2652         }
  2634         cfs->skip_u1(method_attribute_length, CHECK_NULL);
  2653         cfs->skip_u1(method_attribute_length, CHECK_NULL);
  2635       } else if (method_attribute_name == vmSymbols::tag_runtime_visible_parameter_annotations()) {
  2654       } else if (method_attribute_name == vmSymbols::tag_runtime_visible_parameter_annotations()) {
  2636         if (runtime_visible_parameter_annotations != NULL) {
  2655         if (runtime_visible_parameter_annotations != NULL) {
  2637           classfile_parse_error(
  2656           classfile_parse_error(
  2638             "Multiple RuntimeVisibleParameterAnnotations attributes for method in class file %s",
  2657             "Multiple RuntimeVisibleParameterAnnotations attributes for method in class file %s",
  2639             CHECK_NULL);
  2658             CHECK_NULL);
  2640         }
  2659         }
  2641         runtime_visible_parameter_annotations_length = method_attribute_length;
  2660         runtime_visible_parameter_annotations_length = method_attribute_length;
  2642         runtime_visible_parameter_annotations = cfs->get_u1_buffer();
  2661         runtime_visible_parameter_annotations = cfs->current();
  2643         assert(runtime_visible_parameter_annotations != NULL, "null visible parameter annotations");
  2662         assert(runtime_visible_parameter_annotations != NULL, "null visible parameter annotations");
  2644         cfs->skip_u1(runtime_visible_parameter_annotations_length, CHECK_NULL);
  2663         cfs->skip_u1(runtime_visible_parameter_annotations_length, CHECK_NULL);
  2645       } else if (method_attribute_name == vmSymbols::tag_runtime_invisible_parameter_annotations()) {
  2664       } else if (method_attribute_name == vmSymbols::tag_runtime_invisible_parameter_annotations()) {
  2646         if (runtime_invisible_parameter_annotations_exists) {
  2665         if (runtime_invisible_parameter_annotations_exists) {
  2647           classfile_parse_error(
  2666           classfile_parse_error(
  2649             CHECK_NULL);
  2668             CHECK_NULL);
  2650         }
  2669         }
  2651         runtime_invisible_parameter_annotations_exists = true;
  2670         runtime_invisible_parameter_annotations_exists = true;
  2652         if (PreserveAllAnnotations) {
  2671         if (PreserveAllAnnotations) {
  2653           runtime_invisible_parameter_annotations_length = method_attribute_length;
  2672           runtime_invisible_parameter_annotations_length = method_attribute_length;
  2654           runtime_invisible_parameter_annotations = cfs->get_u1_buffer();
  2673           runtime_invisible_parameter_annotations = cfs->current();
  2655           assert(runtime_invisible_parameter_annotations != NULL,
  2674           assert(runtime_invisible_parameter_annotations != NULL,
  2656             "null invisible parameter annotations");
  2675             "null invisible parameter annotations");
  2657         }
  2676         }
  2658         cfs->skip_u1(method_attribute_length, CHECK_NULL);
  2677         cfs->skip_u1(method_attribute_length, CHECK_NULL);
  2659       } else if (method_attribute_name == vmSymbols::tag_annotation_default()) {
  2678       } else if (method_attribute_name == vmSymbols::tag_annotation_default()) {
  2661           classfile_parse_error(
  2680           classfile_parse_error(
  2662             "Multiple AnnotationDefault attributes for method in class file %s",
  2681             "Multiple AnnotationDefault attributes for method in class file %s",
  2663             CHECK_NULL);
  2682             CHECK_NULL);
  2664         }
  2683         }
  2665         annotation_default_length = method_attribute_length;
  2684         annotation_default_length = method_attribute_length;
  2666         annotation_default = cfs->get_u1_buffer();
  2685         annotation_default = cfs->current();
  2667         assert(annotation_default != NULL, "null annotation default");
  2686         assert(annotation_default != NULL, "null annotation default");
  2668         cfs->skip_u1(annotation_default_length, CHECK_NULL);
  2687         cfs->skip_u1(annotation_default_length, CHECK_NULL);
  2669       } else if (method_attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) {
  2688       } else if (method_attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) {
  2670         if (runtime_visible_type_annotations != NULL) {
  2689         if (runtime_visible_type_annotations != NULL) {
  2671           classfile_parse_error(
  2690           classfile_parse_error(
  2672             "Multiple RuntimeVisibleTypeAnnotations attributes for method in class file %s",
  2691             "Multiple RuntimeVisibleTypeAnnotations attributes for method in class file %s",
  2673             CHECK_NULL);
  2692             CHECK_NULL);
  2674         }
  2693         }
  2675         runtime_visible_type_annotations_length = method_attribute_length;
  2694         runtime_visible_type_annotations_length = method_attribute_length;
  2676         runtime_visible_type_annotations = cfs->get_u1_buffer();
  2695         runtime_visible_type_annotations = cfs->current();
  2677         assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
  2696         assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
  2678         // No need for the VM to parse Type annotations
  2697         // No need for the VM to parse Type annotations
  2679         cfs->skip_u1(runtime_visible_type_annotations_length, CHECK_NULL);
  2698         cfs->skip_u1(runtime_visible_type_annotations_length, CHECK_NULL);
  2680       } else if (method_attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) {
  2699       } else if (method_attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) {
  2681         if (runtime_invisible_type_annotations_exists) {
  2700         if (runtime_invisible_type_annotations_exists) {
  2685         } else {
  2704         } else {
  2686           runtime_invisible_type_annotations_exists = true;
  2705           runtime_invisible_type_annotations_exists = true;
  2687         }
  2706         }
  2688         if (PreserveAllAnnotations) {
  2707         if (PreserveAllAnnotations) {
  2689           runtime_invisible_type_annotations_length = method_attribute_length;
  2708           runtime_invisible_type_annotations_length = method_attribute_length;
  2690           runtime_invisible_type_annotations = cfs->get_u1_buffer();
  2709           runtime_invisible_type_annotations = cfs->current();
  2691           assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
  2710           assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
  2692         }
  2711         }
  2693         cfs->skip_u1(method_attribute_length, CHECK_NULL);
  2712         cfs->skip_u1(method_attribute_length, CHECK_NULL);
  2694       } else {
  2713       } else {
  2695         // Skip unknown attributes
  2714         // Skip unknown attributes
  2781            linenumber_table_length);
  2800            linenumber_table_length);
  2782   }
  2801   }
  2783 
  2802 
  2784   // Copy exception table
  2803   // Copy exception table
  2785   if (exception_table_length > 0) {
  2804   if (exception_table_length > 0) {
  2786     int size =
  2805     Copy::conjoint_swap_if_needed<Endian::JAVA>(exception_table_start,
  2787       exception_table_length * sizeof(ExceptionTableElement) / sizeof(u2);
  2806                                                 m->exception_table_start(),
  2788     copy_u2_with_conversion((u2*) m->exception_table_start(),
  2807                                                 exception_table_length * sizeof(ExceptionTableElement),
  2789                             exception_table_start, size);
  2808                                                 sizeof(u2));
  2790   }
  2809   }
  2791 
  2810 
  2792   // Copy method parameters
  2811   // Copy method parameters
  2793   if (method_parameters_length > 0) {
  2812   if (method_parameters_length > 0) {
  2794     MethodParametersElement* elem = m->constMethod()->method_parameters_start();
  2813     MethodParametersElement* elem = m->constMethod()->method_parameters_start();
  2800     }
  2819     }
  2801   }
  2820   }
  2802 
  2821 
  2803   // Copy checked exceptions
  2822   // Copy checked exceptions
  2804   if (checked_exceptions_length > 0) {
  2823   if (checked_exceptions_length > 0) {
  2805     const int size =
  2824     Copy::conjoint_swap_if_needed<Endian::JAVA>(checked_exceptions_start,
  2806       checked_exceptions_length * sizeof(CheckedExceptionElement) / sizeof(u2);
  2825                                                 m->checked_exceptions_start(),
  2807     copy_u2_with_conversion((u2*) m->checked_exceptions_start(),
  2826                                                 checked_exceptions_length * sizeof(CheckedExceptionElement),
  2808                             checked_exceptions_start,
  2827                                                 sizeof(u2));
  2809                             size);
       
  2810   }
  2828   }
  2811 
  2829 
  2812   // Copy class file LVT's/LVTT's into the HotSpot internal LVT.
  2830   // Copy class file LVT's/LVTT's into the HotSpot internal LVT.
  2813   if (total_lvt_length > 0) {
  2831   if (total_lvt_length > 0) {
  2814     promoted_flags->set_has_localvariable_table();
  2832     promoted_flags->set_has_localvariable_table();
  2887     _methods = MetadataFactory::new_array<Method*>(_loader_data,
  2905     _methods = MetadataFactory::new_array<Method*>(_loader_data,
  2888                                                    length,
  2906                                                    length,
  2889                                                    NULL,
  2907                                                    NULL,
  2890                                                    CHECK);
  2908                                                    CHECK);
  2891 
  2909 
  2892     HandleMark hm(THREAD);
       
  2893     for (int index = 0; index < length; index++) {
  2910     for (int index = 0; index < length; index++) {
  2894       Method* method = parse_method(cfs,
  2911       Method* method = parse_method(cfs,
  2895                                     is_interface,
  2912                                     is_interface,
  2896                                     _cp,
  2913                                     _cp,
  2897                                     promoted_flags,
  2914                                     promoted_flags,
  2914       ResourceMark rm(THREAD);
  2931       ResourceMark rm(THREAD);
  2915       NameSigHash** names_and_sigs = NEW_RESOURCE_ARRAY_IN_THREAD(
  2932       NameSigHash** names_and_sigs = NEW_RESOURCE_ARRAY_IN_THREAD(
  2916         THREAD, NameSigHash*, HASH_ROW_SIZE);
  2933         THREAD, NameSigHash*, HASH_ROW_SIZE);
  2917       initialize_hashtable(names_and_sigs);
  2934       initialize_hashtable(names_and_sigs);
  2918       bool dup = false;
  2935       bool dup = false;
       
  2936       const Symbol* name = NULL;
       
  2937       const Symbol* sig = NULL;
  2919       {
  2938       {
  2920         debug_only(NoSafepointVerifier nsv;)
  2939         debug_only(NoSafepointVerifier nsv;)
  2921         for (int i = 0; i < length; i++) {
  2940         for (int i = 0; i < length; i++) {
  2922           const Method* const m = _methods->at(i);
  2941           const Method* const m = _methods->at(i);
       
  2942           name = m->name();
       
  2943           sig = m->signature();
  2923           // If no duplicates, add name/signature in hashtable names_and_sigs.
  2944           // If no duplicates, add name/signature in hashtable names_and_sigs.
  2924           if (!put_after_lookup(m->name(), m->signature(), names_and_sigs)) {
  2945           if (!put_after_lookup(name, sig, names_and_sigs)) {
  2925             dup = true;
  2946             dup = true;
  2926             break;
  2947             break;
  2927           }
  2948           }
  2928         }
  2949         }
  2929       }
  2950       }
  2930       if (dup) {
  2951       if (dup) {
  2931         classfile_parse_error("Duplicate method name&signature in class file %s",
  2952         classfile_parse_error("Duplicate method name \"%s\" with signature \"%s\" in class file %s",
  2932                               CHECK);
  2953                                name->as_C_string(), sig->as_klass_external_name(), CHECK);
  2933       }
  2954       }
  2934     }
  2955     }
  2935   }
  2956   }
  2936 }
  2957 }
  2937 
  2958 
  3000 void ClassFileParser::parse_classfile_source_debug_extension_attribute(const ClassFileStream* const cfs,
  3021 void ClassFileParser::parse_classfile_source_debug_extension_attribute(const ClassFileStream* const cfs,
  3001                                                                        int length,
  3022                                                                        int length,
  3002                                                                        TRAPS) {
  3023                                                                        TRAPS) {
  3003   assert(cfs != NULL, "invariant");
  3024   assert(cfs != NULL, "invariant");
  3004 
  3025 
  3005   const u1* const sde_buffer = cfs->get_u1_buffer();
  3026   const u1* const sde_buffer = cfs->current();
  3006   assert(sde_buffer != NULL, "null sde buffer");
  3027   assert(sde_buffer != NULL, "null sde buffer");
  3007 
  3028 
  3008   // Don't bother storing it if there is no way to retrieve it
  3029   // Don't bother storing it if there is no way to retrieve it
  3009   if (JvmtiExport::can_get_source_debug_extension()) {
  3030   if (JvmtiExport::can_get_source_debug_extension()) {
  3010     assert((length+1) > length, "Overflow checking");
  3031     assert((length+1) > length, "Overflow checking");
  3292       if (parsed_innerclasses_attribute) {
  3313       if (parsed_innerclasses_attribute) {
  3293         classfile_parse_error("Multiple InnerClasses attributes in class file %s", CHECK);
  3314         classfile_parse_error("Multiple InnerClasses attributes in class file %s", CHECK);
  3294       } else {
  3315       } else {
  3295         parsed_innerclasses_attribute = true;
  3316         parsed_innerclasses_attribute = true;
  3296       }
  3317       }
  3297       inner_classes_attribute_start = cfs->get_u1_buffer();
  3318       inner_classes_attribute_start = cfs->current();
  3298       inner_classes_attribute_length = attribute_length;
  3319       inner_classes_attribute_length = attribute_length;
  3299       cfs->skip_u1(inner_classes_attribute_length, CHECK);
  3320       cfs->skip_u1(inner_classes_attribute_length, CHECK);
  3300     } else if (tag == vmSymbols::tag_synthetic()) {
  3321     } else if (tag == vmSymbols::tag_synthetic()) {
  3301       // Check for Synthetic tag
  3322       // Check for Synthetic tag
  3302       // Shouldn't we check that the synthetic flags wasn't already set? - not required in spec
  3323       // Shouldn't we check that the synthetic flags wasn't already set? - not required in spec
  3329         if (runtime_visible_annotations != NULL) {
  3350         if (runtime_visible_annotations != NULL) {
  3330           classfile_parse_error(
  3351           classfile_parse_error(
  3331             "Multiple RuntimeVisibleAnnotations attributes in class file %s", CHECK);
  3352             "Multiple RuntimeVisibleAnnotations attributes in class file %s", CHECK);
  3332         }
  3353         }
  3333         runtime_visible_annotations_length = attribute_length;
  3354         runtime_visible_annotations_length = attribute_length;
  3334         runtime_visible_annotations = cfs->get_u1_buffer();
  3355         runtime_visible_annotations = cfs->current();
  3335         assert(runtime_visible_annotations != NULL, "null visible annotations");
  3356         assert(runtime_visible_annotations != NULL, "null visible annotations");
  3336         cfs->guarantee_more(runtime_visible_annotations_length, CHECK);
  3357         cfs->guarantee_more(runtime_visible_annotations_length, CHECK);
  3337         parse_annotations(cp,
  3358         parse_annotations(cp,
  3338                           runtime_visible_annotations,
  3359                           runtime_visible_annotations,
  3339                           runtime_visible_annotations_length,
  3360                           runtime_visible_annotations_length,
  3347             "Multiple RuntimeInvisibleAnnotations attributes in class file %s", CHECK);
  3368             "Multiple RuntimeInvisibleAnnotations attributes in class file %s", CHECK);
  3348         }
  3369         }
  3349         runtime_invisible_annotations_exists = true;
  3370         runtime_invisible_annotations_exists = true;
  3350         if (PreserveAllAnnotations) {
  3371         if (PreserveAllAnnotations) {
  3351           runtime_invisible_annotations_length = attribute_length;
  3372           runtime_invisible_annotations_length = attribute_length;
  3352           runtime_invisible_annotations = cfs->get_u1_buffer();
  3373           runtime_invisible_annotations = cfs->current();
  3353           assert(runtime_invisible_annotations != NULL, "null invisible annotations");
  3374           assert(runtime_invisible_annotations != NULL, "null invisible annotations");
  3354         }
  3375         }
  3355         cfs->skip_u1(attribute_length, CHECK);
  3376         cfs->skip_u1(attribute_length, CHECK);
  3356       } else if (tag == vmSymbols::tag_enclosing_method()) {
  3377       } else if (tag == vmSymbols::tag_enclosing_method()) {
  3357         if (parsed_enclosingmethod_attribute) {
  3378         if (parsed_enclosingmethod_attribute) {
  3387         if (runtime_visible_type_annotations != NULL) {
  3408         if (runtime_visible_type_annotations != NULL) {
  3388           classfile_parse_error(
  3409           classfile_parse_error(
  3389             "Multiple RuntimeVisibleTypeAnnotations attributes in class file %s", CHECK);
  3410             "Multiple RuntimeVisibleTypeAnnotations attributes in class file %s", CHECK);
  3390         }
  3411         }
  3391         runtime_visible_type_annotations_length = attribute_length;
  3412         runtime_visible_type_annotations_length = attribute_length;
  3392         runtime_visible_type_annotations = cfs->get_u1_buffer();
  3413         runtime_visible_type_annotations = cfs->current();
  3393         assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
  3414         assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
  3394         // No need for the VM to parse Type annotations
  3415         // No need for the VM to parse Type annotations
  3395         cfs->skip_u1(runtime_visible_type_annotations_length, CHECK);
  3416         cfs->skip_u1(runtime_visible_type_annotations_length, CHECK);
  3396       } else if (tag == vmSymbols::tag_runtime_invisible_type_annotations()) {
  3417       } else if (tag == vmSymbols::tag_runtime_invisible_type_annotations()) {
  3397         if (runtime_invisible_type_annotations_exists) {
  3418         if (runtime_invisible_type_annotations_exists) {
  3400         } else {
  3421         } else {
  3401           runtime_invisible_type_annotations_exists = true;
  3422           runtime_invisible_type_annotations_exists = true;
  3402         }
  3423         }
  3403         if (PreserveAllAnnotations) {
  3424         if (PreserveAllAnnotations) {
  3404           runtime_invisible_type_annotations_length = attribute_length;
  3425           runtime_invisible_type_annotations_length = attribute_length;
  3405           runtime_invisible_type_annotations = cfs->get_u1_buffer();
  3426           runtime_invisible_type_annotations = cfs->current();
  3406           assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
  3427           assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
  3407         }
  3428         }
  3408         cfs->skip_u1(attribute_length, CHECK);
  3429         cfs->skip_u1(attribute_length, CHECK);
  3409       } else {
  3430       } else {
  3410         // Unknown attribute
  3431         // Unknown attribute
  4421         return;
  4442         return;
  4422       }
  4443       }
  4423     }
  4444     }
  4424 
  4445 
  4425     Reflection::VerifyClassAccessResults vca_result =
  4446     Reflection::VerifyClassAccessResults vca_result =
  4426       Reflection::verify_class_access(this_klass, super, false);
  4447       Reflection::verify_class_access(this_klass, InstanceKlass::cast(super), false);
  4427     if (vca_result != Reflection::ACCESS_OK) {
  4448     if (vca_result != Reflection::ACCESS_OK) {
  4428       ResourceMark rm(THREAD);
  4449       ResourceMark rm(THREAD);
  4429       char* msg =  Reflection::verify_class_access_msg(this_klass, super, vca_result);
  4450       char* msg = Reflection::verify_class_access_msg(this_klass,
       
  4451                                                       InstanceKlass::cast(super),
       
  4452                                                       vca_result);
  4430       if (msg == NULL) {
  4453       if (msg == NULL) {
  4431         Exceptions::fthrow(
  4454         Exceptions::fthrow(
  4432           THREAD_AND_LOCATION,
  4455           THREAD_AND_LOCATION,
  4433           vmSymbols::java_lang_IllegalAccessError(),
  4456           vmSymbols::java_lang_IllegalAccessError(),
  4434           "class %s cannot access its superclass %s",
  4457           "class %s cannot access its superclass %s",
  4453   const int lng = local_interfaces->length();
  4476   const int lng = local_interfaces->length();
  4454   for (int i = lng - 1; i >= 0; i--) {
  4477   for (int i = lng - 1; i >= 0; i--) {
  4455     Klass* const k = local_interfaces->at(i);
  4478     Klass* const k = local_interfaces->at(i);
  4456     assert (k != NULL && k->is_interface(), "invalid interface");
  4479     assert (k != NULL && k->is_interface(), "invalid interface");
  4457     Reflection::VerifyClassAccessResults vca_result =
  4480     Reflection::VerifyClassAccessResults vca_result =
  4458       Reflection::verify_class_access(this_klass, k, false);
  4481       Reflection::verify_class_access(this_klass, InstanceKlass::cast(k), false);
  4459     if (vca_result != Reflection::ACCESS_OK) {
  4482     if (vca_result != Reflection::ACCESS_OK) {
  4460       ResourceMark rm(THREAD);
  4483       ResourceMark rm(THREAD);
  4461       char* msg =  Reflection::verify_class_access_msg(this_klass, k, vca_result);
  4484       char* msg = Reflection::verify_class_access_msg(this_klass,
       
  4485                                                       InstanceKlass::cast(k),
       
  4486                                                       vca_result);
  4462       if (msg == NULL) {
  4487       if (msg == NULL) {
  4463         Exceptions::fthrow(
  4488         Exceptions::fthrow(
  4464           THREAD_AND_LOCATION,
  4489           THREAD_AND_LOCATION,
  4465           vmSymbols::java_lang_IllegalAccessError(),
  4490           vmSymbols::java_lang_IllegalAccessError(),
  4466           "class %s cannot access its superinterface %s",
  4491           "class %s cannot access its superinterface %s",
  5328   ik->set_initial_method_idnum(ik->methods()->length());
  5353   ik->set_initial_method_idnum(ik->methods()->length());
  5329 
  5354 
  5330   ik->set_name(_class_name);
  5355   ik->set_name(_class_name);
  5331 
  5356 
  5332   if (is_anonymous()) {
  5357   if (is_anonymous()) {
  5333     // I am well known to myself
  5358     // _this_class_index is a CONSTANT_Class entry that refers to this
  5334     ik->constants()->klass_at_put(_this_class_index, ik); // eagerly resolve
  5359     // anonymous class itself. If this class needs to refer to its own methods or
       
  5360     // fields, it would use a CONSTANT_MethodRef, etc, which would reference
       
  5361     // _this_class_index. However, because this class is anonymous (it's
       
  5362     // not stored in SystemDictionary), _this_class_index cannot be resolved
       
  5363     // with ConstantPool::klass_at_impl, which does a SystemDictionary lookup.
       
  5364     // Therefore, we must eagerly resolve _this_class_index now.
       
  5365     ik->constants()->klass_at_put(_this_class_index, ik);
  5335   }
  5366   }
  5336 
  5367 
  5337   ik->set_minor_version(_minor_version);
  5368   ik->set_minor_version(_minor_version);
  5338   ik->set_major_version(_major_version);
  5369   ik->set_major_version(_major_version);
  5339   ik->set_has_nonstatic_concrete_methods(_has_nonstatic_concrete_methods);
  5370   ik->set_has_nonstatic_concrete_methods(_has_nonstatic_concrete_methods);
  5410   Handle module_handle(THREAD, JNIHandles::resolve(module_entry->module()));
  5441   Handle module_handle(THREAD, JNIHandles::resolve(module_entry->module()));
  5411 
  5442 
  5412   // Allocate mirror and initialize static fields
  5443   // Allocate mirror and initialize static fields
  5413   // The create_mirror() call will also call compute_modifiers()
  5444   // The create_mirror() call will also call compute_modifiers()
  5414   java_lang_Class::create_mirror(ik,
  5445   java_lang_Class::create_mirror(ik,
  5415                                  _loader_data->class_loader(),
  5446                                  Handle(THREAD, _loader_data->class_loader()),
  5416                                  module_handle,
  5447                                  module_handle,
  5417                                  _protection_domain,
  5448                                  _protection_domain,
  5418                                  CHECK);
  5449                                  CHECK);
  5419 
  5450 
  5420   assert(_all_mirandas != NULL, "invariant");
  5451   assert(_all_mirandas != NULL, "invariant");
  5443 
  5474 
  5444   if (!is_internal()) {
  5475   if (!is_internal()) {
  5445     if (log_is_enabled(Info, class, load)) {
  5476     if (log_is_enabled(Info, class, load)) {
  5446       ResourceMark rm;
  5477       ResourceMark rm;
  5447       const char* module_name = (module_entry->name() == NULL) ? UNNAMED_MODULE : module_entry->name()->as_C_string();
  5478       const char* module_name = (module_entry->name() == NULL) ? UNNAMED_MODULE : module_entry->name()->as_C_string();
  5448 
  5479       ik->print_class_load_logging(_loader_data, module_name, _stream);
  5449       if (log_is_enabled(Info, class, load)) {
       
  5450         ik->print_loading_log(LogLevel::Info, _loader_data, module_name, _stream);
       
  5451       }
       
  5452       // No 'else' here as logging levels are not mutually exclusive
       
  5453       if (log_is_enabled(Debug, class, load)) {
       
  5454         ik->print_loading_log(LogLevel::Debug, _loader_data, module_name, _stream);
       
  5455       }
       
  5456     }
  5480     }
  5457 
  5481 
  5458     if (log_is_enabled(Debug, class, resolve))  {
  5482     if (log_is_enabled(Debug, class, resolve))  {
  5459       ResourceMark rm;
  5483       ResourceMark rm;
  5460       // print out the superclass.
  5484       // print out the superclass.
  5565   _stream(stream),
  5589   _stream(stream),
  5566   _requested_name(name),
  5590   _requested_name(name),
  5567   _loader_data(loader_data),
  5591   _loader_data(loader_data),
  5568   _host_klass(host_klass),
  5592   _host_klass(host_klass),
  5569   _cp_patches(cp_patches),
  5593   _cp_patches(cp_patches),
       
  5594   _num_patched_klasses(0),
       
  5595   _max_num_patched_klasses(0),
       
  5596   _orig_cp_size(0),
       
  5597   _first_patched_klass_resolved_index(0),
  5570   _super_klass(),
  5598   _super_klass(),
  5571   _cp(NULL),
  5599   _cp(NULL),
  5572   _fields(NULL),
  5600   _fields(NULL),
  5573   _methods(NULL),
  5601   _methods(NULL),
  5574   _inner_classes(NULL),
  5602   _inner_classes(NULL),
  5635   }
  5663   }
  5636   else {
  5664   else {
  5637     _need_verify = Verifier::should_verify_for(_loader_data->class_loader(),
  5665     _need_verify = Verifier::should_verify_for(_loader_data->class_loader(),
  5638                                                stream->need_verify());
  5666                                                stream->need_verify());
  5639   }
  5667   }
       
  5668   if (_cp_patches != NULL) {
       
  5669     int len = _cp_patches->length();
       
  5670     for (int i=0; i<len; i++) {
       
  5671       if (has_cp_patch_at(i)) {
       
  5672         Handle patch = cp_patch_at(i);
       
  5673         if (java_lang_String::is_instance(patch()) || java_lang_Class::is_instance(patch())) {
       
  5674           // We need to append the names of the patched classes to the end of the constant pool,
       
  5675           // because a patched class may have a Utf8 name that's not already included in the
       
  5676           // original constant pool. These class names are used when patch_constant_pool()
       
  5677           // calls patch_class().
       
  5678           //
       
  5679           // Note that a String in cp_patch_at(i) may be used to patch a Utf8, a String, or a Class.
       
  5680           // At this point, we don't know the tag for index i yet, because we haven't parsed the
       
  5681           // constant pool. So we can only assume the worst -- every String is used to patch a Class.
       
  5682           _max_num_patched_klasses++;
       
  5683         }
       
  5684       }
       
  5685     }
       
  5686   }
  5640 
  5687 
  5641   // synch back verification state to stream
  5688   // synch back verification state to stream
  5642   stream->set_verify(_need_verify);
  5689   stream->set_verify(_need_verify);
  5643 
  5690 
  5644   // Check if verification needs to be relaxed for this class file
  5691   // Check if verification needs to be relaxed for this class file
  5764       JAVA_MAX_SUPPORTED_MINOR_VERSION);
  5811       JAVA_MAX_SUPPORTED_MINOR_VERSION);
  5765     return;
  5812     return;
  5766   }
  5813   }
  5767 
  5814 
  5768   stream->guarantee_more(3, CHECK); // length, first cp tag
  5815   stream->guarantee_more(3, CHECK); // length, first cp tag
  5769   const u2 cp_size = stream->get_u2_fast();
  5816   u2 cp_size = stream->get_u2_fast();
  5770 
  5817 
  5771   guarantee_property(
  5818   guarantee_property(
  5772     cp_size >= 1, "Illegal constant pool size %u in class file %s",
  5819     cp_size >= 1, "Illegal constant pool size %u in class file %s",
  5773     cp_size, CHECK);
  5820     cp_size, CHECK);
  5774 
  5821 
       
  5822   _orig_cp_size = cp_size;
       
  5823   if (int(cp_size) + _max_num_patched_klasses > 0xffff) {
       
  5824     THROW_MSG(vmSymbols::java_lang_InternalError(), "not enough space for patched classes");
       
  5825   }
       
  5826   cp_size += _max_num_patched_klasses;
       
  5827 
  5775   _cp = ConstantPool::allocate(_loader_data,
  5828   _cp = ConstantPool::allocate(_loader_data,
  5776                                cp_size,
  5829                                cp_size,
  5777                                CHECK);
  5830                                CHECK);
  5778 
  5831 
  5779   ConstantPool* const cp = _cp;
  5832   ConstantPool* const cp = _cp;
  5780 
  5833 
  5781   parse_constant_pool(stream, cp, cp_size, CHECK);
  5834   parse_constant_pool(stream, cp, _orig_cp_size, CHECK);
  5782 
  5835 
  5783   assert(cp_size == (const u2)cp->length(), "invariant");
  5836   assert(cp_size == (const u2)cp->length(), "invariant");
  5784 
  5837 
  5785   // ACCESS FLAGS
  5838   // ACCESS FLAGS
  5786   stream->guarantee_more(8, CHECK);  // flags, this_class, super_class, infs_len
  5839   stream->guarantee_more(8, CHECK);  // flags, this_class, super_class, infs_len
  5982       // errors not checked yet.
  6035       // errors not checked yet.
  5983       guarantee_property(super_class_name == vmSymbols::java_lang_Object(),
  6036       guarantee_property(super_class_name == vmSymbols::java_lang_Object(),
  5984         "Interfaces must have java.lang.Object as superclass in class file %s",
  6037         "Interfaces must have java.lang.Object as superclass in class file %s",
  5985         CHECK);
  6038         CHECK);
  5986     }
  6039     }
       
  6040     Handle loader(THREAD, _loader_data->class_loader());
  5987     _super_klass = (const InstanceKlass*)
  6041     _super_klass = (const InstanceKlass*)
  5988                        SystemDictionary::resolve_super_or_fail(_class_name,
  6042                        SystemDictionary::resolve_super_or_fail(_class_name,
  5989                                                                super_class_name,
  6043                                                                super_class_name,
  5990                                                                _loader_data->class_loader(),
  6044                                                                loader,
  5991                                                                _protection_domain,
  6045                                                                _protection_domain,
  5992                                                                true,
  6046                                                                true,
  5993                                                                CHECK);
  6047                                                                CHECK);
  5994   }
  6048   }
  5995 
  6049 
  6027   // sort methods
  6081   // sort methods
  6028   _method_ordering = sort_methods(_methods);
  6082   _method_ordering = sort_methods(_methods);
  6029 
  6083 
  6030   _all_mirandas = new GrowableArray<Method*>(20);
  6084   _all_mirandas = new GrowableArray<Method*>(20);
  6031 
  6085 
       
  6086   Handle loader(THREAD, _loader_data->class_loader());
  6032   klassVtable::compute_vtable_size_and_num_mirandas(&_vtable_size,
  6087   klassVtable::compute_vtable_size_and_num_mirandas(&_vtable_size,
  6033                                                     &_num_miranda_methods,
  6088                                                     &_num_miranda_methods,
  6034                                                     _all_mirandas,
  6089                                                     _all_mirandas,
  6035                                                     _super_klass,
  6090                                                     _super_klass,
  6036                                                     _methods,
  6091                                                     _methods,
  6037                                                     _access_flags,
  6092                                                     _access_flags,
  6038                                                     _major_version,
  6093                                                     _major_version,
  6039                                                     _loader_data->class_loader(),
  6094                                                     loader,
  6040                                                     _class_name,
  6095                                                     _class_name,
  6041                                                     _local_interfaces,
  6096                                                     _local_interfaces,
  6042                                                     CHECK);
  6097                                                     CHECK);
  6043 
  6098 
  6044   // Size of Java itable (in words)
  6099   // Size of Java itable (in words)