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

编译报错:java

have the same erasure, yet neither overrides the otherapp

java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

首先,这个问题貌似出如今JDK1.7 中,1.6时应该能够的。ide

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);
        }
    }
}

提示在这个类的这个方法上出错。
ui

public interface IRecordValidator<T> {
    int validate(List<BusinessObjectViolation> violations, T obj, int index, Object validateHelper);

}

这是接口。code

一个简单的实现,应该没什么问题的。接口

Sun那边有个ticket
get

http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7078419 it

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.io


最后这么解决的:编译

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>
相关文章
相关标签/搜索