Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用ant编译错误_Java_Ant - Fatal编程技术网

Java 使用ant编译错误

Java 使用ant编译错误,java,ant,Java,Ant,我真的很难理解出了什么问题。从这里开始,我有一个这样的界面 public interface UserRecordsInterface { public abstract List getRecordsVector() throws UserExitException; } public class MyRecordsClass implements UserRecordsInterface{ private List addend

我真的很难理解出了什么问题。从这里开始,我有一个这样的界面

public interface UserRecordsInterface  
{  

    public abstract List getRecordsVector()  
        throws UserExitException;  

}  
public class MyRecordsClass implements UserRecordsInterface{  

    private List addendaRecs             = null;  

     /** 
     * Return the list of addenda records 
     *  
     * @return List 
     */  

    public List getRecordsVector() {  
        return addendaRecs;  
    }  
}  
我想在我的类MyRecordsClass.java中实现这个接口,如下所示

public interface UserRecordsInterface  
{  

    public abstract List getRecordsVector()  
        throws UserExitException;  

}  
public class MyRecordsClass implements UserRecordsInterface{  

    private List addendaRecs             = null;  

     /** 
     * Return the list of addenda records 
     *  
     * @return List 
     */  

    public List getRecordsVector() {  
        return addendaRecs;  
    }  
}  
在使用ant编译时,我遇到了两个错误

1
类MyRecordsClass不是抽象的,并且不重写UserRecordInterface中的抽象方法getRecordsVector()。

 - [javac] found : java.util.List 
 - [javac] required: java.util.Vector 
 - [javac] public List getRecordsVector() {
2
MyRecordsClass中的getRecordsVector()无法在UserRecordsInterface中实现getRecordsVector();试图使用不兼容的返回类型。

 - [javac] found : java.util.List 
 - [javac] required: java.util.Vector 
 - [javac] public List getRecordsVector() {

最初,方法
getRecordsVector()
在接口中具有返回类型向量。现在,它被改为列表。所以,我在班上也做了相应的改变。现在,它给出了这个错误。如果我把我的类改为Vector&compile,那么它就可以正常工作了。但我想使用List,因为这就是当前界面的功能。所以,我相信ant仍然指向具有向量接口的旧库。不确定,这是否是ant或我的代码的问题。请建议..

您不需要在界面中使用
abstract
修饰符,我有一种预感,这就是导致您出现问题的原因。使用抽象方法的唯一地方是抽象类

编辑

我认为很可能是接口最近发生了变化,并且在一个单独的jar中

它可能用于返回向量,但现在您看到的源返回一个列表


我怀疑您是在类路径中使用旧版本的jar进行编译(其中,
getRecordsVector()
仍然返回一个
Vector
)?我在IntelliJ IDEA中运行Java7,它没有抱怨代码——它实际上已经编译,如果我在其中放入一个main方法,我就可以运行它


我同意@NickJ的评论——接口方法本质上是抽象的——因为必须在实现接口的类中实现它们

你是否删除了所有的类文件并再次尝试编译?是的,我同意你的看法。在接口中使用抽象并没有任何意义。但是,这是允许的。我从另一个团队获得的界面,我没有访问权限。所以,我唯一能做的就是实现它。但是,你真的认为使用抽象是问题的根源吗?因为,正如我所说的,当我使用Vector而不是List时,它编译得很好。我已经检查过了,abstract关键字虽然多余,但不是问题所在。我认为存在一个类兼容性问题。见上面的修正答案。是的,我实施了它。我猜,我也发布了实现方法。