[code-reflection] RFR: Method code model uniquness [v2]
    Maurizio Cimadamore 
    mcimadamore at openjdk.org
       
    Tue Apr 29 14:13:07 UTC 2025
    
    
  
On Tue, 29 Apr 2025 14:09:04 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> 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
>
> src/java.base/share/classes/java/lang/reflect/Method.java line 233:
> 
>> 231:     /* package */
>> 232:     Optional<?> setCodeModelIfNeeded(Function<Method, Optional<?>> modelFactory) {
>> 233:         Optional<?> localRef = root.codeModel;
> 
> I was looking at `Method` and found this method that does more or less a similar operation:
> 
> 
> // Accessor for generic info repository
>     @Override
>     MethodRepository getGenericInfo() {
>         var genericInfo = this.genericInfo;
>         if (genericInfo == null) {
>             var root = this.root;
>             if (root != null) {
>                 genericInfo = root.getGenericInfo();
>             } else {
>                 genericInfo = MethodRepository.make(getGenericSignature(), getFactory());
>             }
>             this.genericInfo = genericInfo;
>         }
>         return genericInfo;
>     }
> 
> 
> Should we copy/reuse same logic?
E.g. note that `root` can be null!
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/415#discussion_r2066621384
    
    
More information about the babylon-dev
mailing list