hotspot/src/share/vm/oops/method.cpp
changeset 20391 7b146c5ebb18
parent 20290 2127dc70bce9
child 21198 dd647e8d1d72
equal deleted inserted replaced
20390:a86c9ed78205 20391:7b146c5ebb18
   509   return _access_flags.has_loops();
   509   return _access_flags.has_loops();
   510 }
   510 }
   511 
   511 
   512 bool Method::is_final_method(AccessFlags class_access_flags) const {
   512 bool Method::is_final_method(AccessFlags class_access_flags) const {
   513   // or "does_not_require_vtable_entry"
   513   // or "does_not_require_vtable_entry"
   514   // overpass can occur, is not final (reuses vtable entry)
   514   // default method or overpass can occur, is not final (reuses vtable entry)
   515   // private methods get vtable entries for backward class compatibility.
   515   // private methods get vtable entries for backward class compatibility.
   516   if (is_overpass())  return false;
   516   if (is_overpass() || is_default_method())  return false;
   517   return is_final() || class_access_flags.is_final();
   517   return is_final() || class_access_flags.is_final();
   518 }
   518 }
   519 
   519 
   520 bool Method::is_final_method() const {
   520 bool Method::is_final_method() const {
   521   return is_final_method(method_holder()->access_flags());
   521   return is_final_method(method_holder()->access_flags());
       
   522 }
       
   523 
       
   524 bool Method::is_default_method() const {
       
   525   if (method_holder() != NULL &&
       
   526       method_holder()->is_interface() &&
       
   527       !is_abstract()) {
       
   528     return true;
       
   529   } else {
       
   530     return false;
       
   531   }
   522 }
   532 }
   523 
   533 
   524 bool Method::can_be_statically_bound(AccessFlags class_access_flags) const {
   534 bool Method::can_be_statically_bound(AccessFlags class_access_flags) const {
   525   if (is_final_method(class_access_flags))  return true;
   535   if (is_final_method(class_access_flags))  return true;
   526 #ifdef ASSERT
   536 #ifdef ASSERT
       
   537   ResourceMark rm;
   527   bool is_nonv = (vtable_index() == nonvirtual_vtable_index);
   538   bool is_nonv = (vtable_index() == nonvirtual_vtable_index);
   528   if (class_access_flags.is_interface())  assert(is_nonv == is_static(), err_msg("is_nonv=%s", is_nonv));
   539   if (class_access_flags.is_interface()) {
       
   540       assert(is_nonv == is_static(), err_msg("is_nonv=%s", name_and_sig_as_C_string()));
       
   541   }
   529 #endif
   542 #endif
   530   assert(valid_vtable_index() || valid_itable_index(), "method must be linked before we ask this question");
   543   assert(valid_vtable_index() || valid_itable_index(), "method must be linked before we ask this question");
   531   return vtable_index() == nonvirtual_vtable_index;
   544   return vtable_index() == nonvirtual_vtable_index;
   532 }
   545 }
   533 
   546 
  1369 static int method_comparator(Method* a, Method* b) {
  1382 static int method_comparator(Method* a, Method* b) {
  1370   return a->name()->fast_compare(b->name());
  1383   return a->name()->fast_compare(b->name());
  1371 }
  1384 }
  1372 
  1385 
  1373 // This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
  1386 // This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
  1374 void Method::sort_methods(Array<Method*>* methods, bool idempotent) {
  1387 // default_methods also uses this without the ordering for fast find_method
       
  1388 void Method::sort_methods(Array<Method*>* methods, bool idempotent, bool set_idnums) {
  1375   int length = methods->length();
  1389   int length = methods->length();
  1376   if (length > 1) {
  1390   if (length > 1) {
  1377     {
  1391     {
  1378       No_Safepoint_Verifier nsv;
  1392       No_Safepoint_Verifier nsv;
  1379       QuickSort::sort<Method*>(methods->data(), length, method_comparator, idempotent);
  1393       QuickSort::sort<Method*>(methods->data(), length, method_comparator, idempotent);
  1380     }
  1394     }
  1381     // Reset method ordering
  1395     // Reset method ordering
  1382     for (int i = 0; i < length; i++) {
  1396     if (set_idnums) {
  1383       Method* m = methods->at(i);
  1397       for (int i = 0; i < length; i++) {
  1384       m->set_method_idnum(i);
  1398         Method* m = methods->at(i);
  1385     }
  1399         m->set_method_idnum(i);
  1386   }
  1400       }
  1387 }
  1401     }
  1388 
  1402   }
       
  1403 }
  1389 
  1404 
  1390 //-----------------------------------------------------------------------------------
  1405 //-----------------------------------------------------------------------------------
  1391 // Non-product code unless JVM/TI needs it
  1406 // Non-product code unless JVM/TI needs it
  1392 
  1407 
  1393 #if !defined(PRODUCT) || INCLUDE_JVMTI
  1408 #if !defined(PRODUCT) || INCLUDE_JVMTI