On Fri, 21 Mar 2025 07:50:50 GMT, Roman Marchenko <rmarche...@openjdk.org> wrote:
>> Fixed `com.sun.beans.introspect.MethodInfo#MethodOrder` to make >> `Introspector.addMethod()` working properly when filtering methods out. >> >> Also, after PR discussion, added the approptiate test cases with >> corresponding fixes in MethodInfo.java and PropertyInfo.java. >> >> --------- >> `getMethodDescriptors()` returns descriptors of public methods of a class >> and its parent classes, including default methods defined in interfaces. The >> result doesn't include methods which were declared and not implemented, >> bridge methods, or methods which were overriden in subclasses. >> >> `getPropertyDescriptors()` returns descriptors of methods which were >> identified as getters or setters. As there can be the only method >> getter/setter per property, the following rules are applied when choosing a >> getter/setter: >> >> * Getters/setters for the same property defined (not necessarily overriden) >> in subclasses have higher precedence. >> * If there are getters/setters for the same property defined in the same >> class and argument types are assignable one to another, the method with the >> Least Common Supertype has the lower priority. If argument types are not >> assignable, the result is undefined (any method will be chosen). >> * Gettters/setters declared and not implemented are not considered. > > Roman Marchenko has updated the pull request incrementally with one > additional commit since the last revision: > > Fixing review comments src/java.desktop/share/classes/com/sun/beans/introspect/MethodInfo.java line 114: > 112: } > 113: for (Method method : iface.getMethods()) { > 114: if (!Modifier.isAbstract(method.getModifiers()) && > !method.isBridge()) { I have looked into the `Modifier` class to check which other modifiers we have, and I found that you might also want to skip static and private methods. Perhaps method.isDefault() is the method you're looking for? It seems like none of the tests catch that? Also please double check the code a few lines above: method = MethodFinder.findAccessibleMethod(method); if (!method.getDeclaringClass().isInterface()) { method = null; // ignore methods from superclasses } - ~~Why do we need to skip the methods from the interfaces? Maybe we can inject our logic there?~~ - The method `MethodFinder.findAccessibleMethod` also checks each method to be `isExported` ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/23443#discussion_r2010743261