RFR: 8338471: Refactor Method::get_new_method() for better NoSuchMethodError handling

Coleen Phillimore coleenp at openjdk.org
Fri Sep 6 13:14:49 UTC 2024


On Thu, 5 Sep 2024 18:56:19 GMT, Matias Saavedra Silva <matsaave at openjdk.org> wrote:

> This patch cleans up the use of `get_new_method()` so callers don't have to worry about throwing `NoSuchMethodError`. The method is refactored to throw the error and avoid ever returning nullptr. Verified with tier1-5 tests.

What should this return for a deleted method?

    // ------------------------------------------------------------------
    // ciMethod::equals
    //
    // Returns true if the methods are the same, taking redefined methods
    // into account.
    bool ciMethod::equals(const ciMethod* m) const {
      if (this == m) return true;
      VM_ENTRY_MARK;
      Method* m1 = this->get_Method();
      Method* m2 = m->get_Method();
      if (m1->is_old()) m1 = m1->get_new_method();
      if (m2->is_old()) m2 = m2->get_new_method();
      return m1 != Universe::no_such_method_error() && m1 == m2;  // ???
    }

-------------

PR Comment: https://git.openjdk.org/jdk/pull/20874#issuecomment-2334024871


More information about the hotspot-dev mailing list