comparison src/share/vm/prims/jvmtiRedefineClasses.hpp @ 10268:43083e670adf

8005056: NPG: Crash after redefining java.lang.Object Summary: Need to walk array class vtables replacing old methods too if j.l.o redefined Reviewed-by: sspitsyn, dcubed, ctornqvi
author coleenp
date Mon, 13 May 2013 15:37:08 -0400
parents 15a99ca4ee34
children 825e6cb66923
comparison
equal deleted inserted replaced
10267:8b40495b9381 10268:43083e670adf
85 // - replacing parts in the_class with parts from scratch_class 85 // - replacing parts in the_class with parts from scratch_class
86 // - adding weak reference(s) to track the obsolete but interesting 86 // - adding weak reference(s) to track the obsolete but interesting
87 // parts of the_class 87 // parts of the_class
88 // - adjusting constant pool caches and vtables in other classes 88 // - adjusting constant pool caches and vtables in other classes
89 // that refer to methods in the_class. These adjustments use the 89 // that refer to methods in the_class. These adjustments use the
90 // SystemDictionary::classes_do() facility which only allows 90 // ClassLoaderDataGraph::classes_do() facility which only allows
91 // a helper method to be specified. The interesting parameters 91 // a helper method to be specified. The interesting parameters
92 // that we would like to pass to the helper method are saved in 92 // that we would like to pass to the helper method are saved in
93 // static global fields in the VM operation. 93 // static global fields in the VM operation.
94 // - telling the SystemDictionary to notice our changes 94 // - telling the SystemDictionary to notice our changes
95 // 95 //
331 // coordinate a cleanup of these constants with Runtime. 331 // coordinate a cleanup of these constants with Runtime.
332 // 332 //
333 333
334 class VM_RedefineClasses: public VM_Operation { 334 class VM_RedefineClasses: public VM_Operation {
335 private: 335 private:
336 // These static fields are needed by SystemDictionary::classes_do() 336 // These static fields are needed by ClassLoaderDataGraph::classes_do()
337 // facility and the adjust_cpool_cache_and_vtable() helper: 337 // facility and the AdjustCpoolCacheAndVtable helper:
338 static Array<Method*>* _old_methods; 338 static Array<Method*>* _old_methods;
339 static Array<Method*>* _new_methods; 339 static Array<Method*>* _new_methods;
340 static Method** _matching_old_methods; 340 static Method** _matching_old_methods;
341 static Method** _matching_new_methods; 341 static Method** _matching_new_methods;
342 static Method** _deleted_methods; 342 static Method** _deleted_methods;
405 // used when information about the previous version of the_class 405 // used when information about the previous version of the_class
406 // is squirreled away. 406 // is squirreled away.
407 void check_methods_and_mark_as_obsolete(BitMap *emcp_methods, 407 void check_methods_and_mark_as_obsolete(BitMap *emcp_methods,
408 int * emcp_method_count_p); 408 int * emcp_method_count_p);
409 void transfer_old_native_function_registrations(instanceKlassHandle the_class); 409 void transfer_old_native_function_registrations(instanceKlassHandle the_class);
410
411 // Unevolving classes may point to methods of the_class directly
412 // from their constant pool caches, itables, and/or vtables. We
413 // use the SystemDictionary::classes_do() facility and this helper
414 // to fix up these pointers.
415 static void adjust_cpool_cache_and_vtable(Klass* k_oop, ClassLoaderData* initiating_loader, TRAPS);
416 static void adjust_array_vtable(Klass* k_oop);
417 410
418 // Install the redefinition of a class 411 // Install the redefinition of a class
419 void redefine_single_class(jclass the_jclass, 412 void redefine_single_class(jclass the_jclass,
420 Klass* scratch_class_oop, TRAPS); 413 Klass* scratch_class_oop, TRAPS);
421 414
478 instanceKlassHandle scratch_class, 471 instanceKlassHandle scratch_class,
479 constantPoolHandle scratch_cp, int scratch_cp_length, TRAPS); 472 constantPoolHandle scratch_cp, int scratch_cp_length, TRAPS);
480 473
481 void flush_dependent_code(instanceKlassHandle k_h, TRAPS); 474 void flush_dependent_code(instanceKlassHandle k_h, TRAPS);
482 475
483 static void check_class(Klass* k_oop, ClassLoaderData* initiating_loader,
484 TRAPS);
485 static void dump_methods(); 476 static void dump_methods();
477
478 // Check that there are no old or obsolete methods
479 class CheckClass : public KlassClosure {
480 Thread* _thread;
481 public:
482 CheckClass(Thread* t) : _thread(t) {}
483 void do_klass(Klass* k);
484 };
485
486 // Unevolving classes may point to methods of the_class directly
487 // from their constant pool caches, itables, and/or vtables. We
488 // use the ClassLoaderDataGraph::classes_do() facility and this helper
489 // to fix up these pointers.
490 class AdjustCpoolCacheAndVtable : public KlassClosure {
491 Thread* _thread;
492 public:
493 AdjustCpoolCacheAndVtable(Thread* t) : _thread(t) {}
494 void do_klass(Klass* k);
495 };
486 496
487 public: 497 public:
488 VM_RedefineClasses(jint class_count, 498 VM_RedefineClasses(jint class_count,
489 const jvmtiClassDefinition *class_defs, 499 const jvmtiClassDefinition *class_defs,
490 JvmtiClassLoadKind class_load_kind); 500 JvmtiClassLoadKind class_load_kind);