hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
changeset 40635 22fa174b2af8
parent 38309 9b8e9c373740
child 42650 1f304d0c888b
equal deleted inserted replaced
40632:8cf7f396360e 40635:22fa174b2af8
   128       _res = JVMTI_ERROR_NULL_POINTER;
   128       _res = JVMTI_ERROR_NULL_POINTER;
   129       return false;
   129       return false;
   130     }
   130     }
   131 
   131 
   132     oop mirror = JNIHandles::resolve_non_null(_class_defs[i].klass);
   132     oop mirror = JNIHandles::resolve_non_null(_class_defs[i].klass);
   133     // classes for primitives and arrays cannot be redefined
   133     // classes for primitives and arrays and vm anonymous classes cannot be redefined
   134     // check here so following code can assume these classes are InstanceKlass
   134     // check here so following code can assume these classes are InstanceKlass
   135     if (!is_modifiable_class(mirror)) {
   135     if (!is_modifiable_class(mirror)) {
   136       _res = JVMTI_ERROR_UNMODIFIABLE_CLASS;
   136       _res = JVMTI_ERROR_UNMODIFIABLE_CLASS;
   137       return false;
   137       return false;
   138     }
   138     }
   248 bool VM_RedefineClasses::is_modifiable_class(oop klass_mirror) {
   248 bool VM_RedefineClasses::is_modifiable_class(oop klass_mirror) {
   249   // classes for primitives cannot be redefined
   249   // classes for primitives cannot be redefined
   250   if (java_lang_Class::is_primitive(klass_mirror)) {
   250   if (java_lang_Class::is_primitive(klass_mirror)) {
   251     return false;
   251     return false;
   252   }
   252   }
   253   Klass* the_class_oop = java_lang_Class::as_Klass(klass_mirror);
   253   Klass* k = java_lang_Class::as_Klass(klass_mirror);
   254   // classes for arrays cannot be redefined
   254   // classes for arrays cannot be redefined
   255   if (the_class_oop == NULL || !the_class_oop->is_instance_klass()) {
   255   if (k == NULL || !k->is_instance_klass()) {
       
   256     return false;
       
   257   }
       
   258 
       
   259   // Cannot redefine or retransform an anonymous class.
       
   260   if (InstanceKlass::cast(k)->is_anonymous()) {
   256     return false;
   261     return false;
   257   }
   262   }
   258   return true;
   263   return true;
   259 }
   264 }
   260 
   265