On Sat, 5 Sep 2026 12:19:38 GMT, Michael Strauß <[email protected]> wrote:
>> Implementation of [enhanced property >> metadata](https://gist.github.com/mstr2/2fec0303fc440b8eaeb126befc76eb5c). >> >> ### New API >> This PR includes the following API additions: >> >> 1. `ReadOnlyProperty.getDeclaringClass()` and its default implementation. >> 2. The `javafx.beans.property.AttachedProperty` interface. >> 3. New constructors for all `Simple<*>Property` and `ReadOnly<*>Wrapper` >> classes, accepting the declaring class of the property. >> >> The declaring class is stored in a new field in the `Simple<*>Property` >> classes. If a legacy constructor is used that doesn't specify the declaring >> class, the `ReadOnlyProperty.getDeclaringClass()` default implementation is >> called the first time the `Simple<*>Property.getDeclaringClass()` method is >> called, and its result is stored for future retrieval. >> >> ### Testing >> For testing, this PR also includes the >> `test.util.property.PropertyMetadataVerifier` tool. It systematically tests >> all public and protected properties of a class, and ensures conformance to >> the following rules: >> * `ReadOnlyProperty.getBean()` returns the object instance of the enclosing >> class, or the target object instance if the property is an attached property. >> * `ReadOnlyProperty.getName()` returns the name of the property, which must >> correspond to the name of the property getter (excluding the word >> "Property"). >> * `ReadOnlyProperty.getDeclaringClass()` returns the enclosing class of the >> property getter. >> * The declaring class of a `Simple<*>Property` or `ReadOnly<*>Wrapper` must >> be specified in the constructor, not resolved at runtime. >> * `getBean()`, `getName()`, and `getDeclaringClass()` must not be overridden >> in subclasses of `Simple<*>Property` or `ReadOnly<*>Wrapper`. >> * An instance property does not implement `AttachedProperty`. >> * An instance property has a parameterless property getter. >> * An attached property implements `AttachedProperty`. >> * An attached property has a static single-argument property getter that >> accepts the target object. >> * `AttachedProperty.getTargetClass()` returns the class of the single >> parameter of the static property getter. >> * A property getter does not return an instance of `ReadOnly<*>Wrapper`, it >> returns the result of calling `ReadOnly<*>Wrapper.getReadOnlyProperty()`. >> >> Many properties in existing JavaFX classes violate the >> `PropertyMetadataVerifier` rules in some way or shape. This PR won't address >> these issues, this will be done in a future cleanup PR. >> >> --------- >> - [x] I confirm... > > Michael Strauß has updated the pull request with a new target base due to a > merge or a rebase. The pull request now contains 12 commits: > > - add ctor overloads to SimpleStyleable* properties > - Merge branch 'master' into feature/property-metadata > - revert > - remove test > - Update javadocs > - Merge branch 'master' into feature/property-metadata > > # Conflicts: > # modules/javafx.graphics/src/main/java/javafx/scene/layout/HeaderBar.java > - Merge branch 'master' into feature/property-metadata > > # Conflicts: > # modules/javafx.graphics/src/test/addExports > - Merge branch 'master' into feature/property-metadata > - review changes > - ReadOnlyProperty.getDeclaringClass() tests > - ... and 2 more: https://git.openjdk.org/jfx/compare/6670f897...78a38fa8 Two comments regarding API and doc. modules/javafx.base/src/main/java/javafx/beans/property/ReadOnlyProperty.java line 48: > 46: * For instance properties, this is the object that contains the > property. > 47: * For {@linkplain AttachedProperty attached properties}, it is the > object to which the property is attached. > 48: * Is this property is not associated with an object, {@code null} is > returned. Typo Suggestion: * If this property is not associated with an object, {@code null} is returned. modules/javafx.base/src/main/java/javafx/beans/property/SimpleStringProperty.java line 67: > 65: */ > 66: @Override > 67: public Class<?> getDeclaringClass() { Minor question, but since we now add the new API, we should probably think about it. Should we rather make all `getDeclaringClass()` methods final for all `Simple*Property` classes? ------------- PR Review: https://git.openjdk.org/jfx/pull/2015#pullrequestreview-5121436139 PR Review Comment: https://git.openjdk.org/jfx/pull/2015#discussion_r3940793950 PR Review Comment: https://git.openjdk.org/jfx/pull/2015#discussion_r3940786297
