首页 > 代码库 > 编译“have the same erasure, yet neither overrides“
编译“have the same erasure, yet neither overrides“
编译报错:
have the same erasure, yet neither overrides the other
首先,这个问题貌似出现在JDK1.7 中,1.6时应该可以的。
public class PortfolioDataValidator implements IRecordValidator{ public int validate(List<BusinessObjectViolation> violations, Object obj, int index, Object validateHelper) { if (obj == null) { return 0; } else { return doValidate(violations, obj, index, validateHelper); } } }
提示在这个类的这个方法上出错。
public interface IRecordValidator<T> { int validate(List<BusinessObjectViolation> violations, T obj, int index, Object validateHelper); }
这是接口。
一个简单的实现,应该没什么问题的。
Sun那边有个ticket
http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7078419
The interim support for "jsr14" class files was never a documented supported option. And, since generic signature attributes are not defined for v48 (JDK 1.4) and earlier class files, it is inappropriate for javac to behave otherwise.
最后这么解决的:
public class PortfolioDataValidator implements IRecordValidator<Object> { public int validate(List<BusinessObjectViolation> violations, Object obj, int index, Object validateHelper) { if (obj == null) { return 0; } else { return doValidate(violations, obj, index, validateHelper); } } }
添加了一个
IRecordValidator<Object>
编译“have the same erasure, yet neither overrides“
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。