<Beans Dev> behavior of PropertyDescription.getReadMethod when is/get getters are provided

Dmitry Cherepanov dcherepanov at azul.com
Tue Mar 19 16:55:21 UTC 2019


Hello,

The behavior of PropertyDescription.getReadMethod() method changed for boolean properties when both “is” and “get” getters are provided in bean class.

The following sample demonstrates this issue
http://cr.openjdk.java.net/~dcherepanov/beans/BoolealPropertyTest/Test.java

For 8, getReadMethod() returns the “is” getter
Starting from 9, getReadMethod() returns the “get” getter

This seems to be a behavior change introduced by [1] for [2] in PropertyInfo.initialize() where the “get” getters (stored in this.readList) overwrite the “is” getter (stored in this.read).

I’m trying to understand if this behavior is covered by spec and after reading JavaBeans API specification (version 1.01, section “8.3.2 Boolean properties”)

-------------------------------------------------------------------------------------
This “is<PropertyName>” method may be provided instead of a “get<PropertyName>” method, or it may be provided in addition to a “get<PropertyName>” method. In either case, if the “is<PropertyName>” method is present for a boolean property then we will use the “is<PropertyName>” method to read the property value.
-------------------------------------------------------------------------------------

it seems like it’s covered and getReadMethod() should return the “is” getter in this case. I plan to file bug for this and prepare a patch (that would restore the behavior of getReadMethod()) but wanted to confirm the evaluation makes sense.

Thanks,

Dmitry

[1] http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/cf25509c9243#l4.72
[2] https://bugs.openjdk.java.net/browse/JDK-4058433



More information about the beans-dev mailing list