src/share/vm/oops/klassVtable.cpp

changeset 5848
ac9cb1d5a202
parent 5786
36b97be47bde
child 6080
fce21ac5968d
     1.1 --- a/src/share/vm/oops/klassVtable.cpp	Sun Oct 06 16:13:50 2013 +0200
     1.2 +++ b/src/share/vm/oops/klassVtable.cpp	Mon Oct 07 12:20:28 2013 -0400
     1.3 @@ -83,7 +83,7 @@
     1.4  
     1.5    GrowableArray<Method*> new_mirandas(20);
     1.6    // compute the number of mirandas methods that must be added to the end
     1.7 -  get_mirandas(&new_mirandas, all_mirandas, super, methods, local_interfaces);
     1.8 +  get_mirandas(&new_mirandas, all_mirandas, super, methods, NULL, local_interfaces);
     1.9    *num_new_mirandas = new_mirandas.length();
    1.10  
    1.11    vtable_length += *num_new_mirandas * vtableEntry::size();
    1.12 @@ -186,7 +186,7 @@
    1.13        assert(methods->at(i)->is_method(), "must be a Method*");
    1.14        methodHandle mh(THREAD, methods->at(i));
    1.15  
    1.16 -      bool needs_new_entry = update_inherited_vtable(ik(), mh, super_vtable_len, checkconstraints, CHECK);
    1.17 +      bool needs_new_entry = update_inherited_vtable(ik(), mh, super_vtable_len, -1, checkconstraints, CHECK);
    1.18  
    1.19        if (needs_new_entry) {
    1.20          put_method_at(mh(), initialized);
    1.21 @@ -195,7 +195,35 @@
    1.22        }
    1.23      }
    1.24  
    1.25 -    // add miranda methods to end of vtable.
    1.26 +    // update vtable with default_methods
    1.27 +    Array<Method*>* default_methods = ik()->default_methods();
    1.28 +    if (default_methods != NULL) {
    1.29 +      len = default_methods->length();
    1.30 +      if (len > 0) {
    1.31 +        Array<int>* def_vtable_indices = NULL;
    1.32 +        if ((def_vtable_indices = ik()->default_vtable_indices()) == NULL) {
    1.33 +          def_vtable_indices = ik()->create_new_default_vtable_indices(len, CHECK);
    1.34 +        } else {
    1.35 +          assert(def_vtable_indices->length() == len, "reinit vtable len?");
    1.36 +        }
    1.37 +        for (int i = 0; i < len; i++) {
    1.38 +          HandleMark hm(THREAD);
    1.39 +          assert(default_methods->at(i)->is_method(), "must be a Method*");
    1.40 +          methodHandle mh(THREAD, default_methods->at(i));
    1.41 +
    1.42 +          bool needs_new_entry = update_inherited_vtable(ik(), mh, super_vtable_len, i, checkconstraints, CHECK);
    1.43 +
    1.44 +          // needs new entry
    1.45 +          if (needs_new_entry) {
    1.46 +            put_method_at(mh(), initialized);
    1.47 +            def_vtable_indices->at_put(i, initialized); //set vtable index
    1.48 +            initialized++;
    1.49 +          }
    1.50 +        }
    1.51 +      }
    1.52 +    }
    1.53 +
    1.54 +    // add miranda methods; it will also return the updated initialized
    1.55      initialized = fill_in_mirandas(initialized);
    1.56  
    1.57      // In class hierarchies where the accessibility is not increasing (i.e., going from private ->
    1.58 @@ -230,14 +258,19 @@
    1.59  #ifndef PRODUCT
    1.60          if (PrintVtables && Verbose) {
    1.61            ResourceMark rm(THREAD);
    1.62 +          char* sig = target_method()->name_and_sig_as_C_string();
    1.63            tty->print("transitive overriding superclass %s with %s::%s index %d, original flags: ",
    1.64             supersuperklass->internal_name(),
    1.65 -           _klass->internal_name(), (target_method() != NULL) ?
    1.66 -           target_method()->name()->as_C_string() : "<NULL>", vtable_index);
    1.67 +           _klass->internal_name(), sig, vtable_index);
    1.68             super_method->access_flags().print_on(tty);
    1.69 +           if (super_method->is_default_method()) {
    1.70 +             tty->print("default");
    1.71 +           }
    1.72             tty->print("overriders flags: ");
    1.73             target_method->access_flags().print_on(tty);
    1.74 -           tty->cr();
    1.75 +           if (target_method->is_default_method()) {
    1.76 +             tty->print("default");
    1.77 +           }
    1.78          }
    1.79  #endif /*PRODUCT*/
    1.80          break; // return found superk
    1.81 @@ -258,16 +291,31 @@
    1.82  // OR return true if a new vtable entry is required.
    1.83  // Only called for InstanceKlass's, i.e. not for arrays
    1.84  // If that changed, could not use _klass as handle for klass
    1.85 -bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle target_method, int super_vtable_len,
    1.86 -                  bool checkconstraints, TRAPS) {
    1.87 +bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle target_method,
    1.88 +                                          int super_vtable_len, int default_index,
    1.89 +                                          bool checkconstraints, TRAPS) {
    1.90    ResourceMark rm;
    1.91    bool allocate_new = true;
    1.92    assert(klass->oop_is_instance(), "must be InstanceKlass");
    1.93 -  assert(klass == target_method()->method_holder(), "caller resp.");
    1.94  
    1.95 -  // Initialize the method's vtable index to "nonvirtual".
    1.96 -  // If we allocate a vtable entry, we will update it to a non-negative number.
    1.97 -  target_method()->set_vtable_index(Method::nonvirtual_vtable_index);
    1.98 +  Array<int>* def_vtable_indices = NULL;
    1.99 +  bool is_default = false;
   1.100 +  // default methods are concrete methods in superinterfaces which are added to the vtable
   1.101 +  // with their real method_holder
   1.102 +  // Since vtable and itable indices share the same storage, don't touch
   1.103 +  // the default method's real vtable/itable index
   1.104 +  // default_vtable_indices stores the vtable value relative to this inheritor
   1.105 +  if (default_index >= 0 ) {
   1.106 +    is_default = true;
   1.107 +    def_vtable_indices = klass->default_vtable_indices();
   1.108 +    assert(def_vtable_indices != NULL, "def vtable alloc?");
   1.109 +    assert(default_index <= def_vtable_indices->length(), "def vtable len?");
   1.110 +  } else {
   1.111 +    assert(klass == target_method()->method_holder(), "caller resp.");
   1.112 +    // Initialize the method's vtable index to "nonvirtual".
   1.113 +    // If we allocate a vtable entry, we will update it to a non-negative number.
   1.114 +    target_method()->set_vtable_index(Method::nonvirtual_vtable_index);
   1.115 +  }
   1.116  
   1.117    // Static and <init> methods are never in
   1.118    if (target_method()->is_static() || target_method()->name() ==  vmSymbols::object_initializer_name()) {
   1.119 @@ -284,6 +332,8 @@
   1.120      // An interface never allocates new vtable slots, only inherits old ones.
   1.121      // This method will either be assigned its own itable index later,
   1.122      // or be assigned an inherited vtable index in the loop below.
   1.123 +    // default methods store their vtable indices in the inheritors default_vtable_indices
   1.124 +    assert (default_index == -1, "interfaces don't store resolved default methods");
   1.125      target_method()->set_vtable_index(Method::pending_itable_index);
   1.126    }
   1.127  
   1.128 @@ -307,8 +357,15 @@
   1.129  
   1.130    Symbol* name = target_method()->name();
   1.131    Symbol* signature = target_method()->signature();
   1.132 -  Handle target_loader(THREAD, _klass()->class_loader());
   1.133 -  Symbol*  target_classname = _klass->name();
   1.134 +
   1.135 +  KlassHandle target_klass(THREAD, target_method()->method_holder());
   1.136 +  if (target_klass == NULL) {
   1.137 +    target_klass = _klass;
   1.138 +  }
   1.139 +
   1.140 +  Handle target_loader(THREAD, target_klass->class_loader());
   1.141 +
   1.142 +  Symbol* target_classname = target_klass->name();
   1.143    for(int i = 0; i < super_vtable_len; i++) {
   1.144      Method* super_method = method_at(i);
   1.145      // Check if method name matches
   1.146 @@ -317,10 +374,14 @@
   1.147        // get super_klass for method_holder for the found method
   1.148        InstanceKlass* super_klass =  super_method->method_holder();
   1.149  
   1.150 -      if ((super_klass->is_override(super_method, target_loader, target_classname, THREAD)) ||
   1.151 -      ((klass->major_version() >= VTABLE_TRANSITIVE_OVERRIDE_VERSION)
   1.152 -        && ((super_klass = find_transitive_override(super_klass, target_method, i, target_loader,
   1.153 -             target_classname, THREAD)) != (InstanceKlass*)NULL))) {
   1.154 +      if (is_default
   1.155 +          || ((super_klass->is_override(super_method, target_loader, target_classname, THREAD))
   1.156 +          || ((klass->major_version() >= VTABLE_TRANSITIVE_OVERRIDE_VERSION)
   1.157 +          && ((super_klass = find_transitive_override(super_klass,
   1.158 +                             target_method, i, target_loader,
   1.159 +                             target_classname, THREAD))
   1.160 +                             != (InstanceKlass*)NULL))))
   1.161 +        {
   1.162          // overriding, so no new entry
   1.163          allocate_new = false;
   1.164  
   1.165 @@ -347,7 +408,7 @@
   1.166                  "%s used in the signature";
   1.167                char* sig = target_method()->name_and_sig_as_C_string();
   1.168                const char* loader1 = SystemDictionary::loader_name(target_loader());
   1.169 -              char* current = _klass->name()->as_C_string();
   1.170 +              char* current = target_klass->name()->as_C_string();
   1.171                const char* loader2 = SystemDictionary::loader_name(super_loader());
   1.172                char* failed_type_name = failed_type_symbol->as_C_string();
   1.173                size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
   1.174 @@ -360,16 +421,39 @@
   1.175            }
   1.176         }
   1.177  
   1.178 -        put_method_at(target_method(), i);
   1.179 -        target_method()->set_vtable_index(i);
   1.180 +       put_method_at(target_method(), i);
   1.181 +       if (!is_default) {
   1.182 +         target_method()->set_vtable_index(i);
   1.183 +       } else {
   1.184 +         if (def_vtable_indices != NULL) {
   1.185 +           def_vtable_indices->at_put(default_index, i);
   1.186 +         }
   1.187 +         assert(super_method->is_default_method() || super_method->is_overpass()
   1.188 +                || super_method->is_abstract(), "default override error");
   1.189 +       }
   1.190 +
   1.191 +
   1.192  #ifndef PRODUCT
   1.193          if (PrintVtables && Verbose) {
   1.194 +          ResourceMark rm(THREAD);
   1.195 +          char* sig = target_method()->name_and_sig_as_C_string();
   1.196            tty->print("overriding with %s::%s index %d, original flags: ",
   1.197 -           _klass->internal_name(), (target_method() != NULL) ?
   1.198 -           target_method()->name()->as_C_string() : "<NULL>", i);
   1.199 +           target_klass->internal_name(), sig, i);
   1.200             super_method->access_flags().print_on(tty);
   1.201 +           if (super_method->is_default_method()) {
   1.202 +             tty->print("default");
   1.203 +           }
   1.204 +           if (super_method->is_overpass()) {
   1.205 +             tty->print("overpass");
   1.206 +           }
   1.207             tty->print("overriders flags: ");
   1.208             target_method->access_flags().print_on(tty);
   1.209 +           if (target_method->is_default_method()) {
   1.210 +             tty->print("default");
   1.211 +           }
   1.212 +           if (target_method->is_overpass()) {
   1.213 +             tty->print("overpass");
   1.214 +           }
   1.215             tty->cr();
   1.216          }
   1.217  #endif /*PRODUCT*/
   1.218 @@ -378,12 +462,25 @@
   1.219          // but not override another. Once we override one, not need new
   1.220  #ifndef PRODUCT
   1.221          if (PrintVtables && Verbose) {
   1.222 +          ResourceMark rm(THREAD);
   1.223 +          char* sig = target_method()->name_and_sig_as_C_string();
   1.224            tty->print("NOT overriding with %s::%s index %d, original flags: ",
   1.225 -           _klass->internal_name(), (target_method() != NULL) ?
   1.226 -           target_method()->name()->as_C_string() : "<NULL>", i);
   1.227 +           target_klass->internal_name(), sig,i);
   1.228             super_method->access_flags().print_on(tty);
   1.229 +           if (super_method->is_default_method()) {
   1.230 +             tty->print("default");
   1.231 +           }
   1.232 +           if (super_method->is_overpass()) {
   1.233 +             tty->print("overpass");
   1.234 +           }
   1.235             tty->print("overriders flags: ");
   1.236             target_method->access_flags().print_on(tty);
   1.237 +           if (target_method->is_default_method()) {
   1.238 +             tty->print("default");
   1.239 +           }
   1.240 +           if (target_method->is_overpass()) {
   1.241 +             tty->print("overpass");
   1.242 +           }
   1.243             tty->cr();
   1.244          }
   1.245  #endif /*PRODUCT*/
   1.246 @@ -438,6 +535,14 @@
   1.247      return false;
   1.248    }
   1.249  
   1.250 +  // Concrete interface methods do not need new entries, they override
   1.251 +  // abstract method entries using default inheritance rules
   1.252 +  if (target_method()->method_holder() != NULL &&
   1.253 +      target_method()->method_holder()->is_interface()  &&
   1.254 +      !target_method()->is_abstract() ) {
   1.255 +    return false;
   1.256 +  }
   1.257 +
   1.258    // we need a new entry if there is no superclass
   1.259    if (super == NULL) {
   1.260      return true;
   1.261 @@ -446,7 +551,7 @@
   1.262    // private methods in classes always have a new entry in the vtable
   1.263    // specification interpretation since classic has
   1.264    // private methods not overriding
   1.265 -  // JDK8 adds private methods in interfaces which require invokespecial
   1.266 +  // JDK8 adds private  methods in interfaces which require invokespecial
   1.267    if (target_method()->is_private()) {
   1.268      return true;
   1.269    }
   1.270 @@ -526,35 +631,40 @@
   1.271    if (mhk->is_interface()) {
   1.272      assert(m->is_public(), "should be public");
   1.273      assert(ik()->implements_interface(method_holder) , "this class should implement the interface");
   1.274 -    assert(is_miranda(m, ik()->methods(), ik()->super()), "should be a miranda_method");
   1.275 +    assert(is_miranda(m, ik()->methods(), ik()->default_methods(), ik()->super()), "should be a miranda_method");
   1.276      return true;
   1.277    }
   1.278    return false;
   1.279  }
   1.280  
   1.281 -// check if a method is a miranda method, given a class's methods table and its super
   1.282 -// "miranda" means not static, not defined by this class, and not defined
   1.283 -// in super unless it is private and therefore inaccessible to this class.
   1.284 +// check if a method is a miranda method, given a class's methods table,
   1.285 +// its default_method table  and its super
   1.286 +// "miranda" means not static, not defined by this class.
   1.287 +// private methods in interfaces do not belong in the miranda list.
   1.288  // the caller must make sure that the method belongs to an interface implemented by the class
   1.289  // Miranda methods only include public interface instance methods
   1.290 -// Not private methods, not static methods, not default = concrete abstract
   1.291 -bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods, Klass* super) {
   1.292 -  if (m->is_static()) {
   1.293 +// Not private methods, not static methods, not default == concrete abstract
   1.294 +bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods,
   1.295 +                             Array<Method*>* default_methods, Klass* super) {
   1.296 +  if (m->is_static() || m->is_private()) {
   1.297      return false;
   1.298    }
   1.299    Symbol* name = m->name();
   1.300    Symbol* signature = m->signature();
   1.301    if (InstanceKlass::find_method(class_methods, name, signature) == NULL) {
   1.302      // did not find it in the method table of the current class
   1.303 -    if (super == NULL) {
   1.304 -      // super doesn't exist
   1.305 -      return true;
   1.306 -    }
   1.307 +    if ((default_methods == NULL) ||
   1.308 +        InstanceKlass::find_method(default_methods, name, signature) == NULL) {
   1.309 +      if (super == NULL) {
   1.310 +        // super doesn't exist
   1.311 +        return true;
   1.312 +      }
   1.313  
   1.314 -    Method* mo = InstanceKlass::cast(super)->lookup_method(name, signature);
   1.315 -    if (mo == NULL || mo->access_flags().is_private() ) {
   1.316 -      // super class hierarchy does not implement it or protection is different
   1.317 -      return true;
   1.318 +      Method* mo = InstanceKlass::cast(super)->lookup_method(name, signature);
   1.319 +      if (mo == NULL || mo->access_flags().is_private() ) {
   1.320 +        // super class hierarchy does not implement it or protection is different
   1.321 +        return true;
   1.322 +      }
   1.323      }
   1.324    }
   1.325  
   1.326 @@ -562,7 +672,7 @@
   1.327  }
   1.328  
   1.329  // Scans current_interface_methods for miranda methods that do not
   1.330 -// already appear in new_mirandas and are also not defined-and-non-private
   1.331 +// already appear in new_mirandas, or default methods,  and are also not defined-and-non-private
   1.332  // in super (superclass).  These mirandas are added to all_mirandas if it is
   1.333  // not null; in addition, those that are not duplicates of miranda methods
   1.334  // inherited by super from its interfaces are added to new_mirandas.
   1.335 @@ -572,7 +682,8 @@
   1.336  void klassVtable::add_new_mirandas_to_lists(
   1.337      GrowableArray<Method*>* new_mirandas, GrowableArray<Method*>* all_mirandas,
   1.338      Array<Method*>* current_interface_methods, Array<Method*>* class_methods,
   1.339 -    Klass* super) {
   1.340 +    Array<Method*>* default_methods, Klass* super) {
   1.341 +
   1.342    // iterate thru the current interface's method to see if it a miranda
   1.343    int num_methods = current_interface_methods->length();
   1.344    for (int i = 0; i < num_methods; i++) {
   1.345 @@ -590,7 +701,7 @@
   1.346      }
   1.347  
   1.348      if (!is_duplicate) { // we don't want duplicate miranda entries in the vtable
   1.349 -      if (is_miranda(im, class_methods, super)) { // is it a miranda at all?
   1.350 +      if (is_miranda(im, class_methods, default_methods, super)) { // is it a miranda at all?
   1.351          InstanceKlass *sk = InstanceKlass::cast(super);
   1.352          // check if it is a duplicate of a super's miranda
   1.353          if (sk->lookup_method_in_all_interfaces(im->name(), im->signature()) == NULL) {
   1.354 @@ -607,6 +718,7 @@
   1.355  void klassVtable::get_mirandas(GrowableArray<Method*>* new_mirandas,
   1.356                                 GrowableArray<Method*>* all_mirandas,
   1.357                                 Klass* super, Array<Method*>* class_methods,
   1.358 +                               Array<Method*>* default_methods,
   1.359                                 Array<Klass*>* local_interfaces) {
   1.360    assert((new_mirandas->length() == 0) , "current mirandas must be 0");
   1.361  
   1.362 @@ -615,14 +727,16 @@
   1.363    for (int i = 0; i < num_local_ifs; i++) {
   1.364      InstanceKlass *ik = InstanceKlass::cast(local_interfaces->at(i));
   1.365      add_new_mirandas_to_lists(new_mirandas, all_mirandas,
   1.366 -                              ik->methods(), class_methods, super);
   1.367 +                              ik->methods(), class_methods,
   1.368 +                              default_methods, super);
   1.369      // iterate thru each local's super interfaces
   1.370      Array<Klass*>* super_ifs = ik->transitive_interfaces();
   1.371      int num_super_ifs = super_ifs->length();
   1.372      for (int j = 0; j < num_super_ifs; j++) {
   1.373        InstanceKlass *sik = InstanceKlass::cast(super_ifs->at(j));
   1.374        add_new_mirandas_to_lists(new_mirandas, all_mirandas,
   1.375 -                                sik->methods(), class_methods, super);
   1.376 +                                sik->methods(), class_methods,
   1.377 +                                default_methods, super);
   1.378      }
   1.379    }
   1.380  }
   1.381 @@ -633,8 +747,22 @@
   1.382  int klassVtable::fill_in_mirandas(int initialized) {
   1.383    GrowableArray<Method*> mirandas(20);
   1.384    get_mirandas(&mirandas, NULL, ik()->super(), ik()->methods(),
   1.385 -               ik()->local_interfaces());
   1.386 +               ik()->default_methods(), ik()->local_interfaces());
   1.387    for (int i = 0; i < mirandas.length(); i++) {
   1.388 +    if (PrintVtables && Verbose) {
   1.389 +      Method* meth = mirandas.at(i);
   1.390 +      ResourceMark rm(Thread::current());
   1.391 +      if (meth != NULL) {
   1.392 +        char* sig = meth->name_and_sig_as_C_string();
   1.393 +        tty->print("fill in mirandas with %s index %d, flags: ",
   1.394 +          sig, initialized);
   1.395 +        meth->access_flags().print_on(tty);
   1.396 +        if (meth->is_default_method()) {
   1.397 +          tty->print("default");
   1.398 +        }
   1.399 +        tty->cr();
   1.400 +      }
   1.401 +    }
   1.402      put_method_at(mirandas.at(i), initialized);
   1.403      ++initialized;
   1.404    }
   1.405 @@ -648,6 +776,26 @@
   1.406  }
   1.407  
   1.408  #if INCLUDE_JVMTI
   1.409 +bool klassVtable::adjust_default_method(int vtable_index, Method* old_method, Method* new_method) {
   1.410 +  // If old_method is default, find this vtable index in default_vtable_indices
   1.411 +  // and replace that method in the _default_methods list
   1.412 +  bool updated = false;
   1.413 +
   1.414 +  Array<Method*>* default_methods = ik()->default_methods();
   1.415 +  if (default_methods != NULL) {
   1.416 +    int len = default_methods->length();
   1.417 +    for (int idx = 0; idx < len; idx++) {
   1.418 +      if (vtable_index == ik()->default_vtable_indices()->at(idx)) {
   1.419 +        if (default_methods->at(idx) == old_method) {
   1.420 +          default_methods->at_put(idx, new_method);
   1.421 +          updated = true;
   1.422 +        }
   1.423 +        break;
   1.424 +      }
   1.425 +    }
   1.426 +  }
   1.427 +  return updated;
   1.428 +}
   1.429  void klassVtable::adjust_method_entries(Method** old_methods, Method** new_methods,
   1.430                                          int methods_length, bool * trace_name_printed) {
   1.431    // search the vtable for uses of either obsolete or EMCP methods
   1.432 @@ -663,18 +811,26 @@
   1.433      for (int index = 0; index < length(); index++) {
   1.434        if (unchecked_method_at(index) == old_method) {
   1.435          put_method_at(new_method, index);
   1.436 +          // For default methods, need to update the _default_methods array
   1.437 +          // which can only have one method entry for a given signature
   1.438 +          bool updated_default = false;
   1.439 +          if (old_method->is_default_method()) {
   1.440 +            updated_default = adjust_default_method(index, old_method, new_method);
   1.441 +          }
   1.442  
   1.443          if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
   1.444            if (!(*trace_name_printed)) {
   1.445              // RC_TRACE_MESG macro has an embedded ResourceMark
   1.446 -            RC_TRACE_MESG(("adjust: name=%s",
   1.447 +            RC_TRACE_MESG(("adjust: klassname=%s for methods from name=%s",
   1.448 +                           klass()->external_name(),
   1.449                             old_method->method_holder()->external_name()));
   1.450              *trace_name_printed = true;
   1.451            }
   1.452            // RC_TRACE macro has an embedded ResourceMark
   1.453 -          RC_TRACE(0x00100000, ("vtable method update: %s(%s)",
   1.454 +          RC_TRACE(0x00100000, ("vtable method update: %s(%s), updated default = %s",
   1.455                                  new_method->name()->as_C_string(),
   1.456 -                                new_method->signature()->as_C_string()));
   1.457 +                                new_method->signature()->as_C_string(),
   1.458 +                                updated_default ? "true" : "false"));
   1.459          }
   1.460          // cannot 'break' here; see for-loop comment above.
   1.461        }
   1.462 @@ -701,6 +857,12 @@
   1.463      if (m != NULL) {
   1.464        tty->print("      (%5d)  ", i);
   1.465        m->access_flags().print_on(tty);
   1.466 +      if (m->is_default_method()) {
   1.467 +        tty->print("default");
   1.468 +      }
   1.469 +      if (m->is_overpass()) {
   1.470 +        tty->print("overpass");
   1.471 +      }
   1.472        tty->print(" --  ");
   1.473        m->print_name(tty);
   1.474        tty->cr();
   1.475 @@ -757,9 +919,9 @@
   1.476  // Initialization
   1.477  void klassItable::initialize_itable(bool checkconstraints, TRAPS) {
   1.478    if (_klass->is_interface()) {
   1.479 -    // This needs to go after vtable indexes are assigned but
   1.480 -    // before implementors need to know the number of itable indexes.
   1.481 -    assign_itable_indexes_for_interface(_klass());
   1.482 +    // This needs to go after vtable indices are assigned but
   1.483 +    // before implementors need to know the number of itable indices.
   1.484 +    assign_itable_indices_for_interface(_klass());
   1.485    }
   1.486  
   1.487    // Cannot be setup doing bootstrapping, interfaces don't have
   1.488 @@ -803,7 +965,7 @@
   1.489    return true;
   1.490  }
   1.491  
   1.492 -int klassItable::assign_itable_indexes_for_interface(Klass* klass) {
   1.493 +int klassItable::assign_itable_indices_for_interface(Klass* klass) {
   1.494    // an interface does not have an itable, but its methods need to be numbered
   1.495    if (TraceItables) tty->print_cr("%3d: Initializing itable for interface %s", ++initialize_count,
   1.496                                    klass->name()->as_C_string());
   1.497 @@ -846,7 +1008,7 @@
   1.498      }
   1.499      nof_methods -= 1;
   1.500    }
   1.501 -  // no methods have itable indexes
   1.502 +  // no methods have itable indices
   1.503    return 0;
   1.504  }
   1.505  
   1.506 @@ -907,6 +1069,21 @@
   1.507        int ime_num = m->itable_index();
   1.508        assert(ime_num < ime_count, "oob");
   1.509        itableOffsetEntry::method_entry(_klass(), method_table_offset)[ime_num].initialize(target());
   1.510 +      if (TraceItables && Verbose) {
   1.511 +        ResourceMark rm(THREAD);
   1.512 +        if (target() != NULL) {
   1.513 +          char* sig = target()->name_and_sig_as_C_string();
   1.514 +          tty->print("interface: %s, ime_num: %d, target: %s, method_holder: %s ",
   1.515 +                    interf_h()->internal_name(), ime_num, sig,
   1.516 +                    target()->method_holder()->internal_name());
   1.517 +          tty->print("target_method flags: ");
   1.518 +          target()->access_flags().print_on(tty);
   1.519 +          if (target()->is_default_method()) {
   1.520 +            tty->print("default");
   1.521 +          }
   1.522 +          tty->cr();
   1.523 +        }
   1.524 +      }
   1.525      }
   1.526    }
   1.527  }
   1.528 @@ -980,6 +1157,9 @@
   1.529      if (m != NULL) {
   1.530        tty->print("      (%5d)  ", i);
   1.531        m->access_flags().print_on(tty);
   1.532 +      if (m->is_default_method()) {
   1.533 +        tty->print("default");
   1.534 +      }
   1.535        tty->print(" --  ");
   1.536        m->print_name(tty);
   1.537        tty->cr();
   1.538 @@ -1116,7 +1296,7 @@
   1.539    Array<Method*>* methods = InstanceKlass::cast(intf)->methods();
   1.540  
   1.541    if (itable_index < 0 || itable_index >= method_count_for_interface(intf))
   1.542 -    return NULL;                // help caller defend against bad indexes
   1.543 +    return NULL;                // help caller defend against bad indices
   1.544  
   1.545    int index = itable_index;
   1.546    Method* m = methods->at(index);

mercurial