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

David Holmes dholmes at openjdk.org
Mon Sep 9 03:27:05 UTC 2024


On Fri, 6 Sep 2024 19:51:18 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.
>
> Matias Saavedra Silva has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fixed conditional to check for is_deleted()

src/hotspot/share/oops/method.hpp line 853:

> 851:     Method* new_method = method_holder()->method_with_idnum(orig_method_idnum());
> 852:     assert(this != new_method, "sanity check");
> 853:     return (new_method == nullptr || is_deleted()) ? Universe::throw_no_such_method_error() : new_method;

I am still confused by the different possibilities here. Under what conditions will we get nullptr? Is it the case that `get_new_method` should only be called when `is_old()` is true? Can `is_old` and `is_deleted` be true at the same time?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20874#discussion_r1749507207


More information about the hotspot-dev mailing list