[code-reflection] RFR: Method code model uniquness [v4]

Mourad Abbay mabbay at openjdk.org
Thu May 1 01:16:56 UTC 2025


On Wed, 30 Apr 2025 08:16:36 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Avoid caching Method.codeModel on non-root instances
>
> src/java.base/share/classes/java/lang/reflect/Method.java line 233:
> 
>> 231:     /* package */
>> 232:     Optional<?> setCodeModelIfNeeded(Function<Method, Optional<?>> modelFactory) {
>> 233:         if (root != null) {
> 
> This logic is subtly different to the one I pointed out -- this always recurse if the root is non null. The one I pointed out calls the method on the root, but than saves the result on the copy locally. I'm not sure which is better -- but it seems odd to use slightly different idioms in the same class to do effectively the same thing?

I applied the pattern you pointed out in the third commit. In this version I intentionally wanted to have the model stored in the root method, this way we only have one reference to the model.

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

PR Review Comment: https://git.openjdk.org/babylon/pull/415#discussion_r2069736239


More information about the babylon-dev mailing list