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

Sergey Bylokhov serb at openjdk.org
Tue Feb 11 04:59:09 UTC 2025


On Thu, 6 Feb 2025 14:13:50 GMT, Roman Marchenko <rmarchenko at openjdk.org> wrote:

>> Fixed `com.sun.beans.introspect.MethodInfo#MethodOrder` to make `Introspector.addMethod()` working properly when filtering methods out.
>> 
>> Also fixed the test, and added the approptiate test case.
>
> Roman Marchenko has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update test/jdk/java/beans/Introspector/DefaultMethodBeanPropertyTest.java
>   
>   Co-authored-by: Aleksandr Zvegintsev <77687766+azvegint at users.noreply.github.com>

Also please check the next example:

import java.beans.IntrospectionException;

public class Test {

    public interface A {
        default void setFoo(Integer num) {
        }
    }

    public class D implements A {
        public void setFoo(Number num) {
        }
//        public Integer getFoo() {
//            return null;
//        }
    }

    public class AC {
        public void setFoo(Integer num) {
        }
    }

    public class DC extends AC {
        public void setFoo(Number num) {
        }
//        public Integer getFoo() {
//            return null;
//        }
    }

    public static void main(String[] args) throws java.beans.IntrospectionException {
        test(D.class);
        test(DC.class);
    }

    private static void test(Class beanClass) throws IntrospectionException {
        System.out.println("\nbeanClass = " + beanClass);
        var info = java.beans.Introspector.getBeanInfo(beanClass, Object.class);
        System.out.println(info.getBeanDescriptor());
        System.out.println("--- properties");
        for (var desc : info.getPropertyDescriptors()) {
            System.out.println(desc.getReadMethod());
            System.out.println(desc.getWriteMethod());
        }
    }
}

Is the next output expected()?


beanClass = class Test$D
java.beans.BeanDescriptor[name=Test$D; beanClass=class Test$D]
--- properties
public java.lang.Integer Test$D.getFoo()
public default void Test$A.setFoo(java.lang.Integer)

beanClass = class Test$DC
java.beans.BeanDescriptor[name=Test$DC; beanClass=class Test$DC]
--- properties
public java.lang.Integer Test$DC.getFoo()
public void Test$AC.setFoo(java.lang.Integer)



btw it will be good to cover this scenario in the test.

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

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


More information about the client-libs-dev mailing list