< prev index next >

src/hotspot/share/prims/jvmtiRedefineClasses.cpp

Print this page
*** 596,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
--- 596,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

*** 907,10 ***
--- 906,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())));
  }

*** 986,10 ***
--- 997,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)

*** 1951,10 ***
--- 1968,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;
    }

*** 2099,10 ***
--- 2122,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 != NULL, "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();
  

*** 2231,10 ***
--- 2267,12 ---
        // these bytecodes have a two-byte constant pool index
        case Bytecodes::_anewarray      : // fall through
        case Bytecodes::_checkcast      : // fall through
        case Bytecodes::_getfield       : // fall through
        case Bytecodes::_getstatic      : // fall through
+       case Bytecodes::_aconst_init   : // fall through
+       case Bytecodes::_withfield      : // fall through
        case Bytecodes::_instanceof     : // fall through
        case Bytecodes::_invokedynamic  : // fall through
        case Bytecodes::_invokeinterface: // fall through
        case Bytecodes::_invokespecial  : // fall through
        case Bytecodes::_invokestatic   : // fall through
< prev index next >