On Sun, 6 Sep 2026 09:41:48 GMT, John Hendrikx <[email protected]> wrote:

>> Michael Strauß has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   cache negative declaringClass lookup
>
> modules/javafx.base/src/main/java/javafx/beans/property/ReadOnlyProperty.java 
> line 110:
> 
>> 108:         } while (beanClass != null);
>> 109: 
>> 110:         return null;
> 
> Is it perhaps an idea here to use a cache for this? Many properties over the 
> lifetime of an FX application will share the same bean class and name; 
> something like this:
> 
> 
> private static final ClassValue<ConcurrentHashMap<String, Class<?>>> CACHE = 
> new ClassValue<>() {
>     @Override
>     protected ConcurrentHashMap<String, Class<?>> computeValue(Class<?> 
> beanClass) {
>         return new ConcurrentHashMap<>();
>     }
> };
> 
> static Class<?> lookup(Class<?> beanClass, String propertyName) {
>     Class<?> result = CACHE.get(beanClass)
>         .computeIfAbsent(propertyName, name -> {
>             Class<?> found = findDeclaringClass(beanClass, name);
>             return found == null ? NOT_FOUND : found;
>         });
> 
>     return result != NOT_FOUND ? result : null;
> }
> 
> 
> The `ClassValue` is specifically intended for this kind of use.

Thats a good question. I understood this code as 'fallback, should usually not 
run' and then I think we don't need a cache, but Michael probably knows better.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2015#discussion_r3943677700

Reply via email to