On Sun, 29 Nov 2026 23:30:08 GMT, David Holmes <[email protected]> wrote:
>> The raw `Method*` stored in `_all_mirandas` were unsafe as the `Method` >> could be reclaimed when class redefinition occurs. >> >> The original proposed fix was as follows: Using the code from >> `JfrMethodProcessor` we extracted a new helper class, `ProtectedMethods` to >> preserve the lifetime of the `Method`s whilst they are in use. This is used >> across classfile parsing, and was also needed in >> `JfrClassTransformer::create_new_instance_klass`. >> >> @mgronlun then suggested an alternative approach, used elsewhere in CFP and >> in JFR: track the klass and method id and only resolve the `Method*` when >> needed. That is the current approach and avoids touching any JFR code. >> >> The new test easily demonstrated the crash prior to the fix, running >> concurrent loads and redefinitions, over a 60 second timeframe. Due to the >> length of the test it is not run in tier1 but in tier2. >> >> Testing: >> - tiers 1-3 general testing >> - local testing >> >> I ran some of the classloading microbenchmarks and did not see any signs of >> there being additional overhead associated with the new code - of course it >> will be highly dependent on the number of interfaces encountered with >> default methods and the size of the classes involved. I'm also running some >> tests through our performance system. >> >> Thanks >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > David Holmes has updated the pull request incrementally with two additional > commits since the last revision: > > - Fix again > - Delete mis-merged changes src/hotspot/share/classfile/defaultMethods.hpp line 47: > 45: public: > 46: MirandaMethodRef(Method* m) > 47: : _holder(m->method_holder()), _method_id(m->method_idnum()) { } I'd make it explicit to use _orig_method_idnum here. In this particular case, method_idnum() works, but that is a consequence of dealing with interface methods (public and non-static). The fact that the JVM preserves _orig_method_id_num is central for this kind of lookup. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/34016#discussion_r4737077925
