Question

I just noticed that java.beans.Introspector getBeanInfo does not pickup any superinterface's properties. Example:

public interface Person {
    String getName();
}
public interface Employee extends Person {
    int getSalary();
}

Introspecting on Employee only yields salary even though name is inherited from Person.

Why is this? I would rather not have to use reflection to get all the getters.

Was it helpful?

Solution

This issue is covered in Sun bug java.beans.Introspector doesn't work for interfaces

OTHER TIPS

The Java VM does not support this out of the box as Phil wrote. I also needed this and implemented a helper class as part of Diergo Utils 1.5.

Try using

public static BeanInfo getBeanInfo(Class<?> beanClass, Introspector.USE_ALL_BEANINFO);

and see if this yields the result you're looking for.

In such a case, you should write a custom BeanInfo class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top