Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6476705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:51:27+00:00 2026-05-25T06:51:27+00:00

So, I have this bit of wild, crazy code, that is making the compiler

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:51:28+00:00Added an answer on May 25, 2026 at 6:51 am

    I encountered the same compilation error, and as far as I can tell, this is an edge case in the specification for intersection types (multiply-bound generic types), and there is no solution possible.

    A small test case:

    public interface InterfaceA {
        public Object clone();
    }
    
    public interface InterfaceB {}
    
    public class ClassA<T extends InterfaceA> {} // ok
    
    public class ClassB<T extends InterfaceA & InterfaceB> {} //not ok
    

    You can’t have an intersection type containing any interfaces containing any method whose signature matches a non-public method on the base class (in this case, implicitly Object). This is not specific to Object or clone, however:

    public abstract class Base {
        protected abstract void m();
    }
    
    public interface Interface {
        public void m();
    }
    
    public class Class<T extends Base & Interface> {} // not ok
    

    Here’s the relevant Oracle bug, marked as "Not a defect".

    Here’s the relevant Eclipse bug, where the compiler was modified to produce the same error to match javac. This appears to have been a change for Indigo 3.7, which explains why some people could reproduce and others couldn’t.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, I have this bit of code that is slowing down the program hugely
I use this bit of code to feed some data i have parsed from
I have this bit of code: typedef CComQIPtr<MSXML::IXMLDOMDocument2> XML_DocumentPtr; then inside some class: XML_DocumentPtr
I have this bit of code to do some testing before I implement it.
I have this bit of code that helps me convert enum to string and
I have this bit of code that is being converted from vb6 to vb.net.
I have this bit of code that is outputting the wrong results. #include <stdio.h>
So I have this bit of python code that runs through a delicious page
I have this bit of code where it displays some locations from an XML
I have this bit of code that is receiving a series of messages: byte[]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.