< prev index next >

src/hotspot/share/prims/jvmtiRedefineClasses.cpp

Print this page
*** 607,12 ***
      case JVM_CONSTANT_Invalid: // fall through
  
      // At this stage, String could be here, but not StringIndex
      case JVM_CONSTANT_StringIndex: // fall through
  
!     // At this stage JVM_CONSTANT_UnresolvedClassInError should not be
-     // here
      case JVM_CONSTANT_UnresolvedClassInError: // fall through
  
      default:
      {
        // leave a breadcrumb
--- 607,11 ---
      case JVM_CONSTANT_Invalid: // fall through
  
      // At this stage, String could be here, but not StringIndex
      case JVM_CONSTANT_StringIndex: // fall through
  
!     // At this stage JVM_CONSTANT_UnresolvedClassInError should not be here
      case JVM_CONSTANT_UnresolvedClassInError: // fall through
  
      default:
      {
        // leave a breadcrumb

*** 920,10 ***
--- 919,22 ---
                                  the_class, scratch_class,
                                  the_class->permitted_subclasses(),
                                  scratch_class->permitted_subclasses());
  }
  
+ static jvmtiError check_preload_attribute(InstanceKlass* the_class,
+                                           InstanceKlass* scratch_class) {
+   Thread* thread = Thread::current();
+   ResourceMark rm(thread);
+ 
+   // Check whether the class Preload attribute has been changed.
+   return check_attribute_arrays("Preload",
+                                 the_class, scratch_class,
+                                 the_class->preload_classes(),
+                                 scratch_class->preload_classes());
+ }
+ 
  static bool can_add_or_delete(Method* m) {
        // Compatibility mode
    return (AllowRedefinitionToAddDeleteMethods &&
            (m->is_private() && (m->is_static() || m->is_final())));
  }

*** 999,10 ***
--- 1010,16 ---
    err = check_permitted_subclasses_attribute(the_class, scratch_class);
    if (err != JVMTI_ERROR_NONE) {
      return err;
    }
  
+   // Check whether the Preload attribute has been changed.
+   err = check_preload_attribute(the_class, scratch_class);
+   if (err != JVMTI_ERROR_NONE) {
+     return err;
+   }
+ 
    // Check whether class modifiers are the same.
    jushort old_flags = (jushort) the_class->access_flags().get_flags();
    jushort new_flags = (jushort) scratch_class->access_flags().get_flags();
    if (old_flags != new_flags) {
      log_info(redefine, class, normalize)

*** 1926,10 ***
--- 1943,16 ---
    if (!rewrite_cp_refs_in_permitted_subclasses_attribute(scratch_class)) {
      // propagate failure back to caller
      return false;
    }
  
+   // rewrite constant pool references in the Preload attribute:
+   if (!rewrite_cp_refs_in_preload_attribute(scratch_class)) {
+     // propagate failure back to caller
+     return false;
+   }
+ 
    // rewrite constant pool references in the methods:
    if (!rewrite_cp_refs_in_methods(scratch_class)) {
      // propagate failure back to caller
      return false;
    }

*** 2074,10 ***
--- 2097,23 ---
      permitted_subclasses->at_put(i, find_new_index(cp_index));
    }
    return true;
  }
  
+ // Rewrite constant pool references in the Preload attribute.
+ bool VM_RedefineClasses::rewrite_cp_refs_in_preload_attribute(
+        InstanceKlass* scratch_class) {
+ 
+   Array<u2>* preload_classes = scratch_class->preload_classes();
+   assert(preload_classes != nullptr, "unexpected null preload_classes");
+   for (int i = 0; i < preload_classes->length(); i++) {
+     u2 cp_index = preload_classes->at(i);
+     preload_classes->at_put(i, find_new_index(cp_index));
+   }
+   return true;
+ }
+ 
  // Rewrite constant pool references in the methods.
  bool VM_RedefineClasses::rewrite_cp_refs_in_methods(InstanceKlass* scratch_class) {
  
    Array<Method*>* methods = scratch_class->methods();
  
< prev index next >