src/share/vm/oops/method.cpp

changeset 5848
ac9cb1d5a202
parent 5792
510fbd28919c
child 6039
bd3237e0e18d
     1.1 --- a/src/share/vm/oops/method.cpp	Sun Oct 06 16:13:50 2013 +0200
     1.2 +++ b/src/share/vm/oops/method.cpp	Mon Oct 07 12:20:28 2013 -0400
     1.3 @@ -511,9 +511,9 @@
     1.4  
     1.5  bool Method::is_final_method(AccessFlags class_access_flags) const {
     1.6    // or "does_not_require_vtable_entry"
     1.7 -  // overpass can occur, is not final (reuses vtable entry)
     1.8 +  // default method or overpass can occur, is not final (reuses vtable entry)
     1.9    // private methods get vtable entries for backward class compatibility.
    1.10 -  if (is_overpass())  return false;
    1.11 +  if (is_overpass() || is_default_method())  return false;
    1.12    return is_final() || class_access_flags.is_final();
    1.13  }
    1.14  
    1.15 @@ -521,11 +521,24 @@
    1.16    return is_final_method(method_holder()->access_flags());
    1.17  }
    1.18  
    1.19 +bool Method::is_default_method() const {
    1.20 +  if (method_holder() != NULL &&
    1.21 +      method_holder()->is_interface() &&
    1.22 +      !is_abstract()) {
    1.23 +    return true;
    1.24 +  } else {
    1.25 +    return false;
    1.26 +  }
    1.27 +}
    1.28 +
    1.29  bool Method::can_be_statically_bound(AccessFlags class_access_flags) const {
    1.30    if (is_final_method(class_access_flags))  return true;
    1.31  #ifdef ASSERT
    1.32 +  ResourceMark rm;
    1.33    bool is_nonv = (vtable_index() == nonvirtual_vtable_index);
    1.34 -  if (class_access_flags.is_interface())  assert(is_nonv == is_static(), err_msg("is_nonv=%s", is_nonv));
    1.35 +  if (class_access_flags.is_interface()) {
    1.36 +      assert(is_nonv == is_static(), err_msg("is_nonv=%s", name_and_sig_as_C_string()));
    1.37 +  }
    1.38  #endif
    1.39    assert(valid_vtable_index() || valid_itable_index(), "method must be linked before we ask this question");
    1.40    return vtable_index() == nonvirtual_vtable_index;
    1.41 @@ -1371,7 +1384,8 @@
    1.42  }
    1.43  
    1.44  // This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
    1.45 -void Method::sort_methods(Array<Method*>* methods, bool idempotent) {
    1.46 +// default_methods also uses this without the ordering for fast find_method
    1.47 +void Method::sort_methods(Array<Method*>* methods, bool idempotent, bool set_idnums) {
    1.48    int length = methods->length();
    1.49    if (length > 1) {
    1.50      {
    1.51 @@ -1379,14 +1393,15 @@
    1.52        QuickSort::sort<Method*>(methods->data(), length, method_comparator, idempotent);
    1.53      }
    1.54      // Reset method ordering
    1.55 -    for (int i = 0; i < length; i++) {
    1.56 -      Method* m = methods->at(i);
    1.57 -      m->set_method_idnum(i);
    1.58 +    if (set_idnums) {
    1.59 +      for (int i = 0; i < length; i++) {
    1.60 +        Method* m = methods->at(i);
    1.61 +        m->set_method_idnum(i);
    1.62 +      }
    1.63      }
    1.64    }
    1.65  }
    1.66  
    1.67 -
    1.68  //-----------------------------------------------------------------------------------
    1.69  // Non-product code unless JVM/TI needs it
    1.70  

mercurial