10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/systemDictionary.hpp"
27 #include "classfile/vmSymbols.hpp"
28 #include "gc/shared/gcLocker.hpp"
29 #include "logging/log.hpp"
30 #include "memory/metaspaceShared.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "memory/universe.inline.hpp"
33 #include "oops/instanceKlass.hpp"
34 #include "oops/klassVtable.hpp"
35 #include "oops/method.hpp"
36 #include "oops/objArrayOop.hpp"
37 #include "oops/oop.inline.hpp"
38 #include "prims/jvm.h"
39 #include "runtime/arguments.hpp"
40 #include "runtime/handles.inline.hpp"
41 #include "utilities/copy.hpp"
42
43 inline InstanceKlass* klassVtable::ik() const {
44 return InstanceKlass::cast(_klass);
45 }
46
47 bool klassVtable::is_preinitialized_vtable() {
48 return _klass->is_shared() && !MetaspaceShared::remapped_readwrite();
49 }
285 // P1.C.m needs to override P1.A.m and can not override P2.B.m
286 // Therefore: all package private methods need their own vtable entries for
287 // them to be the root of an inheritance overriding decision
288 // Package private methods may also override other vtable entries
289 InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper, methodHandle target_method,
290 int vtable_index, Handle target_loader, Symbol* target_classname, Thread * THREAD) {
291 InstanceKlass* superk = initialsuper;
292 while (superk != NULL && superk->super() != NULL) {
293 InstanceKlass* supersuperklass = InstanceKlass::cast(superk->super());
294 klassVtable ssVtable = supersuperklass->vtable();
295 if (vtable_index < ssVtable.length()) {
296 Method* super_method = ssVtable.method_at(vtable_index);
297 #ifndef PRODUCT
298 Symbol* name= target_method()->name();
299 Symbol* signature = target_method()->signature();
300 assert(super_method->name() == name && super_method->signature() == signature, "vtable entry name/sig mismatch");
301 #endif
302 if (supersuperklass->is_override(super_method, target_loader, target_classname, THREAD)) {
303 if (log_develop_is_enabled(Trace, vtables)) {
304 ResourceMark rm(THREAD);
305 outputStream* logst = Log(vtables)::trace_stream();
306 char* sig = target_method()->name_and_sig_as_C_string();
307 logst->print("transitive overriding superclass %s with %s index %d, original flags: ",
308 supersuperklass->internal_name(),
309 sig, vtable_index);
310 super_method->print_linkage_flags(logst);
311 logst->print("overriders flags: ");
312 target_method->print_linkage_flags(logst);
313 logst->cr();
314 }
315
316 break; // return found superk
317 }
318 } else {
319 // super class has no vtable entry here, stop transitive search
320 superk = (InstanceKlass*)NULL;
321 break;
322 }
323 // if no override found yet, continue to search up
324 superk = superk->super() == NULL ? NULL : InstanceKlass::cast(superk->super());
325 }
326
327 return superk;
328 }
329
330 static void log_vtables(int i, bool overrides, methodHandle target_method,
331 Klass* target_klass, Method* super_method,
332 Thread* thread) {
333 #ifndef PRODUCT
334 if (log_develop_is_enabled(Trace, vtables)) {
335 ResourceMark rm(thread);
336 outputStream* logst = Log(vtables)::trace_stream();
337 char* sig = target_method()->name_and_sig_as_C_string();
338 if (overrides) {
339 logst->print("overriding with %s index %d, original flags: ",
340 sig, i);
341 } else {
342 logst->print("NOT overriding with %s index %d, original flags: ",
343 sig, i);
344 }
345 super_method->print_linkage_flags(logst);
346 logst->print("overriders flags: ");
347 target_method->print_linkage_flags(logst);
348 logst->cr();
349 }
350 #endif
351 }
352
353 // Update child's copy of super vtable for overrides
354 // OR return true if a new vtable entry is required.
355 // Only called for InstanceKlass's, i.e. not for arrays
356 // If that changed, could not use _klass as handle for klass
357 bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle target_method,
358 int super_vtable_len, int default_index,
359 bool checkconstraints, TRAPS) {
360 ResourceMark rm;
361 bool allocate_new = true;
362 assert(klass->is_instance_klass(), "must be InstanceKlass");
363
364 Array<int>* def_vtable_indices = NULL;
365 bool is_default = false;
366
367 // default methods are non-private concrete methods in superinterfaces which are added
368 // to the vtable with their real method_holder.
534 } else {
535 overrides = false;
536 }
537 log_vtables(i, overrides, target_method, target_klass, super_method, THREAD);
538 }
539 }
540 return allocate_new;
541 }
542
543 void klassVtable::put_method_at(Method* m, int index) {
544 if (is_preinitialized_vtable()) {
545 // At runtime initialize_vtable is rerun as part of link_class_impl()
546 // for shared class loaded by the non-boot loader to obtain the loader
547 // constraints based on the runtime classloaders' context. The dumptime
548 // method at the vtable index should be the same as the runtime method.
549 assert(table()[index].method() == m,
550 "archived method is different from the runtime method");
551 } else {
552 if (log_develop_is_enabled(Trace, vtables)) {
553 ResourceMark rm;
554 outputStream* logst = Log(vtables)::trace_stream();
555 const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>";
556 logst->print("adding %s at index %d, flags: ", sig, index);
557 if (m != NULL) {
558 m->print_linkage_flags(logst);
559 }
560 logst->cr();
561 }
562 table()[index].set(m);
563 }
564 }
565
566 // Find out if a method "m" with superclass "super", loader "classloader" and
567 // name "classname" needs a new vtable entry. Let P be a class package defined
568 // by "classloader" and "classname".
569 // NOTE: The logic used here is very similar to the one used for computing
570 // the vtables indices for a method. We cannot directly use that function because,
571 // we allocate the InstanceKlass at load time, and that requires that the
572 // superclass has been loaded.
573 // However, the vtable entries are filled in at link time, and therefore
574 // the superclass' vtable may not yet have been filled in.
575 bool klassVtable::needs_new_vtable_entry(methodHandle target_method,
576 const Klass* super,
577 Handle classloader,
578 Symbol* classname,
579 AccessFlags class_flags,
580 u2 major_version,
868 add_new_mirandas_to_lists(new_mirandas, all_mirandas,
869 sik->methods(), class_methods,
870 default_methods, super);
871 }
872 }
873 }
874
875 // Discover miranda methods ("miranda" = "interface abstract, no binding"),
876 // and append them into the vtable starting at index initialized,
877 // return the new value of initialized.
878 // Miranda methods use vtable entries, but do not get assigned a vtable_index
879 // The vtable_index is discovered by searching from the end of the vtable
880 int klassVtable::fill_in_mirandas(int initialized) {
881 GrowableArray<Method*> mirandas(20);
882 get_mirandas(&mirandas, NULL, ik()->super(), ik()->methods(),
883 ik()->default_methods(), ik()->local_interfaces());
884 for (int i = 0; i < mirandas.length(); i++) {
885 if (log_develop_is_enabled(Trace, vtables)) {
886 Method* meth = mirandas.at(i);
887 ResourceMark rm(Thread::current());
888 outputStream* logst = Log(vtables)::trace_stream();
889 if (meth != NULL) {
890 char* sig = meth->name_and_sig_as_C_string();
891 logst->print("fill in mirandas with %s index %d, flags: ",
892 sig, initialized);
893 meth->print_linkage_flags(logst);
894 logst->cr();
895 }
896 }
897 put_method_at(mirandas.at(i), initialized);
898 ++initialized;
899 }
900 return initialized;
901 }
902
903 // Copy this class's vtable to the vtable beginning at start.
904 // Used to copy superclass vtable to prefix of subclass's vtable.
905 void klassVtable::copy_vtable_to(vtableEntry* start) {
906 Copy::disjoint_words((HeapWord*)table(), (HeapWord*)start, _length * vtableEntry::size());
907 }
908
909 #if INCLUDE_JVMTI
910 bool klassVtable::adjust_default_method(int vtable_index, Method* old_method, Method* new_method) {
911 // If old_method is default, find this vtable index in default_vtable_indices
912 // and replace that method in the _default_methods list
913 bool updated = false;
914
1100 // it should already have a vtable index, don't touch it.
1101 // e.g., CharSequence.toString (from initialize_vtable)
1102 // if (m->has_vtable_index()) return false; // NO!
1103 return true;
1104 }
1105
1106 int klassItable::assign_itable_indices_for_interface(Klass* klass) {
1107 // an interface does not have an itable, but its methods need to be numbered
1108 log_develop_debug(itables)("%3d: Initializing itable indices for interface %s",
1109 ++initialize_count, klass->name()->as_C_string());
1110 Array<Method*>* methods = InstanceKlass::cast(klass)->methods();
1111 int nof_methods = methods->length();
1112 int ime_num = 0;
1113 for (int i = 0; i < nof_methods; i++) {
1114 Method* m = methods->at(i);
1115 if (interface_method_needs_itable_index(m)) {
1116 assert(!m->is_final_method(), "no final interface methods");
1117 // If m is already assigned a vtable index, do not disturb it.
1118 if (log_develop_is_enabled(Trace, itables)) {
1119 ResourceMark rm;
1120 outputStream* logst = Log(itables)::trace_stream();
1121 assert(m != NULL, "methods can never be null");
1122 const char* sig = m->name_and_sig_as_C_string();
1123 if (m->has_vtable_index()) {
1124 logst->print("vtable index %d for method: %s, flags: ", m->vtable_index(), sig);
1125 } else {
1126 logst->print("itable index %d for method: %s, flags: ", ime_num, sig);
1127 }
1128 m->print_linkage_flags(logst);
1129 logst->cr();
1130 }
1131 if (!m->has_vtable_index()) {
1132 // A shared method could have an initialized itable_index that
1133 // is < 0.
1134 assert(m->vtable_index() == Method::pending_itable_index ||
1135 m->is_shared(),
1136 "set by initialize_vtable");
1137 m->set_itable_index(ime_num);
1138 // Progress to next itable entry
1139 ime_num++;
1140 }
1141 }
1142 }
1143 assert(ime_num == method_count_for_interface(klass), "proper sizing");
1144 return ime_num;
1145 }
1146
1147 int klassItable::method_count_for_interface(Klass* interf) {
1148 assert(interf->is_instance_klass(), "must be");
1149 assert(interf->is_interface(), "must be");
1220 char* iface = InstanceKlass::cast(interf)->name()->as_C_string();
1221 char* failed_type_name = failed_type_symbol->as_C_string();
1222 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
1223 strlen(current) + strlen(loader2) + strlen(iface) +
1224 strlen(failed_type_name);
1225 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
1226 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2,
1227 iface, failed_type_name);
1228 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
1229 }
1230 }
1231 }
1232
1233 // ime may have moved during GC so recalculate address
1234 int ime_num = m->itable_index();
1235 assert(ime_num < ime_count, "oob");
1236 itableOffsetEntry::method_entry(_klass, method_table_offset)[ime_num].initialize(target());
1237 if (log_develop_is_enabled(Trace, itables)) {
1238 ResourceMark rm(THREAD);
1239 if (target() != NULL) {
1240 outputStream* logst = Log(itables)::trace_stream();
1241 char* sig = target()->name_and_sig_as_C_string();
1242 logst->print("interface: %s, ime_num: %d, target: %s, method_holder: %s ",
1243 interf->internal_name(), ime_num, sig,
1244 target()->method_holder()->internal_name());
1245 logst->print("target_method flags: ");
1246 target()->print_linkage_flags(logst);
1247 logst->cr();
1248 }
1249 }
1250 }
1251 }
1252 }
1253
1254 #if INCLUDE_JVMTI
1255 // search the itable for uses of either obsolete or EMCP methods
1256 void klassItable::adjust_method_entries(InstanceKlass* holder, bool * trace_name_printed) {
1257
1258 itableMethodEntry* ime = method_entry(0);
1259 for (int i = 0; i < _size_method_table; i++, ime++) {
1260 Method* old_method = ime->method();
1261 if (old_method == NULL || old_method->method_holder() != holder || !old_method->is_old()) {
1262 continue; // skip uninteresting entries
1263 }
1264 assert(!old_method->is_deleted(), "itable methods may not be deleted");
1265
1266 Method* new_method = holder->method_with_idnum(old_method->orig_method_idnum());
1267
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/systemDictionary.hpp"
27 #include "classfile/vmSymbols.hpp"
28 #include "gc/shared/gcLocker.hpp"
29 #include "logging/log.hpp"
30 #include "logging/logStream.hpp"
31 #include "memory/metaspaceShared.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "memory/universe.inline.hpp"
34 #include "oops/instanceKlass.hpp"
35 #include "oops/klassVtable.hpp"
36 #include "oops/method.hpp"
37 #include "oops/objArrayOop.hpp"
38 #include "oops/oop.inline.hpp"
39 #include "prims/jvm.h"
40 #include "runtime/arguments.hpp"
41 #include "runtime/handles.inline.hpp"
42 #include "utilities/copy.hpp"
43
44 inline InstanceKlass* klassVtable::ik() const {
45 return InstanceKlass::cast(_klass);
46 }
47
48 bool klassVtable::is_preinitialized_vtable() {
49 return _klass->is_shared() && !MetaspaceShared::remapped_readwrite();
50 }
286 // P1.C.m needs to override P1.A.m and can not override P2.B.m
287 // Therefore: all package private methods need their own vtable entries for
288 // them to be the root of an inheritance overriding decision
289 // Package private methods may also override other vtable entries
290 InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper, methodHandle target_method,
291 int vtable_index, Handle target_loader, Symbol* target_classname, Thread * THREAD) {
292 InstanceKlass* superk = initialsuper;
293 while (superk != NULL && superk->super() != NULL) {
294 InstanceKlass* supersuperklass = InstanceKlass::cast(superk->super());
295 klassVtable ssVtable = supersuperklass->vtable();
296 if (vtable_index < ssVtable.length()) {
297 Method* super_method = ssVtable.method_at(vtable_index);
298 #ifndef PRODUCT
299 Symbol* name= target_method()->name();
300 Symbol* signature = target_method()->signature();
301 assert(super_method->name() == name && super_method->signature() == signature, "vtable entry name/sig mismatch");
302 #endif
303 if (supersuperklass->is_override(super_method, target_loader, target_classname, THREAD)) {
304 if (log_develop_is_enabled(Trace, vtables)) {
305 ResourceMark rm(THREAD);
306 LogTarget(Trace, vtables) lt;
307 LogStream ls(lt);
308 char* sig = target_method()->name_and_sig_as_C_string();
309 ls.print("transitive overriding superclass %s with %s index %d, original flags: ",
310 supersuperklass->internal_name(),
311 sig, vtable_index);
312 super_method->print_linkage_flags(&ls);
313 ls.print("overriders flags: ");
314 target_method->print_linkage_flags(&ls);
315 ls.cr();
316 }
317
318 break; // return found superk
319 }
320 } else {
321 // super class has no vtable entry here, stop transitive search
322 superk = (InstanceKlass*)NULL;
323 break;
324 }
325 // if no override found yet, continue to search up
326 superk = superk->super() == NULL ? NULL : InstanceKlass::cast(superk->super());
327 }
328
329 return superk;
330 }
331
332 static void log_vtables(int i, bool overrides, methodHandle target_method,
333 Klass* target_klass, Method* super_method,
334 Thread* thread) {
335 #ifndef PRODUCT
336 if (log_develop_is_enabled(Trace, vtables)) {
337 ResourceMark rm(thread);
338 LogTarget(Trace, vtables) lt;
339 LogStream ls(lt);
340 char* sig = target_method()->name_and_sig_as_C_string();
341 if (overrides) {
342 ls.print("overriding with %s index %d, original flags: ",
343 sig, i);
344 } else {
345 ls.print("NOT overriding with %s index %d, original flags: ",
346 sig, i);
347 }
348 super_method->print_linkage_flags(&ls);
349 ls.print("overriders flags: ");
350 target_method->print_linkage_flags(&ls);
351 ls.cr();
352 }
353 #endif
354 }
355
356 // Update child's copy of super vtable for overrides
357 // OR return true if a new vtable entry is required.
358 // Only called for InstanceKlass's, i.e. not for arrays
359 // If that changed, could not use _klass as handle for klass
360 bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle target_method,
361 int super_vtable_len, int default_index,
362 bool checkconstraints, TRAPS) {
363 ResourceMark rm;
364 bool allocate_new = true;
365 assert(klass->is_instance_klass(), "must be InstanceKlass");
366
367 Array<int>* def_vtable_indices = NULL;
368 bool is_default = false;
369
370 // default methods are non-private concrete methods in superinterfaces which are added
371 // to the vtable with their real method_holder.
537 } else {
538 overrides = false;
539 }
540 log_vtables(i, overrides, target_method, target_klass, super_method, THREAD);
541 }
542 }
543 return allocate_new;
544 }
545
546 void klassVtable::put_method_at(Method* m, int index) {
547 if (is_preinitialized_vtable()) {
548 // At runtime initialize_vtable is rerun as part of link_class_impl()
549 // for shared class loaded by the non-boot loader to obtain the loader
550 // constraints based on the runtime classloaders' context. The dumptime
551 // method at the vtable index should be the same as the runtime method.
552 assert(table()[index].method() == m,
553 "archived method is different from the runtime method");
554 } else {
555 if (log_develop_is_enabled(Trace, vtables)) {
556 ResourceMark rm;
557 LogTarget(Trace, vtables) lt;
558 LogStream ls(lt);
559 const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>";
560 ls.print("adding %s at index %d, flags: ", sig, index);
561 if (m != NULL) {
562 m->print_linkage_flags(&ls);
563 }
564 ls.cr();
565 }
566 table()[index].set(m);
567 }
568 }
569
570 // Find out if a method "m" with superclass "super", loader "classloader" and
571 // name "classname" needs a new vtable entry. Let P be a class package defined
572 // by "classloader" and "classname".
573 // NOTE: The logic used here is very similar to the one used for computing
574 // the vtables indices for a method. We cannot directly use that function because,
575 // we allocate the InstanceKlass at load time, and that requires that the
576 // superclass has been loaded.
577 // However, the vtable entries are filled in at link time, and therefore
578 // the superclass' vtable may not yet have been filled in.
579 bool klassVtable::needs_new_vtable_entry(methodHandle target_method,
580 const Klass* super,
581 Handle classloader,
582 Symbol* classname,
583 AccessFlags class_flags,
584 u2 major_version,
872 add_new_mirandas_to_lists(new_mirandas, all_mirandas,
873 sik->methods(), class_methods,
874 default_methods, super);
875 }
876 }
877 }
878
879 // Discover miranda methods ("miranda" = "interface abstract, no binding"),
880 // and append them into the vtable starting at index initialized,
881 // return the new value of initialized.
882 // Miranda methods use vtable entries, but do not get assigned a vtable_index
883 // The vtable_index is discovered by searching from the end of the vtable
884 int klassVtable::fill_in_mirandas(int initialized) {
885 GrowableArray<Method*> mirandas(20);
886 get_mirandas(&mirandas, NULL, ik()->super(), ik()->methods(),
887 ik()->default_methods(), ik()->local_interfaces());
888 for (int i = 0; i < mirandas.length(); i++) {
889 if (log_develop_is_enabled(Trace, vtables)) {
890 Method* meth = mirandas.at(i);
891 ResourceMark rm(Thread::current());
892 LogTarget(Trace, vtables) lt;
893 LogStream ls(lt);
894 if (meth != NULL) {
895 char* sig = meth->name_and_sig_as_C_string();
896 ls.print("fill in mirandas with %s index %d, flags: ",
897 sig, initialized);
898 meth->print_linkage_flags(&ls);
899 ls.cr();
900 }
901 }
902 put_method_at(mirandas.at(i), initialized);
903 ++initialized;
904 }
905 return initialized;
906 }
907
908 // Copy this class's vtable to the vtable beginning at start.
909 // Used to copy superclass vtable to prefix of subclass's vtable.
910 void klassVtable::copy_vtable_to(vtableEntry* start) {
911 Copy::disjoint_words((HeapWord*)table(), (HeapWord*)start, _length * vtableEntry::size());
912 }
913
914 #if INCLUDE_JVMTI
915 bool klassVtable::adjust_default_method(int vtable_index, Method* old_method, Method* new_method) {
916 // If old_method is default, find this vtable index in default_vtable_indices
917 // and replace that method in the _default_methods list
918 bool updated = false;
919
1105 // it should already have a vtable index, don't touch it.
1106 // e.g., CharSequence.toString (from initialize_vtable)
1107 // if (m->has_vtable_index()) return false; // NO!
1108 return true;
1109 }
1110
1111 int klassItable::assign_itable_indices_for_interface(Klass* klass) {
1112 // an interface does not have an itable, but its methods need to be numbered
1113 log_develop_debug(itables)("%3d: Initializing itable indices for interface %s",
1114 ++initialize_count, klass->name()->as_C_string());
1115 Array<Method*>* methods = InstanceKlass::cast(klass)->methods();
1116 int nof_methods = methods->length();
1117 int ime_num = 0;
1118 for (int i = 0; i < nof_methods; i++) {
1119 Method* m = methods->at(i);
1120 if (interface_method_needs_itable_index(m)) {
1121 assert(!m->is_final_method(), "no final interface methods");
1122 // If m is already assigned a vtable index, do not disturb it.
1123 if (log_develop_is_enabled(Trace, itables)) {
1124 ResourceMark rm;
1125 LogTarget(Trace, itables) lt;
1126 LogStream ls(lt);
1127 assert(m != NULL, "methods can never be null");
1128 const char* sig = m->name_and_sig_as_C_string();
1129 if (m->has_vtable_index()) {
1130 ls.print("vtable index %d for method: %s, flags: ", m->vtable_index(), sig);
1131 } else {
1132 ls.print("itable index %d for method: %s, flags: ", ime_num, sig);
1133 }
1134 m->print_linkage_flags(&ls);
1135 ls.cr();
1136 }
1137 if (!m->has_vtable_index()) {
1138 // A shared method could have an initialized itable_index that
1139 // is < 0.
1140 assert(m->vtable_index() == Method::pending_itable_index ||
1141 m->is_shared(),
1142 "set by initialize_vtable");
1143 m->set_itable_index(ime_num);
1144 // Progress to next itable entry
1145 ime_num++;
1146 }
1147 }
1148 }
1149 assert(ime_num == method_count_for_interface(klass), "proper sizing");
1150 return ime_num;
1151 }
1152
1153 int klassItable::method_count_for_interface(Klass* interf) {
1154 assert(interf->is_instance_klass(), "must be");
1155 assert(interf->is_interface(), "must be");
1226 char* iface = InstanceKlass::cast(interf)->name()->as_C_string();
1227 char* failed_type_name = failed_type_symbol->as_C_string();
1228 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
1229 strlen(current) + strlen(loader2) + strlen(iface) +
1230 strlen(failed_type_name);
1231 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
1232 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2,
1233 iface, failed_type_name);
1234 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
1235 }
1236 }
1237 }
1238
1239 // ime may have moved during GC so recalculate address
1240 int ime_num = m->itable_index();
1241 assert(ime_num < ime_count, "oob");
1242 itableOffsetEntry::method_entry(_klass, method_table_offset)[ime_num].initialize(target());
1243 if (log_develop_is_enabled(Trace, itables)) {
1244 ResourceMark rm(THREAD);
1245 if (target() != NULL) {
1246 LogTarget(Trace, itables) lt;
1247 LogStream ls(lt);
1248 char* sig = target()->name_and_sig_as_C_string();
1249 ls.print("interface: %s, ime_num: %d, target: %s, method_holder: %s ",
1250 interf->internal_name(), ime_num, sig,
1251 target()->method_holder()->internal_name());
1252 ls.print("target_method flags: ");
1253 target()->print_linkage_flags(&ls);
1254 ls.cr();
1255 }
1256 }
1257 }
1258 }
1259 }
1260
1261 #if INCLUDE_JVMTI
1262 // search the itable for uses of either obsolete or EMCP methods
1263 void klassItable::adjust_method_entries(InstanceKlass* holder, bool * trace_name_printed) {
1264
1265 itableMethodEntry* ime = method_entry(0);
1266 for (int i = 0; i < _size_method_table; i++, ime++) {
1267 Method* old_method = ime->method();
1268 if (old_method == NULL || old_method->method_holder() != holder || !old_method->is_old()) {
1269 continue; // skip uninteresting entries
1270 }
1271 assert(!old_method->is_deleted(), "itable methods may not be deleted");
1272
1273 Method* new_method = holder->method_with_idnum(old_method->orig_method_idnum());
1274
|