src/share/vm/oops/instanceKlass.cpp

changeset 5896
d37a0525c0fe
parent 5853
d25557d03ec0
child 5971
b8860472c377
     1.1 --- a/src/share/vm/oops/instanceKlass.cpp	Sat Oct 12 13:09:18 2013 -0400
     1.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Sat Oct 12 15:39:16 2013 -0400
     1.3 @@ -320,7 +320,8 @@
     1.4  
     1.5  void InstanceKlass::deallocate_methods(ClassLoaderData* loader_data,
     1.6                                         Array<Method*>* methods) {
     1.7 -  if (methods != NULL && methods != Universe::the_empty_method_array()) {
     1.8 +  if (methods != NULL && methods != Universe::the_empty_method_array() &&
     1.9 +      !methods->is_shared()) {
    1.10      for (int i = 0; i < methods->length(); i++) {
    1.11        Method* method = methods->at(i);
    1.12        if (method == NULL) continue;  // maybe null if error processing
    1.13 @@ -344,13 +345,14 @@
    1.14      // check that the interfaces don't come from super class
    1.15      Array<Klass*>* sti = (super_klass == NULL) ? NULL :
    1.16                      InstanceKlass::cast(super_klass)->transitive_interfaces();
    1.17 -    if (ti != sti) {
    1.18 +    if (ti != sti && ti != NULL && !ti->is_shared()) {
    1.19        MetadataFactory::free_array<Klass*>(loader_data, ti);
    1.20      }
    1.21    }
    1.22  
    1.23    // local interfaces can be empty
    1.24 -  if (local_interfaces != Universe::the_empty_klass_array()) {
    1.25 +  if (local_interfaces != Universe::the_empty_klass_array() &&
    1.26 +      local_interfaces != NULL && !local_interfaces->is_shared()) {
    1.27      MetadataFactory::free_array<Klass*>(loader_data, local_interfaces);
    1.28    }
    1.29  }
    1.30 @@ -380,21 +382,25 @@
    1.31    deallocate_methods(loader_data, methods());
    1.32    set_methods(NULL);
    1.33  
    1.34 -  if (method_ordering() != Universe::the_empty_int_array()) {
    1.35 +  if (method_ordering() != NULL &&
    1.36 +      method_ordering() != Universe::the_empty_int_array() &&
    1.37 +      !method_ordering()->is_shared()) {
    1.38      MetadataFactory::free_array<int>(loader_data, method_ordering());
    1.39    }
    1.40    set_method_ordering(NULL);
    1.41  
    1.42    // default methods can be empty
    1.43    if (default_methods() != NULL &&
    1.44 -      default_methods() != Universe::the_empty_method_array()) {
    1.45 +      default_methods() != Universe::the_empty_method_array() &&
    1.46 +      !default_methods()->is_shared()) {
    1.47      MetadataFactory::free_array<Method*>(loader_data, default_methods());
    1.48    }
    1.49    // Do NOT deallocate the default methods, they are owned by superinterfaces.
    1.50    set_default_methods(NULL);
    1.51  
    1.52    // default methods vtable indices can be empty
    1.53 -  if (default_vtable_indices() != NULL) {
    1.54 +  if (default_vtable_indices() != NULL &&
    1.55 +      !default_vtable_indices()->is_shared()) {
    1.56      MetadataFactory::free_array<int>(loader_data, default_vtable_indices());
    1.57    }
    1.58    set_default_vtable_indices(NULL);
    1.59 @@ -403,8 +409,10 @@
    1.60    // This array is in Klass, but remove it with the InstanceKlass since
    1.61    // this place would be the only caller and it can share memory with transitive
    1.62    // interfaces.
    1.63 -  if (secondary_supers() != Universe::the_empty_klass_array() &&
    1.64 -      secondary_supers() != transitive_interfaces()) {
    1.65 +  if (secondary_supers() != NULL &&
    1.66 +      secondary_supers() != Universe::the_empty_klass_array() &&
    1.67 +      secondary_supers() != transitive_interfaces() &&
    1.68 +      !secondary_supers()->is_shared()) {
    1.69      MetadataFactory::free_array<Klass*>(loader_data, secondary_supers());
    1.70    }
    1.71    set_secondary_supers(NULL);
    1.72 @@ -413,24 +421,32 @@
    1.73    set_transitive_interfaces(NULL);
    1.74    set_local_interfaces(NULL);
    1.75  
    1.76 -  MetadataFactory::free_array<jushort>(loader_data, fields());
    1.77 +  if (fields() != NULL && !fields()->is_shared()) {
    1.78 +    MetadataFactory::free_array<jushort>(loader_data, fields());
    1.79 +  }
    1.80    set_fields(NULL, 0);
    1.81  
    1.82    // If a method from a redefined class is using this constant pool, don't
    1.83    // delete it, yet.  The new class's previous version will point to this.
    1.84    if (constants() != NULL) {
    1.85      assert (!constants()->on_stack(), "shouldn't be called if anything is onstack");
    1.86 -    MetadataFactory::free_metadata(loader_data, constants());
    1.87 +    if (!constants()->is_shared()) {
    1.88 +      MetadataFactory::free_metadata(loader_data, constants());
    1.89 +    }
    1.90      set_constants(NULL);
    1.91    }
    1.92  
    1.93 -  if (inner_classes() != Universe::the_empty_short_array()) {
    1.94 +  if (inner_classes() != NULL &&
    1.95 +      inner_classes() != Universe::the_empty_short_array() &&
    1.96 +      !inner_classes()->is_shared()) {
    1.97      MetadataFactory::free_array<jushort>(loader_data, inner_classes());
    1.98    }
    1.99    set_inner_classes(NULL);
   1.100  
   1.101 -  // We should deallocate the Annotations instance
   1.102 -  MetadataFactory::free_metadata(loader_data, annotations());
   1.103 +  // We should deallocate the Annotations instance if it's not in shared spaces.
   1.104 +  if (annotations() != NULL && !annotations()->is_shared()) {
   1.105 +    MetadataFactory::free_metadata(loader_data, annotations());
   1.106 +  }
   1.107    set_annotations(NULL);
   1.108  }
   1.109  

mercurial