RFR: 8347826: Introspector shows wrong method list after 8071693 [v4]

Sergey Bylokhov serb at openjdk.org
Thu Feb 13 00:15:14 UTC 2025


On Wed, 12 Feb 2025 19:54:37 GMT, Roman Marchenko <rmarchenko at openjdk.org> wrote:

> The question is why `Test$DC.setFoo(java.lang.Number)` is set as default setter, while the default call goes to `Test$AC.setFoo()`?

That is not a default call; it is just a method call when null is passed. If an Integer or Number is passed instead, different methods will be selected.

>Is this documented, or is there specification? I see that no tests exist for this, so it's not clear what is the expected behaviour. I mean, regarding property descriptors.

It was implemented in a way to minimize the difference between different 'stopClasses' for the same object. In the example above, the next call will produce the same properties:
-  java.beans.Introspector.getBeanInfo(DC.class, Object.class);
-  java.beans.Introspector.getBeanInfo(DC.class, AC.class);

Thus, the methods of the current class have some priority over those of the parent class.

But if the same class has multiple setFoo(xxx) methods, the behavior will be undefined/unspecified.

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

PR Comment: https://git.openjdk.org/jdk/pull/23443#issuecomment-2655131122


More information about the client-libs-dev mailing list