Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4972073

(compound) same interface allowed twice in compound type

XMLWordPrintable

    • b03
    • sparc
    • solaris_9
    • Verified

        generic class signature allows to extends the same interface multiple times.
        Ideally it should throw compile time here.

        Please find the below code. It compiles successfully. But I think it shouldn't compile it. Class B signature allows to extends the MyInterface<E> twice.

        //-- Code start here --
        //Test1.java
        import java.lang.reflect.*;

        public class Test1 {
        public static void main(String[] args) {
        B b = new B<Sun1>();
        }
        }

        class D { }

        interface MyInterface<E> {
        public String foo();
        }

        class MyClass { }

        class Sun1 extends MyClass implements MyInterface<Sun1>, MyInterface<Sun1> {
        public String foo() {
        return "test";
        }
        }

        class B < E extends MyClass & MyInterface<E> & MyInterface<E> > extends D {
        }
        //-- code end here

              ahe Peter Ahe
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: