--- old/src/hotspot/share/oops/arrayKlass.cpp 2018-07-10 16:06:27.577630848 -0400 +++ new/src/hotspot/share/oops/arrayKlass.cpp 2018-07-10 16:06:25.860640476 -0400 @@ -100,7 +100,6 @@ // Initialization of vtables and mirror object is done separatly from base_create_array_klass, // since a GC can happen. At this point all instance variables of the ArrayKlass must be setup. void ArrayKlass::complete_create_array_klass(ArrayKlass* k, Klass* super_klass, ModuleEntry* module_entry, TRAPS) { - ResourceMark rm(THREAD); k->initialize_supers(super_klass, NULL, CHECK); k->vtable().initialize_vtable(false, CHECK); --- old/src/hotspot/share/oops/instanceKlass.cpp 2018-07-10 16:06:39.499944784 -0400 +++ new/src/hotspot/share/oops/instanceKlass.cpp 2018-07-10 16:06:37.748624418 -0400 @@ -821,7 +821,6 @@ ClassLoaderData * loader_data = class_loader_data(); if (!(is_shared() && loader_data->is_the_null_class_loader_data())) { - ResourceMark rm(THREAD); vtable().initialize_vtable(true, CHECK_false); itable().initialize_itable(true, CHECK_false); } @@ -2326,7 +2325,6 @@ // point to old or obsolete entries. RedefineClasses doesn't fix up // vtables in the shared system dictionary, only the main one. // It also redefines the itable too so fix that too. - ResourceMark rm(THREAD); vtable().initialize_vtable(false, CHECK); itable().initialize_itable(false, CHECK); } --- old/src/hotspot/share/oops/klassVtable.cpp 2018-07-10 16:06:51.527118584 -0400 +++ new/src/hotspot/share/oops/klassVtable.cpp 2018-07-10 16:06:49.881600852 -0400 @@ -257,7 +257,7 @@ // Interfaces do not need interface methods in their vtables // This includes miranda methods and during later processing, default methods if (!ik()->is_interface()) { - initialized = fill_in_mirandas(initialized); + initialized = fill_in_mirandas(initialized, THREAD); } // In class hierarchies where the accessibility is not increasing (i.e., going from private -> @@ -364,7 +364,7 @@ bool klassVtable::update_inherited_vtable(InstanceKlass* klass, const methodHandle& target_method, int super_vtable_len, int default_index, bool checkconstraints, TRAPS) { - ResourceMark rm; + ResourceMark rm(THREAD); bool allocate_new = true; assert(klass->is_instance_klass(), "must be InstanceKlass"); @@ -902,7 +902,8 @@ // return the new value of initialized. // Miranda methods use vtable entries, but do not get assigned a vtable_index // The vtable_index is discovered by searching from the end of the vtable -int klassVtable::fill_in_mirandas(int initialized) { +int klassVtable::fill_in_mirandas(int initialized, TRAPS) { + ResourceMark rm(THREAD); GrowableArray mirandas(20); get_mirandas(&mirandas, NULL, ik()->super(), ik()->methods(), ik()->default_methods(), ik()->local_interfaces(), @@ -910,7 +911,6 @@ for (int i = 0; i < mirandas.length(); i++) { if (log_develop_is_enabled(Trace, vtables)) { Method* meth = mirandas.at(i); - ResourceMark rm(Thread::current()); LogTarget(Trace, vtables) lt; LogStream ls(lt); if (meth != NULL) { @@ -1085,7 +1085,7 @@ if (_klass->is_interface()) { // This needs to go after vtable indices are assigned but // before implementors need to know the number of itable indices. - assign_itable_indices_for_interface(_klass); + assign_itable_indices_for_interface(_klass, THREAD); } // Cannot be setup doing bootstrapping, interfaces don't have @@ -1098,6 +1098,7 @@ guarantee(size_offset_table() >= 1, "too small"); int num_interfaces = size_offset_table() - 1; if (num_interfaces > 0) { + ResourceMark rm(THREAD); log_develop_debug(itables)("%3d: Initializing itables for %s", ++initialize_count, _klass->name()->as_C_string()); @@ -1130,8 +1131,9 @@ return true; } -int klassItable::assign_itable_indices_for_interface(Klass* klass) { +int klassItable::assign_itable_indices_for_interface(Klass* klass, TRAPS) { // an interface does not have an itable, but its methods need to be numbered + ResourceMark rm(THREAD); log_develop_debug(itables)("%3d: Initializing itable indices for interface %s", ++initialize_count, klass->name()->as_C_string()); Array* methods = InstanceKlass::cast(klass)->methods(); @@ -1143,7 +1145,6 @@ assert(!m->is_final_method(), "no final interface methods"); // If m is already assigned a vtable index, do not disturb it. if (log_develop_is_enabled(Trace, itables)) { - ResourceMark rm; LogTarget(Trace, itables) lt; LogStream ls(lt); assert(m != NULL, "methods can never be null"); @@ -1507,6 +1508,7 @@ oop* end_of_obj = (oop*)_klass + _klass->size(); oop* end_of_vtable = (oop *)&table()[_length]; if (end_of_vtable > end_of_obj) { + ResourceMark rm; fatal("klass %s: klass object too short (vtable extends beyond end)", _klass->internal_name()); } --- old/src/hotspot/share/oops/klassVtable.hpp 2018-07-10 16:07:04.192372117 -0400 +++ new/src/hotspot/share/oops/klassVtable.hpp 2018-07-10 16:07:02.806255135 -0400 @@ -141,7 +141,7 @@ // support for miranda methods bool is_miranda_entry_at(int i); - int fill_in_mirandas(int initialized); + int fill_in_mirandas(int initialized, TRAPS); static bool is_miranda(Method* m, Array* class_methods, Array* default_methods, const Klass* super, bool is_interface); @@ -328,7 +328,7 @@ #endif // INCLUDE_JVMTI // Setup of itable - static int assign_itable_indices_for_interface(Klass* klass); + static int assign_itable_indices_for_interface(Klass* klass, TRAPS); static int method_count_for_interface(Klass* klass); static int compute_itable_size(Array* transitive_interfaces); static void setup_itable_offset_table(InstanceKlass* klass); --- old/src/hotspot/share/prims/jvmtiRedefineClasses.cpp 2018-07-10 16:07:16.529806574 -0400 +++ new/src/hotspot/share/prims/jvmtiRedefineClasses.cpp 2018-07-10 16:07:14.651121348 -0400 @@ -4098,17 +4098,14 @@ // Initialize the vtable and interface table after // methods have been rewritten - { - ResourceMark rm(THREAD); - // no exception should happen here since we explicitly - // do not check loader constraints. - // compare_and_normalize_class_versions has already checked: - // - classloaders unchanged, signatures unchanged - // - all instanceKlasses for redefined classes reused & contents updated - the_class->vtable().initialize_vtable(false, THREAD); - the_class->itable().initialize_itable(false, THREAD); - assert(!HAS_PENDING_EXCEPTION || (THREAD->pending_exception()->is_a(SystemDictionary::ThreadDeath_klass())), "redefine exception"); - } + // no exception should happen here since we explicitly + // do not check loader constraints. + // compare_and_normalize_class_versions has already checked: + // - classloaders unchanged, signatures unchanged + // - all instanceKlasses for redefined classes reused & contents updated + the_class->vtable().initialize_vtable(false, THREAD); + the_class->itable().initialize_itable(false, THREAD); + assert(!HAS_PENDING_EXCEPTION || (THREAD->pending_exception()->is_a(SystemDictionary::ThreadDeath_klass())), "redefine exception"); // Leave arrays of jmethodIDs and itable index cache unchanged