编译“have the same erasure, yet neither overrides“

时间:2014-11-24 12:07:52   收藏:0   阅读:2782

编译报错:

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>



原文:http://my.oschina.net/u/921876/blog/348076

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!