src/share/vm/classfile/classFileParser.cpp

changeset 4037
da91efe96a93
parent 3969
1d7922586cf6
child 4047
aed758eda82a
     1.1 --- a/src/share/vm/classfile/classFileParser.cpp	Fri Aug 31 16:39:35 2012 -0700
     1.2 +++ b/src/share/vm/classfile/classFileParser.cpp	Sat Sep 01 13:25:18 2012 -0400
     1.3 @@ -25,6 +25,8 @@
     1.4  #include "precompiled.hpp"
     1.5  #include "classfile/classFileParser.hpp"
     1.6  #include "classfile/classLoader.hpp"
     1.7 +#include "classfile/classLoaderData.hpp"
     1.8 +#include "classfile/classLoaderData.inline.hpp"
     1.9  #include "classfile/javaClasses.hpp"
    1.10  #include "classfile/symbolTable.hpp"
    1.11  #include "classfile/systemDictionary.hpp"
    1.12 @@ -33,17 +35,18 @@
    1.13  #include "classfile/vmSymbols.hpp"
    1.14  #include "memory/allocation.hpp"
    1.15  #include "memory/gcLocker.hpp"
    1.16 +#include "memory/metadataFactory.hpp"
    1.17  #include "memory/oopFactory.hpp"
    1.18  #include "memory/universe.inline.hpp"
    1.19 -#include "oops/constantPoolOop.hpp"
    1.20 +#include "oops/constantPool.hpp"
    1.21  #include "oops/fieldStreams.hpp"
    1.22  #include "oops/instanceKlass.hpp"
    1.23  #include "oops/instanceMirrorKlass.hpp"
    1.24  #include "oops/klass.inline.hpp"
    1.25 -#include "oops/klassOop.hpp"
    1.26  #include "oops/klassVtable.hpp"
    1.27 -#include "oops/methodOop.hpp"
    1.28 +#include "oops/method.hpp"
    1.29  #include "oops/symbol.hpp"
    1.30 +#include "prims/jvm.h"
    1.31  #include "prims/jvmtiExport.hpp"
    1.32  #include "prims/jvmtiThreadState.hpp"
    1.33  #include "runtime/javaCalls.hpp"
    1.34 @@ -53,6 +56,7 @@
    1.35  #include "runtime/timer.hpp"
    1.36  #include "services/classLoadingService.hpp"
    1.37  #include "services/threadService.hpp"
    1.38 +#include "utilities/array.hpp"
    1.39  
    1.40  // We generally try to create the oops directly when parsing, rather than
    1.41  // allocating temporary data structures and copying the bytes twice. A
    1.42 @@ -81,7 +85,7 @@
    1.43  #define JAVA_7_VERSION                    51
    1.44  
    1.45  
    1.46 -void ClassFileParser::parse_constant_pool_entries(Handle class_loader, constantPoolHandle cp, int length, TRAPS) {
    1.47 +void ClassFileParser::parse_constant_pool_entries(ClassLoaderData* loader_data, constantPoolHandle cp, int length, TRAPS) {
    1.48    // Use a local copy of ClassFileStream. It helps the C++ compiler to optimize
    1.49    // this function (_current can be allocated in a register, with scalar
    1.50    // replacement of aggregates). The _current pointer is copied back to
    1.51 @@ -94,6 +98,7 @@
    1.52    assert(cfs->allocated_on_stack(),"should be local");
    1.53    u1* old_current = cfs0->current();
    1.54  #endif
    1.55 +  Handle class_loader(THREAD, loader_data->class_loader());
    1.56  
    1.57    // Used for batching symbol allocations.
    1.58    const char* names[SymbolTable::symbol_alloc_batch_size];
    1.59 @@ -272,7 +277,7 @@
    1.60              indices[names_count] = index;
    1.61              hashValues[names_count++] = hash;
    1.62              if (names_count == SymbolTable::symbol_alloc_batch_size) {
    1.63 -              SymbolTable::new_symbols(class_loader, cp, names_count, names, lengths, indices, hashValues, CHECK);
    1.64 +              SymbolTable::new_symbols(loader_data, cp, names_count, names, lengths, indices, hashValues, CHECK);
    1.65                names_count = 0;
    1.66              }
    1.67            } else {
    1.68 @@ -289,7 +294,7 @@
    1.69  
    1.70    // Allocate the remaining symbols
    1.71    if (names_count > 0) {
    1.72 -    SymbolTable::new_symbols(class_loader, cp, names_count, names, lengths, indices, hashValues, CHECK);
    1.73 +    SymbolTable::new_symbols(loader_data, cp, names_count, names, lengths, indices, hashValues, CHECK);
    1.74    }
    1.75  
    1.76    // Copy _current pointer of local copy back to stream().
    1.77 @@ -325,7 +330,7 @@
    1.78      return NULL;
    1.79  }
    1.80  
    1.81 -constantPoolHandle ClassFileParser::parse_constant_pool(Handle class_loader, TRAPS) {
    1.82 +constantPoolHandle ClassFileParser::parse_constant_pool(ClassLoaderData* loader_data, TRAPS) {
    1.83    ClassFileStream* cfs = stream();
    1.84    constantPoolHandle nullHandle;
    1.85  
    1.86 @@ -334,17 +339,16 @@
    1.87    guarantee_property(
    1.88      length >= 1, "Illegal constant pool size %u in class file %s",
    1.89      length, CHECK_(nullHandle));
    1.90 -  constantPoolOop constant_pool =
    1.91 -                      oopFactory::new_constantPool(length,
    1.92 -                                                   oopDesc::IsSafeConc,
    1.93 +  ConstantPool* constant_pool =
    1.94 +                      ConstantPool::allocate(loader_data,
    1.95 +                                                    length,
    1.96                                                     CHECK_(nullHandle));
    1.97    constantPoolHandle cp (THREAD, constant_pool);
    1.98  
    1.99 -  cp->set_partially_loaded();    // Enables heap verify to work on partial constantPoolOops
   1.100    ConstantPoolCleaner cp_in_error(cp); // set constant pool to be cleaned up.
   1.101  
   1.102    // parsing constant pool entries
   1.103 -  parse_constant_pool_entries(class_loader, cp, length, CHECK_(nullHandle));
   1.104 +  parse_constant_pool_entries(loader_data, cp, length, CHECK_(nullHandle));
   1.105  
   1.106    int index = 1;  // declared outside of loops for portability
   1.107  
   1.108 @@ -423,9 +427,6 @@
   1.109            cp->unresolved_klass_at_put(index, cp->symbol_at(class_index));
   1.110          }
   1.111          break;
   1.112 -      case JVM_CONSTANT_UnresolvedString :
   1.113 -        ShouldNotReachHere();     // Only JVM_CONSTANT_StringIndex should be present
   1.114 -        break;
   1.115        case JVM_CONSTANT_StringIndex :
   1.116          {
   1.117            int string_index = cp->string_index_at(index);
   1.118 @@ -531,12 +532,6 @@
   1.119          patch_constant_pool(cp, index, cp_patch_at(index), CHECK_(nullHandle));
   1.120        }
   1.121      }
   1.122 -    // Ensure that all the patches have been used.
   1.123 -    for (index = 0; index < _cp_patches->length(); index++) {
   1.124 -      guarantee_property(!has_cp_patch_at(index),
   1.125 -                         "Unused constant pool patch at %d in class file %s",
   1.126 -                         index, CHECK_(nullHandle));
   1.127 -    }
   1.128    }
   1.129  
   1.130    if (!_need_verify) {
   1.131 @@ -671,6 +666,7 @@
   1.132  void ClassFileParser::patch_constant_pool(constantPoolHandle cp, int index, Handle patch, TRAPS) {
   1.133    assert(EnableInvokeDynamic, "");
   1.134    BasicType patch_type = T_VOID;
   1.135 +
   1.136    switch (cp->tag_at(index).value()) {
   1.137  
   1.138    case JVM_CONSTANT_UnresolvedClass :
   1.139 @@ -680,7 +676,7 @@
   1.140        guarantee_property(!java_lang_Class::is_primitive(patch()),
   1.141                           "Illegal class patch at %d in class file %s",
   1.142                           index, CHECK);
   1.143 -      cp->klass_at_put(index, java_lang_Class::as_klassOop(patch()));
   1.144 +      cp->klass_at_put(index, java_lang_Class::as_Klass(patch()));
   1.145      } else {
   1.146        guarantee_property(java_lang_String::is_instance(patch()),
   1.147                           "Illegal class patch at %d in class file %s",
   1.148 @@ -690,15 +686,10 @@
   1.149      }
   1.150      break;
   1.151  
   1.152 -  case JVM_CONSTANT_UnresolvedString :
   1.153 -    // Patching a string means pre-resolving it.
   1.154 -    // The spelling in the constant pool is ignored.
   1.155 -    // The constant reference may be any object whatever.
   1.156 -    // If it is not a real interned string, the constant is referred
   1.157 -    // to as a "pseudo-string", and must be presented to the CP
   1.158 -    // explicitly, because it may require scavenging.
   1.159 -    cp->pseudo_string_at_put(index, patch());
   1.160 -    break;
   1.161 +  case JVM_CONSTANT_String :
   1.162 +    // skip this patch and don't clear it.  Needs the oop array for resolved
   1.163 +    // references to be created first.
   1.164 +    return;
   1.165  
   1.166    case JVM_CONSTANT_Integer : patch_type = T_INT;    goto patch_prim;
   1.167    case JVM_CONSTANT_Float :   patch_type = T_FLOAT;  goto patch_prim;
   1.168 @@ -789,27 +780,26 @@
   1.169  }
   1.170  
   1.171  
   1.172 -objArrayHandle ClassFileParser::parse_interfaces(constantPoolHandle cp,
   1.173 +Array<Klass*>* ClassFileParser::parse_interfaces(constantPoolHandle cp,
   1.174                                                   int length,
   1.175 -                                                 Handle class_loader,
   1.176 +                                                   ClassLoaderData* loader_data,
   1.177                                                   Handle protection_domain,
   1.178                                                   Symbol* class_name,
   1.179                                                   TRAPS) {
   1.180    ClassFileStream* cfs = stream();
   1.181    assert(length > 0, "only called for length>0");
   1.182 -  objArrayHandle nullHandle;
   1.183 -  objArrayOop interface_oop = oopFactory::new_system_objArray(length, CHECK_(nullHandle));
   1.184 -  objArrayHandle interfaces (THREAD, interface_oop);
   1.185 +  // FIXME: Leak at later OOM.
   1.186 +  Array<Klass*>* interfaces = MetadataFactory::new_array<Klass*>(loader_data, length, NULL, CHECK_NULL);
   1.187  
   1.188    int index;
   1.189    for (index = 0; index < length; index++) {
   1.190 -    u2 interface_index = cfs->get_u2(CHECK_(nullHandle));
   1.191 +    u2 interface_index = cfs->get_u2(CHECK_NULL);
   1.192      KlassHandle interf;
   1.193      check_property(
   1.194        valid_cp_range(interface_index, cp->length()) &&
   1.195        is_klass_reference(cp, interface_index),
   1.196        "Interface name has bad constant pool index %u in class file %s",
   1.197 -      interface_index, CHECK_(nullHandle));
   1.198 +      interface_index, CHECK_NULL);
   1.199      if (cp->tag_at(interface_index).is_klass()) {
   1.200        interf = KlassHandle(THREAD, cp->resolved_klass_at(interface_index));
   1.201      } else {
   1.202 @@ -818,12 +808,13 @@
   1.203        // Don't need to check legal name because it's checked when parsing constant pool.
   1.204        // But need to make sure it's not an array type.
   1.205        guarantee_property(unresolved_klass->byte_at(0) != JVM_SIGNATURE_ARRAY,
   1.206 -                         "Bad interface name in class file %s", CHECK_(nullHandle));
   1.207 +                         "Bad interface name in class file %s", CHECK_NULL);
   1.208 +      Handle class_loader(THREAD, loader_data->class_loader());
   1.209  
   1.210        // Call resolve_super so classcircularity is checked
   1.211 -      klassOop k = SystemDictionary::resolve_super_or_fail(class_name,
   1.212 +      Klass* k = SystemDictionary::resolve_super_or_fail(class_name,
   1.213                      unresolved_klass, class_loader, protection_domain,
   1.214 -                    false, CHECK_(nullHandle));
   1.215 +                    false, CHECK_NULL);
   1.216        interf = KlassHandle(THREAD, k);
   1.217  
   1.218        if (LinkWellKnownClasses)  // my super type is well known to me
   1.219 @@ -831,9 +822,9 @@
   1.220      }
   1.221  
   1.222      if (!Klass::cast(interf())->is_interface()) {
   1.223 -      THROW_MSG_(vmSymbols::java_lang_IncompatibleClassChangeError(), "Implementing class", nullHandle);
   1.224 +      THROW_MSG_(vmSymbols::java_lang_IncompatibleClassChangeError(), "Implementing class", NULL);
   1.225      }
   1.226 -    interfaces->obj_at_put(index, interf());
   1.227 +    interfaces->at_put(index, interf());
   1.228    }
   1.229  
   1.230    if (!_need_verify || length <= 1) {
   1.231 @@ -849,8 +840,8 @@
   1.232    {
   1.233      debug_only(No_Safepoint_Verifier nsv;)
   1.234      for (index = 0; index < length; index++) {
   1.235 -      klassOop k = (klassOop)interfaces->obj_at(index);
   1.236 -      Symbol* name = instanceKlass::cast(k)->name();
   1.237 +      Klass* k = interfaces->at(index);
   1.238 +      Symbol* name = InstanceKlass::cast(k)->name();
   1.239        // If no duplicates, add (name, NULL) in hashtable interface_names.
   1.240        if (!put_after_lookup(name, NULL, interface_names)) {
   1.241          dup = true;
   1.242 @@ -859,8 +850,7 @@
   1.243      }
   1.244    }
   1.245    if (dup) {
   1.246 -    classfile_parse_error("Duplicate interface name in class file %s",
   1.247 -                          CHECK_(nullHandle));
   1.248 +    classfile_parse_error("Duplicate interface name in class file %s", CHECK_NULL);
   1.249    }
   1.250  
   1.251    return interfaces;
   1.252 @@ -890,7 +880,7 @@
   1.253        break;
   1.254      case T_OBJECT:
   1.255        guarantee_property((cp->symbol_at(signature_index)->equals("Ljava/lang/String;")
   1.256 -                         && (value_type.is_string() || value_type.is_unresolved_string())),
   1.257 +                         && value_type.is_string()),
   1.258                           "Bad string initial value in class file %s", CHECK);
   1.259        break;
   1.260      default:
   1.261 @@ -902,13 +892,14 @@
   1.262  
   1.263  
   1.264  // Parse attributes for a field.
   1.265 -void ClassFileParser::parse_field_attributes(constantPoolHandle cp,
   1.266 +void ClassFileParser::parse_field_attributes(ClassLoaderData* loader_data,
   1.267 +                                             constantPoolHandle cp,
   1.268                                               u2 attributes_count,
   1.269                                               bool is_static, u2 signature_index,
   1.270                                               u2* constantvalue_index_addr,
   1.271                                               bool* is_synthetic_addr,
   1.272                                               u2* generic_signature_index_addr,
   1.273 -                                             typeArrayHandle* field_annotations,
   1.274 +                                             AnnotationArray** field_annotations,
   1.275                                               ClassFileParser::FieldAnnotationCollector* parsed_annotations,
   1.276                                               TRAPS) {
   1.277    ClassFileStream* cfs = stream();
   1.278 @@ -985,7 +976,8 @@
   1.279    *constantvalue_index_addr = constantvalue_index;
   1.280    *is_synthetic_addr = is_synthetic;
   1.281    *generic_signature_index_addr = generic_signature_index;
   1.282 -  *field_annotations = assemble_annotations(runtime_visible_annotations,
   1.283 +  *field_annotations = assemble_annotations(loader_data,
   1.284 +                                            runtime_visible_annotations,
   1.285                                              runtime_visible_annotations_length,
   1.286                                              runtime_invisible_annotations,
   1.287                                              runtime_invisible_annotations_length,
   1.288 @@ -1029,7 +1021,8 @@
   1.289    BAD_ALLOCATION_TYPE, // T_VOID     = 14,
   1.290    BAD_ALLOCATION_TYPE, // T_ADDRESS  = 15,
   1.291    BAD_ALLOCATION_TYPE, // T_NARROWOOP= 16,
   1.292 -  BAD_ALLOCATION_TYPE, // T_CONFLICT = 17,
   1.293 +  BAD_ALLOCATION_TYPE, // T_METADATA = 17,
   1.294 +  BAD_ALLOCATION_TYPE, // T_CONFLICT = 18,
   1.295    BAD_ALLOCATION_TYPE, // 0
   1.296    BAD_ALLOCATION_TYPE, // 1
   1.297    BAD_ALLOCATION_TYPE, // 2
   1.298 @@ -1047,7 +1040,8 @@
   1.299    BAD_ALLOCATION_TYPE, // T_VOID     = 14,
   1.300    BAD_ALLOCATION_TYPE, // T_ADDRESS  = 15,
   1.301    BAD_ALLOCATION_TYPE, // T_NARROWOOP= 16,
   1.302 -  BAD_ALLOCATION_TYPE, // T_CONFLICT = 17,
   1.303 +  BAD_ALLOCATION_TYPE, // T_METADATA = 17,
   1.304 +  BAD_ALLOCATION_TYPE, // T_CONFLICT = 18,
   1.305  };
   1.306  
   1.307  static FieldAllocationType basic_type_to_atype(bool is_static, BasicType type) {
   1.308 @@ -1076,15 +1070,14 @@
   1.309    }
   1.310  };
   1.311  
   1.312 -
   1.313 -typeArrayHandle ClassFileParser::parse_fields(Symbol* class_name,
   1.314 +Array<u2>* ClassFileParser::parse_fields(ClassLoaderData* loader_data,
   1.315 +                                         Symbol* class_name,
   1.316                                                constantPoolHandle cp, bool is_interface,
   1.317                                                FieldAllocationCount *fac,
   1.318 -                                              objArrayHandle* fields_annotations,
   1.319 +                                         Array<AnnotationArray*>** fields_annotations,
   1.320                                                u2* java_fields_count_ptr, TRAPS) {
   1.321    ClassFileStream* cfs = stream();
   1.322 -  typeArrayHandle nullHandle;
   1.323 -  cfs->guarantee_more(2, CHECK_(nullHandle));  // length
   1.324 +  cfs->guarantee_more(2, CHECK_NULL);  // length
   1.325    u2 length = cfs->get_u2_fast();
   1.326    *java_fields_count_ptr = length;
   1.327  
   1.328 @@ -1116,16 +1109,16 @@
   1.329    u2* fa = NEW_RESOURCE_ARRAY_IN_THREAD(
   1.330               THREAD, u2, total_fields * (FieldInfo::field_slots + 1));
   1.331  
   1.332 -  typeArrayHandle field_annotations;
   1.333 +  AnnotationArray* field_annotations = NULL;
   1.334    // The generic signature slots start after all other fields' data.
   1.335    int generic_signature_slot = total_fields * FieldInfo::field_slots;
   1.336    int num_generic_signature = 0;
   1.337    for (int n = 0; n < length; n++) {
   1.338 -    cfs->guarantee_more(8, CHECK_(nullHandle));  // access_flags, name_index, descriptor_index, attributes_count
   1.339 +    cfs->guarantee_more(8, CHECK_NULL);  // access_flags, name_index, descriptor_index, attributes_count
   1.340  
   1.341      AccessFlags access_flags;
   1.342      jint flags = cfs->get_u2_fast() & JVM_RECOGNIZED_FIELD_MODIFIERS;
   1.343 -    verify_legal_field_modifiers(flags, is_interface, CHECK_(nullHandle));
   1.344 +    verify_legal_field_modifiers(flags, is_interface, CHECK_NULL);
   1.345      access_flags.set_flags(flags);
   1.346  
   1.347      u2 name_index = cfs->get_u2_fast();
   1.348 @@ -1133,18 +1126,18 @@
   1.349      check_property(
   1.350        valid_cp_range(name_index, cp_size) && cp->tag_at(name_index).is_utf8(),
   1.351        "Invalid constant pool index %u for field name in class file %s",
   1.352 -      name_index, CHECK_(nullHandle));
   1.353 +      name_index, CHECK_NULL);
   1.354      Symbol*  name = cp->symbol_at(name_index);
   1.355 -    verify_legal_field_name(name, CHECK_(nullHandle));
   1.356 +    verify_legal_field_name(name, CHECK_NULL);
   1.357  
   1.358      u2 signature_index = cfs->get_u2_fast();
   1.359      check_property(
   1.360        valid_cp_range(signature_index, cp_size) &&
   1.361          cp->tag_at(signature_index).is_utf8(),
   1.362        "Invalid constant pool index %u for field signature in class file %s",
   1.363 -      signature_index, CHECK_(nullHandle));
   1.364 +      signature_index, CHECK_NULL);
   1.365      Symbol*  sig = cp->symbol_at(signature_index);
   1.366 -    verify_legal_field_signature(name, sig, CHECK_(nullHandle));
   1.367 +    verify_legal_field_signature(name, sig, CHECK_NULL);
   1.368  
   1.369      u2 constantvalue_index = 0;
   1.370      bool is_synthetic = false;
   1.371 @@ -1154,17 +1147,19 @@
   1.372  
   1.373      u2 attributes_count = cfs->get_u2_fast();
   1.374      if (attributes_count > 0) {
   1.375 -      parse_field_attributes(cp, attributes_count, is_static, signature_index,
   1.376 +      parse_field_attributes(loader_data,
   1.377 +                             cp, attributes_count, is_static, signature_index,
   1.378                               &constantvalue_index, &is_synthetic,
   1.379                               &generic_signature_index, &field_annotations,
   1.380                               &parsed_annotations,
   1.381 -                             CHECK_(nullHandle));
   1.382 -      if (field_annotations.not_null()) {
   1.383 -        if (fields_annotations->is_null()) {
   1.384 -          objArrayOop md = oopFactory::new_system_objArray(length, CHECK_(nullHandle));
   1.385 -          *fields_annotations = objArrayHandle(THREAD, md);
   1.386 +                             CHECK_NULL);
   1.387 +      if (field_annotations != NULL) {
   1.388 +        if (*fields_annotations == NULL) {
   1.389 +          *fields_annotations = MetadataFactory::new_array<AnnotationArray*>(
   1.390 +                                             loader_data, length, NULL,
   1.391 +                                             CHECK_NULL);
   1.392          }
   1.393 -        (*fields_annotations)->obj_at_put(n, field_annotations());
   1.394 +        (*fields_annotations)->at_put(n, field_annotations);
   1.395        }
   1.396        if (is_synthetic) {
   1.397          access_flags.set_is_synthetic();
   1.398 @@ -1244,20 +1239,19 @@
   1.399    // the fields array could be too long.  In that case the
   1.400    // fields array is trimed. Also unused slots that were reserved
   1.401    // for generic signature indexes are discarded.
   1.402 -  typeArrayOop new_fields = oopFactory::new_permanent_shortArray(
   1.403 -    index * FieldInfo::field_slots + num_generic_signature,
   1.404 -    CHECK_(nullHandle));
   1.405 -  typeArrayHandle fields(THREAD, new_fields);
   1.406 +  Array<u2>* fields = MetadataFactory::new_array<u2>(
   1.407 +          loader_data, index * FieldInfo::field_slots + num_generic_signature,
   1.408 +          CHECK_NULL);
   1.409    {
   1.410      int i = 0;
   1.411      for (; i < index * FieldInfo::field_slots; i++) {
   1.412 -      new_fields->short_at_put(i, fa[i]);
   1.413 +      fields->at_put(i, fa[i]);
   1.414      }
   1.415      for (int j = total_fields * FieldInfo::field_slots;
   1.416           j < generic_signature_slot; j++) {
   1.417 -      new_fields->short_at_put(i++, fa[j]);
   1.418 +      fields->at_put(i++, fa[j]);
   1.419      }
   1.420 -    assert(i == new_fields->length(), "");
   1.421 +    assert(i == fields->length(), "");
   1.422    }
   1.423  
   1.424    if (_need_verify && length > 1) {
   1.425 @@ -1281,7 +1275,7 @@
   1.426      }
   1.427      if (dup) {
   1.428        classfile_parse_error("Duplicate field name&signature in class file %s",
   1.429 -                            CHECK_(nullHandle));
   1.430 +                            CHECK_NULL);
   1.431      }
   1.432    }
   1.433  
   1.434 @@ -1296,7 +1290,8 @@
   1.435  }
   1.436  
   1.437  
   1.438 -u2* ClassFileParser::parse_exception_table(u4 code_length,
   1.439 +u2* ClassFileParser::parse_exception_table(ClassLoaderData* loader_data,
   1.440 +                                           u4 code_length,
   1.441                                             u4 exception_table_length,
   1.442                                             constantPoolHandle cp,
   1.443                                             TRAPS) {
   1.444 @@ -1578,7 +1573,8 @@
   1.445    *u2_index = i2;
   1.446  }
   1.447  
   1.448 -typeArrayOop ClassFileParser::parse_stackmap_table(
   1.449 +Array<u1>* ClassFileParser::parse_stackmap_table(
   1.450 +    ClassLoaderData* loader_data,
   1.451      u4 code_attribute_length, TRAPS) {
   1.452    if (code_attribute_length == 0)
   1.453      return NULL;
   1.454 @@ -1594,11 +1590,10 @@
   1.455      return NULL;
   1.456    }
   1.457  
   1.458 -  typeArrayOop stackmap_data =
   1.459 -    oopFactory::new_permanent_byteArray(code_attribute_length, CHECK_NULL);
   1.460 -
   1.461 -  stackmap_data->set_length(code_attribute_length);
   1.462 -  memcpy((void*)stackmap_data->byte_at_addr(0),
   1.463 +  Array<u1>* stackmap_data =
   1.464 +    MetadataFactory::new_array<u1>(loader_data, code_attribute_length, 0, CHECK_NULL);
   1.465 +
   1.466 +  memcpy((void*)stackmap_data->adr_at(0),
   1.467           (void*)stackmap_table_start, code_attribute_length);
   1.468    return stackmap_data;
   1.469  }
   1.470 @@ -1813,18 +1808,20 @@
   1.471  
   1.472  // Note: the parse_method below is big and clunky because all parsing of the code and exceptions
   1.473  // attribute is inlined. This is cumbersome to avoid since we inline most of the parts in the
   1.474 -// methodOop to save footprint, so we only know the size of the resulting methodOop when the
   1.475 +// Method* to save footprint, so we only know the size of the resulting Method* when the
   1.476  // entire method attribute is parsed.
   1.477  //
   1.478  // The promoted_flags parameter is used to pass relevant access_flags
   1.479  // from the method back up to the containing klass. These flag values
   1.480  // are added to klass's access_flags.
   1.481  
   1.482 -methodHandle ClassFileParser::parse_method(constantPoolHandle cp, bool is_interface,
   1.483 +methodHandle ClassFileParser::parse_method(ClassLoaderData* loader_data,
   1.484 +                                           constantPoolHandle cp,
   1.485 +                                           bool is_interface,
   1.486                                             AccessFlags *promoted_flags,
   1.487 -                                           typeArrayHandle* method_annotations,
   1.488 -                                           typeArrayHandle* method_parameter_annotations,
   1.489 -                                           typeArrayHandle* method_default_annotations,
   1.490 +                                           AnnotationArray** method_annotations,
   1.491 +                                           AnnotationArray** method_parameter_annotations,
   1.492 +                                           AnnotationArray** method_default_annotations,
   1.493                                             TRAPS) {
   1.494    ClassFileStream* cfs = stream();
   1.495    methodHandle nullHandle;
   1.496 @@ -1882,7 +1879,7 @@
   1.497    u1* code_start = 0;
   1.498    u2 exception_table_length = 0;
   1.499    u2* exception_table_start = NULL;
   1.500 -  typeArrayHandle exception_handlers(THREAD, Universe::the_empty_int_array());
   1.501 +  Array<int>* exception_handlers = Universe::the_empty_int_array();
   1.502    u2 checked_exceptions_length = 0;
   1.503    u2* checked_exceptions_start = NULL;
   1.504    CompressedLineNumberWriteStream* linenumber_table = NULL;
   1.505 @@ -1901,7 +1898,7 @@
   1.506    bool parsed_checked_exceptions_attribute = false;
   1.507    bool parsed_stackmap_attribute = false;
   1.508    // stackmap attribute - JDK1.5
   1.509 -  typeArrayHandle stackmap_data;
   1.510 +  Array<u1>* stackmap_data = NULL;
   1.511    u2 generic_signature_index = 0;
   1.512    MethodAnnotationCollector parsed_annotations;
   1.513    u1* runtime_visible_annotations = NULL;
   1.514 @@ -1970,7 +1967,7 @@
   1.515        exception_table_length = cfs->get_u2_fast();
   1.516        if (exception_table_length > 0) {
   1.517          exception_table_start =
   1.518 -              parse_exception_table(code_length, exception_table_length, cp, CHECK_(nullHandle));
   1.519 +              parse_exception_table(loader_data, code_length, exception_table_length, cp, CHECK_(nullHandle));
   1.520        }
   1.521  
   1.522        // Parse additional attributes in code attribute
   1.523 @@ -2079,9 +2076,7 @@
   1.524            if (parsed_stackmap_attribute) {
   1.525              classfile_parse_error("Multiple StackMapTable attributes in class file %s", CHECK_(nullHandle));
   1.526            }
   1.527 -          typeArrayOop sm =
   1.528 -            parse_stackmap_table(code_attribute_length, CHECK_(nullHandle));
   1.529 -          stackmap_data = typeArrayHandle(THREAD, sm);
   1.530 +          stackmap_data = parse_stackmap_table(loader_data, code_attribute_length, CHECK_(nullHandle));
   1.531            parsed_stackmap_attribute = true;
   1.532          } else {
   1.533            // Skip unknown attributes
   1.534 @@ -2173,17 +2168,17 @@
   1.535                        "Absent Code attribute in method that is not native or abstract in class file %s", CHECK_(nullHandle));
   1.536    }
   1.537  
   1.538 -  // All sizing information for a methodOop is finally available, now create it
   1.539 -  methodOop m_oop  = oopFactory::new_method(code_length, access_flags,
   1.540 +  // All sizing information for a Method* is finally available, now create it
   1.541 +  Method* m = Method::allocate(loader_data,
   1.542 +                                        code_length,
   1.543 +                                        access_flags,
   1.544                                              linenumber_table_length,
   1.545                                              total_lvt_length,
   1.546                                              exception_table_length,
   1.547                                              checked_exceptions_length,
   1.548 -                                            oopDesc::IsSafeConc,
   1.549                                              CHECK_(nullHandle));
   1.550 -  methodHandle m (THREAD, m_oop);
   1.551 -
   1.552 -  ClassLoadingService::add_class_method_size(m_oop->size()*HeapWordSize);
   1.553 +
   1.554 +  ClassLoadingService::add_class_method_size(m->size()*HeapWordSize);
   1.555  
   1.556    // Fill in information from fixed part (access_flags already set)
   1.557    m->set_constants(cp());
   1.558 @@ -2212,14 +2207,7 @@
   1.559    m->set_max_stack(max_stack);
   1.560    m->set_max_locals(max_locals);
   1.561  
   1.562 -  /**
   1.563 -   * The stackmap_data field is the flag used to indicate
   1.564 -   * that the methodOop and it's associated constMethodOop are partially
   1.565 -   * initialized and thus are exempt from pre/post GC verification.  Once
   1.566 -   * the field is set, the oops are considered fully initialized so make
   1.567 -   * sure that the oops can pass verification when this field is set.
   1.568 -   */
   1.569 -  m->constMethod()->set_stackmap_data(stackmap_data());
   1.570 +  m->constMethod()->set_stackmap_data(stackmap_data);
   1.571  
   1.572    // Copy byte codes
   1.573    m->set_code(code_start);
   1.574 @@ -2321,17 +2309,20 @@
   1.575  
   1.576    if (parsed_annotations.has_any_annotations())
   1.577      parsed_annotations.apply_to(m);
   1.578 -  *method_annotations = assemble_annotations(runtime_visible_annotations,
   1.579 +  *method_annotations = assemble_annotations(loader_data,
   1.580 +                                             runtime_visible_annotations,
   1.581                                               runtime_visible_annotations_length,
   1.582                                               runtime_invisible_annotations,
   1.583                                               runtime_invisible_annotations_length,
   1.584                                               CHECK_(nullHandle));
   1.585 -  *method_parameter_annotations = assemble_annotations(runtime_visible_parameter_annotations,
   1.586 +  *method_parameter_annotations = assemble_annotations(loader_data,
   1.587 +                                                       runtime_visible_parameter_annotations,
   1.588                                                         runtime_visible_parameter_annotations_length,
   1.589                                                         runtime_invisible_parameter_annotations,
   1.590                                                         runtime_invisible_parameter_annotations_length,
   1.591                                                         CHECK_(nullHandle));
   1.592 -  *method_default_annotations = assemble_annotations(annotation_default,
   1.593 +  *method_default_annotations = assemble_annotations(loader_data,
   1.594 +                                                     annotation_default,
   1.595                                                       annotation_default_length,
   1.596                                                       NULL,
   1.597                                                       0,
   1.598 @@ -2359,61 +2350,56 @@
   1.599  // from the methods back up to the containing klass. These flag values
   1.600  // are added to klass's access_flags.
   1.601  
   1.602 -objArrayHandle ClassFileParser::parse_methods(constantPoolHandle cp, bool is_interface,
   1.603 +Array<Method*>* ClassFileParser::parse_methods(ClassLoaderData* loader_data,
   1.604 +                                                 constantPoolHandle cp,
   1.605 +                                                 bool is_interface,
   1.606                                                AccessFlags* promoted_flags,
   1.607                                                bool* has_final_method,
   1.608 -                                              objArrayOop* methods_annotations_oop,
   1.609 -                                              objArrayOop* methods_parameter_annotations_oop,
   1.610 -                                              objArrayOop* methods_default_annotations_oop,
   1.611 +                                                 Array<AnnotationArray*>** methods_annotations,
   1.612 +                                                 Array<AnnotationArray*>** methods_parameter_annotations,
   1.613 +                                                 Array<AnnotationArray*>** methods_default_annotations,
   1.614                                                TRAPS) {
   1.615    ClassFileStream* cfs = stream();
   1.616 -  objArrayHandle nullHandle;
   1.617 -  typeArrayHandle method_annotations;
   1.618 -  typeArrayHandle method_parameter_annotations;
   1.619 -  typeArrayHandle method_default_annotations;
   1.620 -  cfs->guarantee_more(2, CHECK_(nullHandle));  // length
   1.621 +  AnnotationArray* method_annotations = NULL;
   1.622 +  AnnotationArray* method_parameter_annotations = NULL;
   1.623 +  AnnotationArray* method_default_annotations = NULL;
   1.624 +  cfs->guarantee_more(2, CHECK_NULL);  // length
   1.625    u2 length = cfs->get_u2_fast();
   1.626    if (length == 0) {
   1.627 -    return objArrayHandle(THREAD, Universe::the_empty_system_obj_array());
   1.628 +    return Universe::the_empty_method_array();
   1.629    } else {
   1.630 -    objArrayOop m = oopFactory::new_system_objArray(length, CHECK_(nullHandle));
   1.631 -    objArrayHandle methods(THREAD, m);
   1.632 +    // FIXME: Handle leaks at later failures.
   1.633 +    Array<Method*>* methods = MetadataFactory::new_array<Method*>(loader_data, length, NULL, CHECK_NULL);
   1.634 +
   1.635      HandleMark hm(THREAD);
   1.636 -    objArrayHandle methods_annotations;
   1.637 -    objArrayHandle methods_parameter_annotations;
   1.638 -    objArrayHandle methods_default_annotations;
   1.639      for (int index = 0; index < length; index++) {
   1.640 -      methodHandle method = parse_method(cp, is_interface,
   1.641 +      methodHandle method = parse_method(loader_data,
   1.642 +                                         cp, is_interface,
   1.643                                           promoted_flags,
   1.644                                           &method_annotations,
   1.645                                           &method_parameter_annotations,
   1.646                                           &method_default_annotations,
   1.647 -                                         CHECK_(nullHandle));
   1.648 +                                         CHECK_NULL);
   1.649 +
   1.650        if (method->is_final()) {
   1.651          *has_final_method = true;
   1.652        }
   1.653 -      methods->obj_at_put(index, method());
   1.654 -      if (method_annotations.not_null()) {
   1.655 -        if (methods_annotations.is_null()) {
   1.656 -          objArrayOop md = oopFactory::new_system_objArray(length, CHECK_(nullHandle));
   1.657 -          methods_annotations = objArrayHandle(THREAD, md);
   1.658 -        }
   1.659 -        methods_annotations->obj_at_put(index, method_annotations());
   1.660 +      methods->at_put(index, method());
   1.661 +      if (*methods_annotations == NULL) {
   1.662 +        *methods_annotations =
   1.663 +             MetadataFactory::new_array<AnnotationArray*>(loader_data, length, NULL, CHECK_NULL);
   1.664        }
   1.665 -      if (method_parameter_annotations.not_null()) {
   1.666 -        if (methods_parameter_annotations.is_null()) {
   1.667 -          objArrayOop md = oopFactory::new_system_objArray(length, CHECK_(nullHandle));
   1.668 -          methods_parameter_annotations = objArrayHandle(THREAD, md);
   1.669 -        }
   1.670 -        methods_parameter_annotations->obj_at_put(index, method_parameter_annotations());
   1.671 +      (*methods_annotations)->at_put(index, method_annotations);
   1.672 +      if (*methods_parameter_annotations == NULL) {
   1.673 +        *methods_parameter_annotations =
   1.674 +            MetadataFactory::new_array<AnnotationArray*>(loader_data, length, NULL, CHECK_NULL);
   1.675        }
   1.676 -      if (method_default_annotations.not_null()) {
   1.677 -        if (methods_default_annotations.is_null()) {
   1.678 -          objArrayOop md = oopFactory::new_system_objArray(length, CHECK_(nullHandle));
   1.679 -          methods_default_annotations = objArrayHandle(THREAD, md);
   1.680 -        }
   1.681 -        methods_default_annotations->obj_at_put(index, method_default_annotations());
   1.682 +      (*methods_parameter_annotations)->at_put(index, method_parameter_annotations);
   1.683 +      if (*methods_default_annotations == NULL) {
   1.684 +        *methods_default_annotations =
   1.685 +            MetadataFactory::new_array<AnnotationArray*>(loader_data, length, NULL, CHECK_NULL);
   1.686        }
   1.687 +      (*methods_default_annotations)->at_put(index, method_default_annotations);
   1.688      }
   1.689      if (_need_verify && length > 1) {
   1.690        // Check duplicated methods
   1.691 @@ -2425,7 +2411,7 @@
   1.692        {
   1.693          debug_only(No_Safepoint_Verifier nsv;)
   1.694          for (int i = 0; i < length; i++) {
   1.695 -          methodOop m = (methodOop)methods->obj_at(i);
   1.696 +          Method* m = methods->at(i);
   1.697            // If no duplicates, add name/signature in hashtable names_and_sigs.
   1.698            if (!put_after_lookup(m->name(), m->signature(), names_and_sigs)) {
   1.699              dup = true;
   1.700 @@ -2435,60 +2421,54 @@
   1.701        }
   1.702        if (dup) {
   1.703          classfile_parse_error("Duplicate method name&signature in class file %s",
   1.704 -                              CHECK_(nullHandle));
   1.705 +                              CHECK_NULL);
   1.706        }
   1.707      }
   1.708 -
   1.709 -    *methods_annotations_oop = methods_annotations();
   1.710 -    *methods_parameter_annotations_oop = methods_parameter_annotations();
   1.711 -    *methods_default_annotations_oop = methods_default_annotations();
   1.712 -
   1.713      return methods;
   1.714    }
   1.715  }
   1.716  
   1.717  
   1.718 -typeArrayHandle ClassFileParser::sort_methods(objArrayHandle methods,
   1.719 -                                              objArrayHandle methods_annotations,
   1.720 -                                              objArrayHandle methods_parameter_annotations,
   1.721 -                                              objArrayHandle methods_default_annotations,
   1.722 +Array<int>* ClassFileParser::sort_methods(ClassLoaderData* loader_data,
   1.723 +                                          Array<Method*>* methods,
   1.724 +                                          Array<AnnotationArray*>* methods_annotations,
   1.725 +                                          Array<AnnotationArray*>* methods_parameter_annotations,
   1.726 +                                          Array<AnnotationArray*>* methods_default_annotations,
   1.727                                                TRAPS) {
   1.728 -  typeArrayHandle nullHandle;
   1.729 -  int length = methods()->length();
   1.730 +  int length = methods->length();
   1.731    // If JVMTI original method ordering or sharing is enabled we have to
   1.732    // remember the original class file ordering.
   1.733 -  // We temporarily use the vtable_index field in the methodOop to store the
   1.734 +  // We temporarily use the vtable_index field in the Method* to store the
   1.735    // class file index, so we can read in after calling qsort.
   1.736    // Put the method ordering in the shared archive.
   1.737    if (JvmtiExport::can_maintain_original_method_order() || DumpSharedSpaces) {
   1.738      for (int index = 0; index < length; index++) {
   1.739 -      methodOop m = methodOop(methods->obj_at(index));
   1.740 +      Method* m = methods->at(index);
   1.741        assert(!m->valid_vtable_index(), "vtable index should not be set");
   1.742        m->set_vtable_index(index);
   1.743      }
   1.744    }
   1.745    // Sort method array by ascending method name (for faster lookups & vtable construction)
   1.746    // Note that the ordering is not alphabetical, see Symbol::fast_compare
   1.747 -  methodOopDesc::sort_methods(methods(),
   1.748 -                              methods_annotations(),
   1.749 -                              methods_parameter_annotations(),
   1.750 -                              methods_default_annotations());
   1.751 +  Method::sort_methods(methods,
   1.752 +                              methods_annotations,
   1.753 +                              methods_parameter_annotations,
   1.754 +                              methods_default_annotations);
   1.755  
   1.756    // If JVMTI original method ordering or sharing is enabled construct int
   1.757    // array remembering the original ordering
   1.758    if (JvmtiExport::can_maintain_original_method_order() || DumpSharedSpaces) {
   1.759 -    typeArrayOop new_ordering = oopFactory::new_permanent_intArray(length, CHECK_(nullHandle));
   1.760 -    typeArrayHandle method_ordering(THREAD, new_ordering);
   1.761 +    Array<int>* method_ordering = MetadataFactory::new_array<int>(loader_data, length, CHECK_NULL);
   1.762      for (int index = 0; index < length; index++) {
   1.763 -      methodOop m = methodOop(methods->obj_at(index));
   1.764 +      Method* m = methods->at(index);
   1.765        int old_index = m->vtable_index();
   1.766        assert(old_index >= 0 && old_index < length, "invalid method index");
   1.767 -      method_ordering->int_at_put(index, old_index);
   1.768 -      m->set_vtable_index(methodOopDesc::invalid_vtable_index);
   1.769 +      method_ordering->at_put(index, old_index);
   1.770 +      m->set_vtable_index(Method::invalid_vtable_index);
   1.771      }
   1.772      return method_ordering;
   1.773    } else {
   1.774 -    return typeArrayHandle(THREAD, Universe::the_empty_int_array());
   1.775 +    return Universe::the_empty_int_array();
   1.776    }
   1.777  }
   1.778  
   1.779 @@ -2532,7 +2512,8 @@
   1.780  #define RECOGNIZED_INNER_CLASS_MODIFIERS (JVM_RECOGNIZED_CLASS_MODIFIERS | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED | JVM_ACC_STATIC)
   1.781  
   1.782  // Return number of classes in the inner classes attribute table
   1.783 -u2 ClassFileParser::parse_classfile_inner_classes_attribute(u1* inner_classes_attribute_start,
   1.784 +u2 ClassFileParser::parse_classfile_inner_classes_attribute(ClassLoaderData* loader_data,
   1.785 +                                                            u1* inner_classes_attribute_start,
   1.786                                                              bool parsed_enclosingmethod_attribute,
   1.787                                                              u2 enclosing_method_class_index,
   1.788                                                              u2 enclosing_method_method_index,
   1.789 @@ -2557,8 +2538,8 @@
   1.790    //    enclosing_method_class_index,
   1.791    //    enclosing_method_method_index]
   1.792    int size = length * 4 + (parsed_enclosingmethod_attribute ? 2 : 0);
   1.793 -  typeArrayOop ic = oopFactory::new_permanent_shortArray(size, CHECK_0);
   1.794 -  typeArrayHandle inner_classes(THREAD, ic);
   1.795 +  // FIXME: Will leak on exceptions.
   1.796 +  Array<u2>* inner_classes = MetadataFactory::new_array<u2>(loader_data, size, CHECK_0);
   1.797    int index = 0;
   1.798    int cp_size = cp->length();
   1.799    cfs->guarantee_more(8 * length, CHECK_0);  // 4-tuples of u2
   1.800 @@ -2600,20 +2581,20 @@
   1.801      verify_legal_class_modifiers(flags, CHECK_0);
   1.802      inner_access_flags.set_flags(flags);
   1.803  
   1.804 -    inner_classes->short_at_put(index++, inner_class_info_index);
   1.805 -    inner_classes->short_at_put(index++, outer_class_info_index);
   1.806 -    inner_classes->short_at_put(index++, inner_name_index);
   1.807 -    inner_classes->short_at_put(index++, inner_access_flags.as_short());
   1.808 +    inner_classes->at_put(index++, inner_class_info_index);
   1.809 +    inner_classes->at_put(index++, outer_class_info_index);
   1.810 +    inner_classes->at_put(index++, inner_name_index);
   1.811 +    inner_classes->at_put(index++, inner_access_flags.as_short());
   1.812    }
   1.813  
   1.814    // 4347400: make sure there's no duplicate entry in the classes array
   1.815    if (_need_verify && _major_version >= JAVA_1_5_VERSION) {
   1.816      for(int i = 0; i < length * 4; i += 4) {
   1.817        for(int j = i + 4; j < length * 4; j += 4) {
   1.818 -        guarantee_property((inner_classes->ushort_at(i)   != inner_classes->ushort_at(j) ||
   1.819 -                            inner_classes->ushort_at(i+1) != inner_classes->ushort_at(j+1) ||
   1.820 -                            inner_classes->ushort_at(i+2) != inner_classes->ushort_at(j+2) ||
   1.821 -                            inner_classes->ushort_at(i+3) != inner_classes->ushort_at(j+3)),
   1.822 +        guarantee_property((inner_classes->at(i)   != inner_classes->at(j) ||
   1.823 +                            inner_classes->at(i+1) != inner_classes->at(j+1) ||
   1.824 +                            inner_classes->at(i+2) != inner_classes->at(j+2) ||
   1.825 +                            inner_classes->at(i+3) != inner_classes->at(j+3)),
   1.826                              "Duplicate entry in InnerClasses in class file %s",
   1.827                              CHECK_0);
   1.828        }
   1.829 @@ -2622,12 +2603,12 @@
   1.830  
   1.831    // Set EnclosingMethod class and method indexes.
   1.832    if (parsed_enclosingmethod_attribute) {
   1.833 -    inner_classes->short_at_put(index++, enclosing_method_class_index);
   1.834 -    inner_classes->short_at_put(index++, enclosing_method_method_index);
   1.835 +    inner_classes->at_put(index++, enclosing_method_class_index);
   1.836 +    inner_classes->at_put(index++, enclosing_method_method_index);
   1.837    }
   1.838    assert(index == size, "wrong size");
   1.839  
   1.840 -  // Update instanceKlass with inner class info.
   1.841 +  // Update InstanceKlass with inner class info.
   1.842    set_class_inner_classes(inner_classes);
   1.843  
   1.844    // Restore buffer's current position.
   1.845 @@ -2651,7 +2632,8 @@
   1.846    set_class_generic_signature(cp->symbol_at(signature_index));
   1.847  }
   1.848  
   1.849 -void ClassFileParser::parse_classfile_bootstrap_methods_attribute(constantPoolHandle cp,
   1.850 +void ClassFileParser::parse_classfile_bootstrap_methods_attribute(ClassLoaderData* loader_data,
   1.851 +                                                                  constantPoolHandle cp,
   1.852                                                                    u4 attribute_byte_length, TRAPS) {
   1.853    ClassFileStream* cfs = stream();
   1.854    u1* current_start = cfs->current();
   1.855 @@ -2673,17 +2655,14 @@
   1.856    // The array begins with a series of short[2] pairs, one for each tuple.
   1.857    int index_size = (attribute_array_length * 2);
   1.858  
   1.859 -  typeArrayOop operands_oop = oopFactory::new_permanent_intArray(index_size + operand_count, CHECK);
   1.860 -  typeArrayHandle operands(THREAD, operands_oop);
   1.861 -  operands_oop = NULL; // tidy
   1.862 +  Array<u2>* operands = MetadataFactory::new_array<u2>(loader_data, index_size + operand_count, CHECK);
   1.863  
   1.864    int operand_fill_index = index_size;
   1.865    int cp_size = cp->length();
   1.866  
   1.867    for (int n = 0; n < attribute_array_length; n++) {
   1.868      // Store a 32-bit offset into the header of the operand array.
   1.869 -    assert(constantPoolOopDesc::operand_offset_at(operands(), n) == 0, "");
   1.870 -    constantPoolOopDesc::operand_offset_at_put(operands(), n, operand_fill_index);
   1.871 +    ConstantPool::operand_offset_at_put(operands, n, operand_fill_index);
   1.872  
   1.873      // Read a bootstrap specifier.
   1.874      cfs->guarantee_more(sizeof(u2) * 2, CHECK);  // bsm, argc
   1.875 @@ -2695,8 +2674,8 @@
   1.876        "bootstrap_method_index %u has bad constant type in class file %s",
   1.877        bootstrap_method_index,
   1.878        CHECK);
   1.879 -    operands->short_at_put(operand_fill_index++, bootstrap_method_index);
   1.880 -    operands->short_at_put(operand_fill_index++, argument_count);
   1.881 +    operands->at_put(operand_fill_index++, bootstrap_method_index);
   1.882 +    operands->at_put(operand_fill_index++, argument_count);
   1.883  
   1.884      cfs->guarantee_more(sizeof(u2) * argument_count, CHECK);  // argv[argc]
   1.885      for (int j = 0; j < argument_count; j++) {
   1.886 @@ -2707,28 +2686,28 @@
   1.887          "argument_index %u has bad constant type in class file %s",
   1.888          argument_index,
   1.889          CHECK);
   1.890 -      operands->short_at_put(operand_fill_index++, argument_index);
   1.891 +      operands->at_put(operand_fill_index++, argument_index);
   1.892      }
   1.893    }
   1.894  
   1.895 -  assert(operand_fill_index == operands()->length(), "exact fill");
   1.896 -  assert(constantPoolOopDesc::operand_array_length(operands()) == attribute_array_length, "correct decode");
   1.897 +  assert(operand_fill_index == operands->length(), "exact fill");
   1.898 +  assert(ConstantPool::operand_array_length(operands) == attribute_array_length, "correct decode");
   1.899  
   1.900    u1* current_end = cfs->current();
   1.901    guarantee_property(current_end == current_start + attribute_byte_length,
   1.902                       "Bad length on BootstrapMethods in class file %s",
   1.903                       CHECK);
   1.904  
   1.905 -  cp->set_operands(operands());
   1.906 +  cp->set_operands(operands);
   1.907  }
   1.908  
   1.909 -
   1.910 -void ClassFileParser::parse_classfile_attributes(constantPoolHandle cp,
   1.911 +void ClassFileParser::parse_classfile_attributes(ClassLoaderData* loader_data,
   1.912 +                                                 constantPoolHandle cp,
   1.913                                                   ClassFileParser::ClassAnnotationCollector* parsed_annotations,
   1.914                                                   TRAPS) {
   1.915    ClassFileStream* cfs = stream();
   1.916    // Set inner classes attribute to default sentinel
   1.917 -  set_class_inner_classes(typeArrayHandle(THREAD, Universe::the_empty_short_array()));
   1.918 +  set_class_inner_classes(Universe::the_empty_short_array());
   1.919    cfs->guarantee_more(2, CHECK);  // attributes_count
   1.920    u2 attributes_count = cfs->get_u2_fast();
   1.921    bool parsed_sourcefile_attribute = false;
   1.922 @@ -2844,7 +2823,7 @@
   1.923          if (parsed_bootstrap_methods_attribute)
   1.924            classfile_parse_error("Multiple BootstrapMethods attributes in class file %s", CHECK);
   1.925          parsed_bootstrap_methods_attribute = true;
   1.926 -        parse_classfile_bootstrap_methods_attribute(cp, attribute_length, CHECK);
   1.927 +        parse_classfile_bootstrap_methods_attribute(loader_data, cp, attribute_length, CHECK);
   1.928        } else {
   1.929          // Unknown attribute
   1.930          cfs->skip_u1(attribute_length, CHECK);
   1.931 @@ -2854,7 +2833,8 @@
   1.932        cfs->skip_u1(attribute_length, CHECK);
   1.933      }
   1.934    }
   1.935 -  typeArrayHandle annotations = assemble_annotations(runtime_visible_annotations,
   1.936 +  AnnotationArray* annotations = assemble_annotations(loader_data,
   1.937 +                                                      runtime_visible_annotations,
   1.938                                                       runtime_visible_annotations_length,
   1.939                                                       runtime_invisible_annotations,
   1.940                                                       runtime_invisible_annotations_length,
   1.941 @@ -2863,6 +2843,7 @@
   1.942  
   1.943    if (parsed_innerclasses_attribute || parsed_enclosingmethod_attribute) {
   1.944      u2 num_of_classes = parse_classfile_inner_classes_attribute(
   1.945 +                            loader_data,
   1.946                              inner_classes_attribute_start,
   1.947                              parsed_innerclasses_attribute,
   1.948                              enclosing_method_class_index,
   1.949 @@ -2895,25 +2876,34 @@
   1.950    if (_sde_buffer != NULL) {
   1.951      k->set_source_debug_extension(_sde_buffer, _sde_length);
   1.952    }
   1.953 -  k->set_inner_classes(_inner_classes());
   1.954 -  k->set_class_annotations(_annotations());
   1.955 +  k->set_inner_classes(_inner_classes);
   1.956 +  if (_annotations != NULL) {
   1.957 +    k->annotations()->set_class_annotations(_annotations);
   1.958 +  }
   1.959  }
   1.960  
   1.961 -typeArrayHandle ClassFileParser::assemble_annotations(u1* runtime_visible_annotations,
   1.962 +AnnotationArray* ClassFileParser::assemble_annotations(ClassLoaderData* loader_data,
   1.963 +                                                       u1* runtime_visible_annotations,
   1.964                                                        int runtime_visible_annotations_length,
   1.965                                                        u1* runtime_invisible_annotations,
   1.966                                                        int runtime_invisible_annotations_length, TRAPS) {
   1.967 -  typeArrayHandle annotations;
   1.968 +  AnnotationArray* annotations = NULL;
   1.969    if (runtime_visible_annotations != NULL ||
   1.970        runtime_invisible_annotations != NULL) {
   1.971 -    typeArrayOop anno = oopFactory::new_permanent_byteArray(runtime_visible_annotations_length +
   1.972 -                                                            runtime_invisible_annotations_length, CHECK_(annotations));
   1.973 -    annotations = typeArrayHandle(THREAD, anno);
   1.974 +    annotations = MetadataFactory::new_array<u1>(loader_data,
   1.975 +                                          runtime_visible_annotations_length +
   1.976 +                                          runtime_invisible_annotations_length,
   1.977 +                                          CHECK_(annotations));
   1.978      if (runtime_visible_annotations != NULL) {
   1.979 -      memcpy(annotations->byte_at_addr(0), runtime_visible_annotations, runtime_visible_annotations_length);
   1.980 +      for (int i = 0; i < runtime_visible_annotations_length; i++) {
   1.981 +        annotations->at_put(i, runtime_visible_annotations[i]);
   1.982 +      }
   1.983      }
   1.984      if (runtime_invisible_annotations != NULL) {
   1.985 -      memcpy(annotations->byte_at_addr(runtime_visible_annotations_length), runtime_invisible_annotations, runtime_invisible_annotations_length);
   1.986 +      for (int i = 0; i < runtime_invisible_annotations_length; i++) {
   1.987 +        int append = runtime_visible_annotations_length+i;
   1.988 +        annotations->at_put(append, runtime_invisible_annotations[i]);
   1.989 +      }
   1.990      }
   1.991    }
   1.992    return annotations;
   1.993 @@ -2935,6 +2925,7 @@
   1.994    // original class bytes.
   1.995    unsigned char *cached_class_file_bytes = NULL;
   1.996    jint cached_class_file_length;
   1.997 +  ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader());
   1.998  
   1.999    ClassFileStream* cfs = stream();
  1.1000    // Timing
  1.1001 @@ -3043,7 +3034,7 @@
  1.1002    _relax_verify = Verifier::relax_verify_for(class_loader());
  1.1003  
  1.1004    // Constant pool
  1.1005 -  constantPoolHandle cp = parse_constant_pool(class_loader, CHECK_(nullHandle));
  1.1006 +  constantPoolHandle cp = parse_constant_pool(loader_data, CHECK_(nullHandle));
  1.1007    ConstantPoolCleaner error_handler(cp); // set constant pool to be cleaned up.
  1.1008  
  1.1009    int cp_size = cp->length();
  1.1010 @@ -3092,7 +3083,7 @@
  1.1011                         CHECK_(nullHandle));
  1.1012    }
  1.1013  
  1.1014 -  klassOop preserve_this_klass;   // for storing result across HandleMark
  1.1015 +  Klass* preserve_this_klass;   // for storing result across HandleMark
  1.1016  
  1.1017    // release all handles when parsing is done
  1.1018    { HandleMark hm(THREAD);
  1.1019 @@ -3146,18 +3137,18 @@
  1.1020  
  1.1021      // Interfaces
  1.1022      u2 itfs_len = cfs->get_u2_fast();
  1.1023 -    objArrayHandle local_interfaces;
  1.1024 +    Array<Klass*>* local_interfaces;
  1.1025      if (itfs_len == 0) {
  1.1026 -      local_interfaces = objArrayHandle(THREAD, Universe::the_empty_system_obj_array());
  1.1027 +      local_interfaces = Universe::the_empty_klass_array();
  1.1028      } else {
  1.1029 -      local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, CHECK_(nullHandle));
  1.1030 +      local_interfaces = parse_interfaces(cp, itfs_len, loader_data, protection_domain, _class_name, CHECK_(nullHandle));
  1.1031      }
  1.1032  
  1.1033      u2 java_fields_count = 0;
  1.1034      // Fields (offsets are filled in later)
  1.1035      FieldAllocationCount fac;
  1.1036 -    objArrayHandle fields_annotations;
  1.1037 -    typeArrayHandle fields = parse_fields(class_name, cp, access_flags.is_interface(), &fac, &fields_annotations,
  1.1038 +    Array<AnnotationArray*>* fields_annotations = NULL;
  1.1039 +    Array<u2>* fields = parse_fields(loader_data, class_name, cp, access_flags.is_interface(), &fac, &fields_annotations,
  1.1040                                            &java_fields_count,
  1.1041                                            CHECK_(nullHandle));
  1.1042      // Methods
  1.1043 @@ -3166,24 +3157,21 @@
  1.1044      promoted_flags.set_flags(0);
  1.1045      // These need to be oop pointers because they are allocated lazily
  1.1046      // inside parse_methods inside a nested HandleMark
  1.1047 -    objArrayOop methods_annotations_oop = NULL;
  1.1048 -    objArrayOop methods_parameter_annotations_oop = NULL;
  1.1049 -    objArrayOop methods_default_annotations_oop = NULL;
  1.1050 -    objArrayHandle methods = parse_methods(cp, access_flags.is_interface(),
  1.1051 +    Array<AnnotationArray*>* methods_annotations = NULL;
  1.1052 +    Array<AnnotationArray*>* methods_parameter_annotations = NULL;
  1.1053 +    Array<AnnotationArray*>* methods_default_annotations = NULL;
  1.1054 +    Array<Method*>* methods = parse_methods(loader_data,
  1.1055 +                                              cp, access_flags.is_interface(),
  1.1056                                             &promoted_flags,
  1.1057                                             &has_final_method,
  1.1058 -                                           &methods_annotations_oop,
  1.1059 -                                           &methods_parameter_annotations_oop,
  1.1060 -                                           &methods_default_annotations_oop,
  1.1061 +                                              &methods_annotations,
  1.1062 +                                              &methods_parameter_annotations,
  1.1063 +                                              &methods_default_annotations,
  1.1064                                             CHECK_(nullHandle));
  1.1065  
  1.1066 -    objArrayHandle methods_annotations(THREAD, methods_annotations_oop);
  1.1067 -    objArrayHandle methods_parameter_annotations(THREAD, methods_parameter_annotations_oop);
  1.1068 -    objArrayHandle methods_default_annotations(THREAD, methods_default_annotations_oop);
  1.1069 -
  1.1070      // Additional attributes
  1.1071      ClassAnnotationCollector parsed_annotations;
  1.1072 -    parse_classfile_attributes(cp, &parsed_annotations, CHECK_(nullHandle));
  1.1073 +    parse_classfile_attributes(loader_data, cp, &parsed_annotations, CHECK_(nullHandle));
  1.1074  
  1.1075      // Make sure this is the end of class file stream
  1.1076      guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle));
  1.1077 @@ -3198,7 +3186,7 @@
  1.1078                             "Interfaces must have java.lang.Object as superclass in class file %s",
  1.1079                             CHECK_(nullHandle));
  1.1080        }
  1.1081 -      klassOop k = SystemDictionary::resolve_super_or_fail(class_name,
  1.1082 +      Klass* k = SystemDictionary::resolve_super_or_fail(class_name,
  1.1083                                                             sk,
  1.1084                                                             class_loader,
  1.1085                                                             protection_domain,
  1.1086 @@ -3229,10 +3217,11 @@
  1.1087      }
  1.1088  
  1.1089      // Compute the transitive list of all unique interfaces implemented by this class
  1.1090 -    objArrayHandle transitive_interfaces = compute_transitive_interfaces(super_klass, local_interfaces, CHECK_(nullHandle));
  1.1091 +    Array<Klass*>* transitive_interfaces = compute_transitive_interfaces(loader_data, super_klass, local_interfaces, CHECK_(nullHandle));
  1.1092  
  1.1093      // sort methods
  1.1094 -    typeArrayHandle method_ordering = sort_methods(methods,
  1.1095 +    Array<int>* method_ordering = sort_methods(loader_data,
  1.1096 +                                               methods,
  1.1097                                                     methods_annotations,
  1.1098                                                     methods_parameter_annotations,
  1.1099                                                     methods_default_annotations,
  1.1100 @@ -3249,11 +3238,11 @@
  1.1101      klassVtable::compute_vtable_size_and_num_mirandas(vtable_size,
  1.1102                                                        num_miranda_methods,
  1.1103                                                        super_klass(),
  1.1104 -                                                      methods(),
  1.1105 +                                                      methods,
  1.1106                                                        access_flags,
  1.1107                                                        class_loader,
  1.1108                                                        class_name,
  1.1109 -                                                      local_interfaces(),
  1.1110 +                                                      local_interfaces,
  1.1111                                                        CHECK_(nullHandle));
  1.1112  
  1.1113      // Size of Java itable (in words)
  1.1114 @@ -3597,13 +3586,26 @@
  1.1115        rt = super_klass->reference_type();
  1.1116      }
  1.1117  
  1.1118 -    // We can now create the basic klassOop for this klass
  1.1119 -    klassOop ik = oopFactory::new_instanceKlass(name, vtable_size, itable_size,
  1.1120 +    // We can now create the basic Klass* for this klass
  1.1121 +    int total_oop_map_size2 =
  1.1122 +      InstanceKlass::nonstatic_oop_map_size(total_oop_map_count);
  1.1123 +
  1.1124 +    Klass* ik = InstanceKlass::allocate_instance_klass(loader_data,
  1.1125 +                                                         vtable_size,
  1.1126 +                                                         itable_size,
  1.1127                                                  static_field_size,
  1.1128 -                                                total_oop_map_count,
  1.1129 +                                                         total_oop_map_size2,
  1.1130 +                                                         rt,
  1.1131                                                  access_flags,
  1.1132 -                                                rt, host_klass,
  1.1133 +                                                         name,
  1.1134 +                                                         super_klass(),
  1.1135 +                                                         host_klass,
  1.1136                                                  CHECK_(nullHandle));
  1.1137 +
  1.1138 +    // Add all classes to our internal class loader list here,
  1.1139 +    // including classes in the bootstrap (NULL) class loader.
  1.1140 +    loader_data->add_class(ik);
  1.1141 +
  1.1142      instanceKlassHandle this_klass (THREAD, ik);
  1.1143  
  1.1144      assert(this_klass->static_field_size() == static_field_size, "sanity");
  1.1145 @@ -3618,51 +3620,61 @@
  1.1146      assert(this_klass->size_helper() == instance_size, "correct size_helper");
  1.1147      // Not yet: supers are done below to support the new subtype-checking fields
  1.1148      //this_klass->set_super(super_klass());
  1.1149 -    this_klass->set_class_loader(class_loader());
  1.1150 +    this_klass->set_class_loader_data(loader_data);
  1.1151      this_klass->set_nonstatic_field_size(nonstatic_field_size);
  1.1152      this_klass->set_has_nonstatic_fields(has_nonstatic_fields);
  1.1153      this_klass->set_static_oop_field_count(fac.count[STATIC_OOP]);
  1.1154      cp->set_pool_holder(this_klass());
  1.1155      error_handler.set_in_error(false);   // turn off error handler for cp
  1.1156      this_klass->set_constants(cp());
  1.1157 -    this_klass->set_local_interfaces(local_interfaces());
  1.1158 -    this_klass->set_fields(fields(), java_fields_count);
  1.1159 -    this_klass->set_methods(methods());
  1.1160 +    this_klass->set_local_interfaces(local_interfaces);
  1.1161 +    this_klass->set_fields(fields, java_fields_count);
  1.1162 +    this_klass->set_methods(methods);
  1.1163      if (has_final_method) {
  1.1164        this_klass->set_has_final_method();
  1.1165      }
  1.1166 -    this_klass->set_method_ordering(method_ordering());
  1.1167 -    // The instanceKlass::_methods_jmethod_ids cache and the
  1.1168 -    // instanceKlass::_methods_cached_itable_indices cache are
  1.1169 +    this_klass->set_method_ordering(method_ordering);
  1.1170 +    // The InstanceKlass::_methods_jmethod_ids cache and the
  1.1171 +    // InstanceKlass::_methods_cached_itable_indices cache are
  1.1172      // both managed on the assumption that the initial cache
  1.1173      // size is equal to the number of methods in the class. If
  1.1174 -    // that changes, then instanceKlass::idnum_can_increment()
  1.1175 +    // that changes, then InstanceKlass::idnum_can_increment()
  1.1176      // has to be changed accordingly.
  1.1177      this_klass->set_initial_method_idnum(methods->length());
  1.1178      this_klass->set_name(cp->klass_name_at(this_class_index));
  1.1179      if (LinkWellKnownClasses || is_anonymous())  // I am well known to myself
  1.1180        cp->klass_at_put(this_class_index, this_klass()); // eagerly resolve
  1.1181 -    this_klass->set_protection_domain(protection_domain());
  1.1182 -    this_klass->set_fields_annotations(fields_annotations());
  1.1183 -    this_klass->set_methods_annotations(methods_annotations());
  1.1184 -    this_klass->set_methods_parameter_annotations(methods_parameter_annotations());
  1.1185 -    this_klass->set_methods_default_annotations(methods_default_annotations());
  1.1186 +
  1.1187 +    if (fields_annotations != NULL ||
  1.1188 +        methods_annotations != NULL ||
  1.1189 +        methods_parameter_annotations != NULL ||
  1.1190 +        methods_default_annotations != NULL) {
  1.1191 +      // Allocate an annotation type if needed.
  1.1192 +      Annotations* anno = Annotations::allocate(loader_data,
  1.1193 +                            fields_annotations, methods_annotations,
  1.1194 +                            methods_parameter_annotations,
  1.1195 +                            methods_default_annotations, CHECK_(nullHandle));
  1.1196 +      this_klass->set_annotations(anno);
  1.1197 +    } else {
  1.1198 +      this_klass->set_annotations(NULL);
  1.1199 +    }
  1.1200 +
  1.1201  
  1.1202      this_klass->set_minor_version(minor_version);
  1.1203      this_klass->set_major_version(major_version);
  1.1204  
  1.1205 -    // Set up methodOop::intrinsic_id as soon as we know the names of methods.
  1.1206 +    // Set up Method*::intrinsic_id as soon as we know the names of methods.
  1.1207      // (We used to do this lazily, but now we query it in Rewriter,
  1.1208      // which is eagerly done for every method, so we might as well do it now,
  1.1209      // when everything is fresh in memory.)
  1.1210 -    if (methodOopDesc::klass_id_for_intrinsics(this_klass->as_klassOop()) != vmSymbols::NO_SID) {
  1.1211 +    if (Method::klass_id_for_intrinsics(this_klass()) != vmSymbols::NO_SID) {
  1.1212        for (int j = 0; j < methods->length(); j++) {
  1.1213 -        ((methodOop)methods->obj_at(j))->init_intrinsic_id();
  1.1214 +        methods->at(j)->init_intrinsic_id();
  1.1215        }
  1.1216      }
  1.1217  
  1.1218      if (cached_class_file_bytes != NULL) {
  1.1219 -      // JVMTI: we have an instanceKlass now, tell it about the cached bytes
  1.1220 +      // JVMTI: we have an InstanceKlass now, tell it about the cached bytes
  1.1221        this_klass->set_cached_class_file(cached_class_file_bytes,
  1.1222                                          cached_class_file_length);
  1.1223      }
  1.1224 @@ -3677,13 +3689,18 @@
  1.1225      }
  1.1226  
  1.1227      // Fill in field values obtained by parse_classfile_attributes
  1.1228 -    if (parsed_annotations.has_any_annotations())
  1.1229 +    if (parsed_annotations.has_any_annotations()) {
  1.1230        parsed_annotations.apply_to(this_klass);
  1.1231 +    }
  1.1232 +    // Create annotations
  1.1233 +    if (_annotations != NULL && this_klass->annotations() == NULL) {
  1.1234 +      Annotations* anno = Annotations::allocate(loader_data, CHECK_NULL);
  1.1235 +      this_klass->set_annotations(anno);
  1.1236 +    }
  1.1237      apply_parsed_class_attributes(this_klass);
  1.1238  
  1.1239 -    // VerifyOops believes that once this has been set, the object is completely loaded.
  1.1240      // Compute transitive closure of interfaces this class implements
  1.1241 -    this_klass->set_transitive_interfaces(transitive_interfaces());
  1.1242 +    this_klass->set_transitive_interfaces(transitive_interfaces);
  1.1243  
  1.1244      // Fill in information needed to compute superclasses.
  1.1245      this_klass->initialize_supers(super_klass(), CHECK_(nullHandle));
  1.1246 @@ -3718,7 +3735,18 @@
  1.1247      // Allocate mirror and initialize static fields
  1.1248      java_lang_Class::create_mirror(this_klass, CHECK_(nullHandle));
  1.1249  
  1.1250 -    ClassLoadingService::notify_class_loaded(instanceKlass::cast(this_klass()),
  1.1251 +    // Allocate a simple java object for locking during class initialization.
  1.1252 +    // This needs to be a java object because it can be held across a java call.
  1.1253 +    typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK_NULL);
  1.1254 +    this_klass->set_init_lock(r);
  1.1255 +
  1.1256 +    // TODO: Move these oops to the mirror
  1.1257 +    this_klass->set_protection_domain(protection_domain());
  1.1258 +
  1.1259 +    // Update the loader_data graph.
  1.1260 +    record_defined_class_dependencies(this_klass, CHECK_NULL);
  1.1261 +
  1.1262 +    ClassLoadingService::notify_class_loaded(InstanceKlass::cast(this_klass()),
  1.1263                                               false /* not shared class */);
  1.1264  
  1.1265      if (TraceClassLoading) {
  1.1266 @@ -3728,17 +3756,17 @@
  1.1267                     cfs->source());
  1.1268        } else if (class_loader.is_null()) {
  1.1269          if (THREAD->is_Java_thread()) {
  1.1270 -          klassOop caller = ((JavaThread*)THREAD)->security_get_caller_class(1);
  1.1271 +          Klass* caller = ((JavaThread*)THREAD)->security_get_caller_class(1);
  1.1272            tty->print("[Loaded %s by instance of %s]\n",
  1.1273                       this_klass->external_name(),
  1.1274 -                     instanceKlass::cast(caller)->external_name());
  1.1275 +                     InstanceKlass::cast(caller)->external_name());
  1.1276          } else {
  1.1277            tty->print("[Loaded %s]\n", this_klass->external_name());
  1.1278          }
  1.1279        } else {
  1.1280          ResourceMark rm;
  1.1281          tty->print("[Loaded %s from %s]\n", this_klass->external_name(),
  1.1282 -                   instanceKlass::cast(class_loader->klass())->external_name());
  1.1283 +                   InstanceKlass::cast(class_loader->klass())->external_name());
  1.1284        }
  1.1285      }
  1.1286  
  1.1287 @@ -3746,15 +3774,15 @@
  1.1288        // print out the superclass.
  1.1289        const char * from = Klass::cast(this_klass())->external_name();
  1.1290        if (this_klass->java_super() != NULL) {
  1.1291 -        tty->print("RESOLVE %s %s (super)\n", from, instanceKlass::cast(this_klass->java_super())->external_name());
  1.1292 +        tty->print("RESOLVE %s %s (super)\n", from, InstanceKlass::cast(this_klass->java_super())->external_name());
  1.1293        }
  1.1294        // print out each of the interface classes referred to by this class.
  1.1295 -      objArrayHandle local_interfaces(THREAD, this_klass->local_interfaces());
  1.1296 -      if (!local_interfaces.is_null()) {
  1.1297 +      Array<Klass*>* local_interfaces = this_klass->local_interfaces();
  1.1298 +      if (local_interfaces != NULL) {
  1.1299          int length = local_interfaces->length();
  1.1300          for (int i = 0; i < length; i++) {
  1.1301 -          klassOop k = klassOop(local_interfaces->obj_at(i));
  1.1302 -          instanceKlass* to_class = instanceKlass::cast(k);
  1.1303 +          Klass* k = local_interfaces->at(i);
  1.1304 +          InstanceKlass* to_class = InstanceKlass::cast(k);
  1.1305            const char * to = to_class->external_name();
  1.1306            tty->print("RESOLVE %s %s (interface)\n", from, to);
  1.1307          }
  1.1308 @@ -3781,9 +3809,10 @@
  1.1309      preserve_this_klass = this_klass();
  1.1310    }
  1.1311  
  1.1312 -  // Create new handle outside HandleMark
  1.1313 +  // Create new handle outside HandleMark (might be needed for
  1.1314 +  // Extended Class Redefinition)
  1.1315    instanceKlassHandle this_klass (THREAD, preserve_this_klass);
  1.1316 -  debug_only(this_klass->as_klassOop()->verify();)
  1.1317 +  debug_only(this_klass->verify();)
  1.1318  
  1.1319    return this_klass;
  1.1320  }
  1.1321 @@ -3826,7 +3855,7 @@
  1.1322                                      int* nonstatic_oop_offsets,
  1.1323                                      unsigned int* nonstatic_oop_counts) {
  1.1324    OopMapBlock* this_oop_map = k->start_of_nonstatic_oop_maps();
  1.1325 -  const instanceKlass* const super = k->superklass();
  1.1326 +  const InstanceKlass* const super = k->superklass();
  1.1327    const unsigned int super_count = super ? super->nonstatic_oop_map_count() : 0;
  1.1328    if (super_count > 0) {
  1.1329      // Copy maps from superklass
  1.1330 @@ -3861,20 +3890,20 @@
  1.1331  
  1.1332  
  1.1333  void ClassFileParser::set_precomputed_flags(instanceKlassHandle k) {
  1.1334 -  klassOop super = k->super();
  1.1335 +  Klass* super = k->super();
  1.1336  
  1.1337    // Check if this klass has an empty finalize method (i.e. one with return bytecode only),
  1.1338    // in which case we don't have to register objects as finalizable
  1.1339    if (!_has_empty_finalizer) {
  1.1340      if (_has_finalizer ||
  1.1341 -        (super != NULL && super->klass_part()->has_finalizer())) {
  1.1342 +        (super != NULL && super->has_finalizer())) {
  1.1343        k->set_has_finalizer();
  1.1344      }
  1.1345    }
  1.1346  
  1.1347  #ifdef ASSERT
  1.1348    bool f = false;
  1.1349 -  methodOop m = k->lookup_method(vmSymbols::finalize_method_name(),
  1.1350 +  Method* m = k->lookup_method(vmSymbols::finalize_method_name(),
  1.1351                                   vmSymbols::void_method_signature());
  1.1352    if (m != NULL && !m->is_empty_method()) {
  1.1353      f = true;
  1.1354 @@ -3901,7 +3930,7 @@
  1.1355  #ifdef ASSERT
  1.1356      bool v = false;
  1.1357      if (Klass::cast(super)->has_vanilla_constructor()) {
  1.1358 -      methodOop constructor = k->find_method(vmSymbols::object_initializer_name(
  1.1359 +      Method* constructor = k->find_method(vmSymbols::object_initializer_name(
  1.1360  ), vmSymbols::void_method_signature());
  1.1361        if (constructor != NULL && constructor->is_vanilla_constructor()) {
  1.1362          v = true;
  1.1363 @@ -3912,12 +3941,12 @@
  1.1364    }
  1.1365  
  1.1366    // If it cannot be fast-path allocated, set a bit in the layout helper.
  1.1367 -  // See documentation of instanceKlass::can_be_fastpath_allocated().
  1.1368 +  // See documentation of InstanceKlass::can_be_fastpath_allocated().
  1.1369    assert(k->size_helper() > 0, "layout_helper is initialized");
  1.1370    if ((!RegisterFinalizersAtInit && k->has_finalizer())
  1.1371        || k->is_abstract() || k->is_interface()
  1.1372        || (k->name() == vmSymbols::java_lang_Class()
  1.1373 -          && k->class_loader() == NULL)
  1.1374 +          && k->class_loader_data()->is_the_null_class_loader_data())
  1.1375        || k->size_helper() >= FastAllocateSizeLimit) {
  1.1376      // Forbid fast-path allocation.
  1.1377      jint lh = Klass::instance_layout_helper(k->size_helper(), true);
  1.1378 @@ -3925,30 +3954,44 @@
  1.1379    }
  1.1380  }
  1.1381  
  1.1382 -
  1.1383 -// utility method for appending and array with check for duplicates
  1.1384 -
  1.1385 -void append_interfaces(objArrayHandle result, int& index, objArrayOop ifs) {
  1.1386 -  // iterate over new interfaces
  1.1387 -  for (int i = 0; i < ifs->length(); i++) {
  1.1388 -    oop e = ifs->obj_at(i);
  1.1389 -    assert(e->is_klass() && instanceKlass::cast(klassOop(e))->is_interface(), "just checking");
  1.1390 -    // check for duplicates
  1.1391 -    bool duplicate = false;
  1.1392 -    for (int j = 0; j < index; j++) {
  1.1393 -      if (result->obj_at(j) == e) {
  1.1394 -        duplicate = true;
  1.1395 -        break;
  1.1396 +// Attach super classes and interface classes to class loader data
  1.1397 +void ClassFileParser::record_defined_class_dependencies(instanceKlassHandle defined_klass, TRAPS) {
  1.1398 +  ClassLoaderData * defining_loader_data = defined_klass->class_loader_data();
  1.1399 +  if (defining_loader_data->is_the_null_class_loader_data()) {
  1.1400 +      // Dependencies to null class loader data are implicit.
  1.1401 +      return;
  1.1402 +  } else {
  1.1403 +    // add super class dependency
  1.1404 +    Klass* super = defined_klass->super();
  1.1405 +    if (super != NULL) {
  1.1406 +      defining_loader_data->record_dependency(super, CHECK);
  1.1407 +    }
  1.1408 +
  1.1409 +    // add super interface dependencies
  1.1410 +    Array<Klass*>* local_interfaces = defined_klass->local_interfaces();
  1.1411 +    if (local_interfaces != NULL) {
  1.1412 +      int length = local_interfaces->length();
  1.1413 +      for (int i = 0; i < length; i++) {
  1.1414 +        defining_loader_data->record_dependency(local_interfaces->at(i), CHECK);
  1.1415        }
  1.1416      }
  1.1417 -    // add new interface
  1.1418 -    if (!duplicate) {
  1.1419 -      result->obj_at_put(index++, e);
  1.1420 -    }
  1.1421    }
  1.1422  }
  1.1423  
  1.1424 -objArrayHandle ClassFileParser::compute_transitive_interfaces(instanceKlassHandle super, objArrayHandle local_ifs, TRAPS) {
  1.1425 +// utility method for appending and array with check for duplicates
  1.1426 +
  1.1427 +void append_interfaces(GrowableArray<Klass*>* result, Array<Klass*>* ifs) {
  1.1428 +  // iterate over new interfaces
  1.1429 +  for (int i = 0; i < ifs->length(); i++) {
  1.1430 +    Klass* e = ifs->at(i);
  1.1431 +    assert(e->is_klass() && InstanceKlass::cast(e)->is_interface(), "just checking");
  1.1432 +    // add new interface
  1.1433 +    result->append_if_missing(e);
  1.1434 +  }
  1.1435 +}
  1.1436 +
  1.1437 +
  1.1438 +Array<Klass*>* ClassFileParser::compute_transitive_interfaces(ClassLoaderData* loader_data, instanceKlassHandle super, Array<Klass*>* local_ifs, TRAPS) {
  1.1439    // Compute maximum size for transitive interfaces
  1.1440    int max_transitive_size = 0;
  1.1441    int super_size = 0;
  1.1442 @@ -3960,66 +4003,63 @@
  1.1443    // Add local interfaces' super interfaces
  1.1444    int local_size = local_ifs->length();
  1.1445    for (int i = 0; i < local_size; i++) {
  1.1446 -    klassOop l = klassOop(local_ifs->obj_at(i));
  1.1447 -    max_transitive_size += instanceKlass::cast(l)->transitive_interfaces()->length();
  1.1448 +    Klass* l = local_ifs->at(i);
  1.1449 +    max_transitive_size += InstanceKlass::cast(l)->transitive_interfaces()->length();
  1.1450    }
  1.1451    // Finally add local interfaces
  1.1452    max_transitive_size += local_size;
  1.1453    // Construct array
  1.1454 -  objArrayHandle result;
  1.1455    if (max_transitive_size == 0) {
  1.1456      // no interfaces, use canonicalized array
  1.1457 -    result = objArrayHandle(THREAD, Universe::the_empty_system_obj_array());
  1.1458 +    return Universe::the_empty_klass_array();
  1.1459    } else if (max_transitive_size == super_size) {
  1.1460      // no new local interfaces added, share superklass' transitive interface array
  1.1461 -    result = objArrayHandle(THREAD, super->transitive_interfaces());
  1.1462 +    return super->transitive_interfaces();
  1.1463    } else if (max_transitive_size == local_size) {
  1.1464      // only local interfaces added, share local interface array
  1.1465 -    result = local_ifs;
  1.1466 +    return local_ifs;
  1.1467    } else {
  1.1468 -    objArrayHandle nullHandle;
  1.1469 -    objArrayOop new_objarray = oopFactory::new_system_objArray(max_transitive_size, CHECK_(nullHandle));
  1.1470 -    result = objArrayHandle(THREAD, new_objarray);
  1.1471 -    int index = 0;
  1.1472 +    ResourceMark rm;
  1.1473 +    GrowableArray<Klass*>* result = new GrowableArray<Klass*>(max_transitive_size);
  1.1474 +
  1.1475      // Copy down from superclass
  1.1476      if (super.not_null()) {
  1.1477 -      append_interfaces(result, index, super->transitive_interfaces());
  1.1478 +      append_interfaces(result, super->transitive_interfaces());
  1.1479      }
  1.1480 +
  1.1481      // Copy down from local interfaces' superinterfaces
  1.1482      for (int i = 0; i < local_ifs->length(); i++) {
  1.1483 -      klassOop l = klassOop(local_ifs->obj_at(i));
  1.1484 -      append_interfaces(result, index, instanceKlass::cast(l)->transitive_interfaces());
  1.1485 +      Klass* l = local_ifs->at(i);
  1.1486 +      append_interfaces(result, InstanceKlass::cast(l)->transitive_interfaces());
  1.1487      }
  1.1488      // Finally add local interfaces
  1.1489 -    append_interfaces(result, index, local_ifs());
  1.1490 -
  1.1491 -    // Check if duplicates were removed
  1.1492 -    if (index != max_transitive_size) {
  1.1493 -      assert(index < max_transitive_size, "just checking");
  1.1494 -      objArrayOop new_result = oopFactory::new_system_objArray(index, CHECK_(nullHandle));
  1.1495 -      for (int i = 0; i < index; i++) {
  1.1496 -        oop e = result->obj_at(i);
  1.1497 +    append_interfaces(result, local_ifs);
  1.1498 +
  1.1499 +    // length will be less than the max_transitive_size if duplicates were removed
  1.1500 +    int length = result->length();
  1.1501 +    assert(length <= max_transitive_size, "just checking");
  1.1502 +    Array<Klass*>* new_result = MetadataFactory::new_array<Klass*>(loader_data, length, CHECK_NULL);
  1.1503 +    for (int i = 0; i < length; i++) {
  1.1504 +      Klass* e = result->at(i);
  1.1505          assert(e != NULL, "just checking");
  1.1506 -        new_result->obj_at_put(i, e);
  1.1507 -      }
  1.1508 -      result = objArrayHandle(THREAD, new_result);
  1.1509 +      new_result->at_put(i, e);
  1.1510      }
  1.1511 +    return new_result;
  1.1512    }
  1.1513 -  return result;
  1.1514  }
  1.1515  
  1.1516  
  1.1517  void ClassFileParser::check_super_class_access(instanceKlassHandle this_klass, TRAPS) {
  1.1518 -  klassOop super = this_klass->super();
  1.1519 +  Klass* super = this_klass->super();
  1.1520    if ((super != NULL) &&
  1.1521 -      (!Reflection::verify_class_access(this_klass->as_klassOop(), super, false))) {
  1.1522 +      (!Reflection::verify_class_access(this_klass(), super, false))) {
  1.1523      ResourceMark rm(THREAD);
  1.1524      Exceptions::fthrow(
  1.1525        THREAD_AND_LOCATION,
  1.1526        vmSymbols::java_lang_IllegalAccessError(),
  1.1527        "class %s cannot access its superclass %s",
  1.1528        this_klass->external_name(),
  1.1529 -      instanceKlass::cast(super)->external_name()
  1.1530 +      InstanceKlass::cast(super)->external_name()
  1.1531      );
  1.1532      return;
  1.1533    }
  1.1534 @@ -4027,19 +4067,19 @@
  1.1535  
  1.1536  
  1.1537  void ClassFileParser::check_super_interface_access(instanceKlassHandle this_klass, TRAPS) {
  1.1538 -  objArrayHandle local_interfaces (THREAD, this_klass->local_interfaces());
  1.1539 +  Array<Klass*>* local_interfaces = this_klass->local_interfaces();
  1.1540    int lng = local_interfaces->length();
  1.1541    for (int i = lng - 1; i >= 0; i--) {
  1.1542 -    klassOop k = klassOop(local_interfaces->obj_at(i));
  1.1543 +    Klass* k = local_interfaces->at(i);
  1.1544      assert (k != NULL && Klass::cast(k)->is_interface(), "invalid interface");
  1.1545 -    if (!Reflection::verify_class_access(this_klass->as_klassOop(), k, false)) {
  1.1546 +    if (!Reflection::verify_class_access(this_klass(), k, false)) {
  1.1547        ResourceMark rm(THREAD);
  1.1548        Exceptions::fthrow(
  1.1549          THREAD_AND_LOCATION,
  1.1550          vmSymbols::java_lang_IllegalAccessError(),
  1.1551          "class %s cannot access its superinterface %s",
  1.1552          this_klass->external_name(),
  1.1553 -        instanceKlass::cast(k)->external_name()
  1.1554 +        InstanceKlass::cast(k)->external_name()
  1.1555        );
  1.1556        return;
  1.1557      }
  1.1558 @@ -4048,12 +4088,12 @@
  1.1559  
  1.1560  
  1.1561  void ClassFileParser::check_final_method_override(instanceKlassHandle this_klass, TRAPS) {
  1.1562 -  objArrayHandle methods (THREAD, this_klass->methods());
  1.1563 +  Array<Method*>* methods = this_klass->methods();
  1.1564    int num_methods = methods->length();
  1.1565  
  1.1566    // go thru each method and check if it overrides a final method
  1.1567    for (int index = 0; index < num_methods; index++) {
  1.1568 -    methodOop m = (methodOop)methods->obj_at(index);
  1.1569 +    Method* m = methods->at(index);
  1.1570  
  1.1571      // skip private, static and <init> methods
  1.1572      if ((!m->is_private()) &&
  1.1573 @@ -4062,20 +4102,20 @@
  1.1574  
  1.1575        Symbol* name = m->name();
  1.1576        Symbol* signature = m->signature();
  1.1577 -      klassOop k = this_klass->super();
  1.1578 -      methodOop super_m = NULL;
  1.1579 +      Klass* k = this_klass->super();
  1.1580 +      Method* super_m = NULL;
  1.1581        while (k != NULL) {
  1.1582          // skip supers that don't have final methods.
  1.1583 -        if (k->klass_part()->has_final_method()) {
  1.1584 +        if (k->has_final_method()) {
  1.1585            // lookup a matching method in the super class hierarchy
  1.1586 -          super_m = instanceKlass::cast(k)->lookup_method(name, signature);
  1.1587 +          super_m = InstanceKlass::cast(k)->lookup_method(name, signature);
  1.1588            if (super_m == NULL) {
  1.1589              break; // didn't find any match; get out
  1.1590            }
  1.1591  
  1.1592            if (super_m->is_final() &&
  1.1593                // matching method in super is final
  1.1594 -              (Reflection::verify_field_access(this_klass->as_klassOop(),
  1.1595 +              (Reflection::verify_field_access(this_klass(),
  1.1596                                                 super_m->method_holder(),
  1.1597                                                 super_m->method_holder(),
  1.1598                                                 super_m->access_flags(), false))
  1.1599 @@ -4094,11 +4134,11 @@
  1.1600            }
  1.1601  
  1.1602            // continue to look from super_m's holder's super.
  1.1603 -          k = instanceKlass::cast(super_m->method_holder())->super();
  1.1604 +          k = InstanceKlass::cast(super_m->method_holder())->super();
  1.1605            continue;
  1.1606          }
  1.1607  
  1.1608 -        k = k->klass_part()->super();
  1.1609 +        k = k->super();
  1.1610        }
  1.1611      }
  1.1612    }
  1.1613 @@ -4108,11 +4148,11 @@
  1.1614  // assumes that this_klass is an interface
  1.1615  void ClassFileParser::check_illegal_static_method(instanceKlassHandle this_klass, TRAPS) {
  1.1616    assert(this_klass->is_interface(), "not an interface");
  1.1617 -  objArrayHandle methods (THREAD, this_klass->methods());
  1.1618 +  Array<Method*>* methods = this_klass->methods();
  1.1619    int num_methods = methods->length();
  1.1620  
  1.1621    for (int index = 0; index < num_methods; index++) {
  1.1622 -    methodOop m = (methodOop)methods->obj_at(index);
  1.1623 +    Method* m = methods->at(index);
  1.1624      // if m is static and not the init method, throw a verify error
  1.1625      if ((m->is_static()) && (m->name() != vmSymbols::class_initializer_name())) {
  1.1626        ResourceMark rm(THREAD);

mercurial