[code-reflection] RFR: Method code model uniquness [v2]
Paul Sandoz
psandoz at openjdk.org
Tue Apr 29 16:34:00 UTC 2025
On Tue, 29 Apr 2025 12:10:34 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:
>> Multiple `Method` objects that represent the same java method, have different code models. This is because every time we call `Class.getMethod` or `Class.getDeclaredMethod` we get a newly created instance. One possible solution is to attach the model to the root `Method` object.
>
> Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision:
>
> Ensure instances that reflect the same method have the same model
Given the underlying root method is held in an instance of `ReflectionData` which in turn is held in a soft reference stored on the class we may not need to do anything specific to ensure code models don't hang around too long after they are no longer used. If we find we need to, e.g., because the non-root method instances are cached or something connected is, we can update to store the model in a weak reference. However, we probably need to do something like that for the code models of lambda expressions, when you get to that, and if so i think we should do so for both cases.
-------------
PR Review: https://git.openjdk.org/babylon/pull/415#pullrequestreview-2804224298
More information about the babylon-dev
mailing list