Java.beans.Introspector getBeanInfo does not load any supersurface properties

I just noticed that java.beans.Introspector getBeanInfo does not get any supersurface properties. Example:

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

Introspection on Employee only gives a salary, even if the name is inherited from Person.

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

+4
source share
4 answers

This problem is covered in the Sun-error java.beans.Introspector does not work for interfaces

+3
source

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 .

+3
source

Try using

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

and see if this gives the result you are looking for.

+1
source

In this case, you should write your own BeanInfo class.

0
source

Source: https://habr.com/ru/post/1277582/


All Articles