Good day everyone. I'm using Vaadin and got a problem with BeanItemContainer. I have a generic interface and a bean implementing that interface
package ru.package.testpackage;
public class SomeTest {
interface SomeHavingId<T> {
T getId();
void setId(T id);
}
class TestBean implements SomeHavingId<Integer> {
public TestBean(Integer id) {
this.id = id;
}
@Override
public Integer getId() {
return id;
}
@Override
public void setId(Integer id) {
this.id = id;
}
private Integer id;
}
}
The problem is that Vaadin inside BeanItemContainer
uses Introspector.getBeanInfo(TestBean.class)
to parse setters and getters to create property map. But instead of resolving a Integer getId()
I get java.lang.Object getId()
. As far as I see, Introspector is not able to understand the interface being implemented in SomeHavingId<Integer>
way.
So that's my question - what should I do to get correct method signature if:
Unfortunately the Problem can still occur in JRE7 but is not reproducable. It depends on the order of the methods returned by the method "Method[] java.lang.Class.getMethods()" if the result is correct or not.
The javadoc of this method says "... The elements in the array returned are not sorted and are not in any particular order..." but the introspector uses the order to create the property descriptors. Therefore it can happen that a wrong property descriptor is returned.
I run into this problem but could not find a solution and not even a way to reproduce because it does not happen very frequently.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.