JAVA 泛型编译(JDK1.7)

begoodluck begoodluck 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
父类

public class Bridge<T extends Serializable> {

private T entity;

protected void setEntity(final T entity) {
this.entity = entity;
}

public T getEntity() {
return this.entity;
}
}

子类

public class StringBridge extends Bridge<String> {

@Override
@Autowired
protected void setEntity(final String entity) {
// TODO Auto-generated method stub
super.setEntity(entity);
}

}

测试

StringBridge bridge = new StringBridge();
Method[] methodArr = bridge.getClass().getDeclaredMethods();
for (Method method : methodArr) {
System.out.println(method);
Annotation[] annotations = method.getAnnotations();
for (Annotation annotation : annotations) {
System.out.println(annotation);
}
}

绝大部分是输出这样的,这个是正常的

protected void com.ces.config.StringBridge.setEntity(java.lang.String)
@org.springframework.beans.factory.annotation.Autowired(required=true)
protected void com.ces.config.StringBridge.setEntity(java.io.Serializable)

偶尔会输出这个,bridge方法上也有注解,有哪位大侠知道的,解释一下,谢谢

protected void com.ces.config.StringBridge.setEntity(java.lang.String)
@org.springframework.beans.factory.annotation.Autowired(required=true)
protected void com.ces.config.StringBridge.setEntity(java.io.Serializable)
@org.springframework.beans.factory.annotation.Autowired(required=true)
...全文

相关推荐

评论
收藏 已收藏
分享
返回顶部
begoodluck
Java 51,407 成员 86,133 内容