src/share/vm/prims/jvmtiRedefineClasses.cpp

changeset 4562
8d9fc28831cc
parent 4506
79c1bb8fce5d
child 4572
927a311d00f9
     1.1 --- a/src/share/vm/prims/jvmtiRedefineClasses.cpp	Tue Feb 05 00:59:40 2013 -0800
     1.2 +++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp	Wed Feb 06 14:31:37 2013 -0800
     1.3 @@ -154,8 +154,15 @@
     1.4    // See jvmtiExport.hpp for detailed explanation.
     1.5    JvmtiExport::set_has_redefined_a_class();
     1.6  
     1.7 -#ifdef ASSERT
     1.8 -  SystemDictionary::classes_do(check_class, thread);
     1.9 +// check_class() is optionally called for product bits, but is
    1.10 +// always called for non-product bits.
    1.11 +#ifdef PRODUCT
    1.12 +  if (RC_TRACE_ENABLED(0x00004000)) {
    1.13 +#endif
    1.14 +    RC_TRACE_WITH_THREAD(0x00004000, thread, ("calling check_class"));
    1.15 +    SystemDictionary::classes_do(check_class, thread);
    1.16 +#ifdef PRODUCT
    1.17 +  }
    1.18  #endif
    1.19  }
    1.20  
    1.21 @@ -1564,9 +1571,9 @@
    1.22              bcp, cp_index, new_index));
    1.23            // Rewriter::rewrite_method() uses put_native_u2() in this
    1.24            // situation because it is reusing the constant pool index
    1.25 -          // location for a native index into the constantPoolCache.
    1.26 +          // location for a native index into the ConstantPoolCache.
    1.27            // Since we are updating the constant pool index prior to
    1.28 -          // verification and constantPoolCache initialization, we
    1.29 +          // verification and ConstantPoolCache initialization, we
    1.30            // need to keep the new index in Java byte order.
    1.31            Bytes::put_Java_u2(p, new_index);
    1.32          }
    1.33 @@ -3371,7 +3378,6 @@
    1.34    }
    1.35  }
    1.36  
    1.37 -#ifndef PRODUCT
    1.38  void VM_RedefineClasses::check_class(Klass* k_oop,
    1.39                                       ClassLoaderData* initiating_loader,
    1.40                                       TRAPS) {
    1.41 @@ -3379,82 +3385,110 @@
    1.42    if (k->oop_is_instance()) {
    1.43      HandleMark hm(THREAD);
    1.44      InstanceKlass *ik = (InstanceKlass *) k;
    1.45 -
    1.46 -    if (ik->vtable_length() > 0) {
    1.47 -      ResourceMark rm(THREAD);
    1.48 -      if (!ik->vtable()->check_no_old_entries()) {
    1.49 -        tty->print_cr("klassVtable::check_no_old_entries failure -- OLD method found -- class: %s", ik->signature_name());
    1.50 +    bool no_old_methods = true;  // be optimistic
    1.51 +    ResourceMark rm(THREAD);
    1.52 +
    1.53 +    // a vtable should never contain old or obsolete methods
    1.54 +    if (ik->vtable_length() > 0 &&
    1.55 +        !ik->vtable()->check_no_old_or_obsolete_entries()) {
    1.56 +      if (RC_TRACE_ENABLED(0x00004000)) {
    1.57 +        RC_TRACE_WITH_THREAD(0x00004000, THREAD,
    1.58 +          ("klassVtable::check_no_old_or_obsolete_entries failure"
    1.59 +           " -- OLD or OBSOLETE method found -- class: %s",
    1.60 +           ik->signature_name()));
    1.61          ik->vtable()->dump_vtable();
    1.62 -        assert(false, "OLD method found");
    1.63        }
    1.64 +      no_old_methods = false;
    1.65      }
    1.66 -    if (ik->itable_length() > 0) {
    1.67 -      ResourceMark rm(THREAD);
    1.68 -      if (!ik->itable()->check_no_old_entries()) {
    1.69 -        tty->print_cr("klassItable::check_no_old_entries failure -- OLD method found -- class: %s", ik->signature_name());
    1.70 -        assert(false, "OLD method found");
    1.71 +
    1.72 +    // an itable should never contain old or obsolete methods
    1.73 +    if (ik->itable_length() > 0 &&
    1.74 +        !ik->itable()->check_no_old_or_obsolete_entries()) {
    1.75 +      if (RC_TRACE_ENABLED(0x00004000)) {
    1.76 +        RC_TRACE_WITH_THREAD(0x00004000, THREAD,
    1.77 +          ("klassItable::check_no_old_or_obsolete_entries failure"
    1.78 +           " -- OLD or OBSOLETE method found -- class: %s",
    1.79 +           ik->signature_name()));
    1.80 +        ik->itable()->dump_itable();
    1.81        }
    1.82 +      no_old_methods = false;
    1.83      }
    1.84 -    // Check that the constant pool cache has no deleted entries.
    1.85 +
    1.86 +    // the constant pool cache should never contain old or obsolete methods
    1.87      if (ik->constants() != NULL &&
    1.88          ik->constants()->cache() != NULL &&
    1.89 -       !ik->constants()->cache()->check_no_old_entries()) {
    1.90 -      tty->print_cr("klassVtable::check_no_old_entries failure -- OLD method found -- class: %s", ik->signature_name());
    1.91 -      assert(false, "OLD method found");
    1.92 +        !ik->constants()->cache()->check_no_old_or_obsolete_entries()) {
    1.93 +      if (RC_TRACE_ENABLED(0x00004000)) {
    1.94 +        RC_TRACE_WITH_THREAD(0x00004000, THREAD,
    1.95 +          ("cp-cache::check_no_old_or_obsolete_entries failure"
    1.96 +           " -- OLD or OBSOLETE method found -- class: %s",
    1.97 +           ik->signature_name()));
    1.98 +        ik->constants()->cache()->dump_cache();
    1.99 +      }
   1.100 +      no_old_methods = false;
   1.101 +    }
   1.102 +
   1.103 +    if (!no_old_methods) {
   1.104 +      if (RC_TRACE_ENABLED(0x00004000)) {
   1.105 +        dump_methods();
   1.106 +      } else {
   1.107 +        tty->print_cr("INFO: use the '-XX:TraceRedefineClasses=16384' option "
   1.108 +          "to see more info about the following guarantee() failure.");
   1.109 +      }
   1.110 +      guarantee(false, "OLD and/or OBSOLETE method(s) found");
   1.111      }
   1.112    }
   1.113  }
   1.114  
   1.115  void VM_RedefineClasses::dump_methods() {
   1.116 -        int j;
   1.117 -        tty->print_cr("_old_methods --");
   1.118 -        for (j = 0; j < _old_methods->length(); ++j) {
   1.119 -          Method* m = _old_methods->at(j);
   1.120 -          tty->print("%4d  (%5d)  ", j, m->vtable_index());
   1.121 -          m->access_flags().print_on(tty);
   1.122 -          tty->print(" --  ");
   1.123 -          m->print_name(tty);
   1.124 -          tty->cr();
   1.125 -        }
   1.126 -        tty->print_cr("_new_methods --");
   1.127 -        for (j = 0; j < _new_methods->length(); ++j) {
   1.128 -          Method* m = _new_methods->at(j);
   1.129 -          tty->print("%4d  (%5d)  ", j, m->vtable_index());
   1.130 -          m->access_flags().print_on(tty);
   1.131 -          tty->print(" --  ");
   1.132 -          m->print_name(tty);
   1.133 -          tty->cr();
   1.134 -        }
   1.135 -        tty->print_cr("_matching_(old/new)_methods --");
   1.136 -        for (j = 0; j < _matching_methods_length; ++j) {
   1.137 -          Method* m = _matching_old_methods[j];
   1.138 -          tty->print("%4d  (%5d)  ", j, m->vtable_index());
   1.139 -          m->access_flags().print_on(tty);
   1.140 -          tty->print(" --  ");
   1.141 -          m->print_name(tty);
   1.142 -          tty->cr();
   1.143 -          m = _matching_new_methods[j];
   1.144 -          tty->print("      (%5d)  ", m->vtable_index());
   1.145 -          m->access_flags().print_on(tty);
   1.146 -          tty->cr();
   1.147 -        }
   1.148 -        tty->print_cr("_deleted_methods --");
   1.149 -        for (j = 0; j < _deleted_methods_length; ++j) {
   1.150 -          Method* m = _deleted_methods[j];
   1.151 -          tty->print("%4d  (%5d)  ", j, m->vtable_index());
   1.152 -          m->access_flags().print_on(tty);
   1.153 -          tty->print(" --  ");
   1.154 -          m->print_name(tty);
   1.155 -          tty->cr();
   1.156 -        }
   1.157 -        tty->print_cr("_added_methods --");
   1.158 -        for (j = 0; j < _added_methods_length; ++j) {
   1.159 -          Method* m = _added_methods[j];
   1.160 -          tty->print("%4d  (%5d)  ", j, m->vtable_index());
   1.161 -          m->access_flags().print_on(tty);
   1.162 -          tty->print(" --  ");
   1.163 -          m->print_name(tty);
   1.164 -          tty->cr();
   1.165 -        }
   1.166 +  int j;
   1.167 +  RC_TRACE(0x00004000, ("_old_methods --"));
   1.168 +  for (j = 0; j < _old_methods->length(); ++j) {
   1.169 +    Method* m = _old_methods->at(j);
   1.170 +    RC_TRACE_NO_CR(0x00004000, ("%4d  (%5d)  ", j, m->vtable_index()));
   1.171 +    m->access_flags().print_on(tty);
   1.172 +    tty->print(" --  ");
   1.173 +    m->print_name(tty);
   1.174 +    tty->cr();
   1.175 +  }
   1.176 +  RC_TRACE(0x00004000, ("_new_methods --"));
   1.177 +  for (j = 0; j < _new_methods->length(); ++j) {
   1.178 +    Method* m = _new_methods->at(j);
   1.179 +    RC_TRACE_NO_CR(0x00004000, ("%4d  (%5d)  ", j, m->vtable_index()));
   1.180 +    m->access_flags().print_on(tty);
   1.181 +    tty->print(" --  ");
   1.182 +    m->print_name(tty);
   1.183 +    tty->cr();
   1.184 +  }
   1.185 +  RC_TRACE(0x00004000, ("_matching_(old/new)_methods --"));
   1.186 +  for (j = 0; j < _matching_methods_length; ++j) {
   1.187 +    Method* m = _matching_old_methods[j];
   1.188 +    RC_TRACE_NO_CR(0x00004000, ("%4d  (%5d)  ", j, m->vtable_index()));
   1.189 +    m->access_flags().print_on(tty);
   1.190 +    tty->print(" --  ");
   1.191 +    m->print_name(tty);
   1.192 +    tty->cr();
   1.193 +    m = _matching_new_methods[j];
   1.194 +    RC_TRACE_NO_CR(0x00004000, ("      (%5d)  ", m->vtable_index()));
   1.195 +    m->access_flags().print_on(tty);
   1.196 +    tty->cr();
   1.197 +  }
   1.198 +  RC_TRACE(0x00004000, ("_deleted_methods --"));
   1.199 +  for (j = 0; j < _deleted_methods_length; ++j) {
   1.200 +    Method* m = _deleted_methods[j];
   1.201 +    RC_TRACE_NO_CR(0x00004000, ("%4d  (%5d)  ", j, m->vtable_index()));
   1.202 +    m->access_flags().print_on(tty);
   1.203 +    tty->print(" --  ");
   1.204 +    m->print_name(tty);
   1.205 +    tty->cr();
   1.206 +  }
   1.207 +  RC_TRACE(0x00004000, ("_added_methods --"));
   1.208 +  for (j = 0; j < _added_methods_length; ++j) {
   1.209 +    Method* m = _added_methods[j];
   1.210 +    RC_TRACE_NO_CR(0x00004000, ("%4d  (%5d)  ", j, m->vtable_index()));
   1.211 +    m->access_flags().print_on(tty);
   1.212 +    tty->print(" --  ");
   1.213 +    m->print_name(tty);
   1.214 +    tty->cr();
   1.215 +  }
   1.216  }
   1.217 -#endif

mercurial