The inherited method Object.clone() cannot hide the public abstract method

Viewed 7767

So, I have this bit of wild, crazy code, that is making the compiler spit in my face for some hours the following error:

The inherited method Object.clone() cannot hide the public abstract method in IOrderable<T>

The culprit classes are the following (the error appears right in the T of the generic):

public class MyInterval<T extends Xpto & Successorable<T>> implements Cloneable {
    public MyInterval<T> clone(){
        MyInterval<T> it = null;
        try {
            it = (MyInterval<T>) super.clone();
            it.max = it.max.clone();
            it.min = (T) it.min.clone();
        } catch (CloneNotSupportedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return it;
    }
}

public interface Xpto {}

public interface Successorable<Y> extends IOrderable<Y> {
    Y suc();    
}   

interface IOrderable<J> extends Rankable<J>, Cloneable {
    boolean greaterEq(J e);
    J clone();
}

public interface Rankable<P> {
    int rank(P e);
}

Yes, they seem kinda random. They solely exist to test some weird things in a compiler/java_byte_code_instrumentation-like project I am doing. How can I make this work while keeping the logic intact?

Thanks

5 Answers

I solve this problem implementing clone as public

I had the same error.

In my case I forgot the public keyword in front of a method that had to be implemented as the class containing it implemented an interface defining it.

Related