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

(compound) same interface allowed twice in compound type

    Details

    • Subcomponent:
    • Resolved In Build:
      b03
    • CPU:
      sparc
    • OS:
      solaris_9
    • Verification:
      Verified

      Backports

        Description

        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

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ahe Peter Ahe
                  Reporter:
                  duke J. Duke (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: