JAVA 泛型编译(JDK1.7)

begoodluck 2019-01-28 02:53:40
父类

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)
...全文
62 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,528

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧