On Sun, 6 Sep 2026 10:34:15 GMT, Marius Hanl <[email protected]> wrote:
>> 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.
This is an easy optimization, so I added a class-associated cache.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/2015#discussion_r3944093391