import java.beans.Introspector;
import java.beans.PropertyDescriptor;

public class PropertyTypeTest {
    public static class BaseBean {
        private Object value;
        public Object getValue() {
            return this.value;
        }
        public void setValue(Object value) {
            this.value = value;
        }
    }

    public static class StringBean extends BaseBean {
        @Override
        public String getValue() {
            return (String) super.getValue();
        }
    }

    public static void main(String[] args) throws Exception {
        PropertyDescriptor[] pds = Introspector.getBeanInfo(StringBean.class).getPropertyDescriptors();
        PropertyDescriptor pd = null;
        for (PropertyDescriptor desc : pds) {
            if (desc.getName().equals("value")) {
                pd = desc;
            }
        }
        if (pd != null && !String.class.equals(pd.getPropertyType())) {
            throw new RuntimeException("Incorrect property type: expected String but got " +
                            (pd.getPropertyType() == null ? "null" : pd.getPropertyType().getName()));
        }
    }
}
