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

The problem with the multiple bounds for the generic type

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 7
    • Fix Version/s: 7
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      Javac allows to inherit a method with one signature from the superclass and a super interface at the same time.
      It is also not a problem if this method is protected in the class and is certainly public in the interface - you just have to override it as public in the subclass.

      But for some unclear reasons using the described class and the interface
      as the multiple bounds for a generic type doesn't work.

      Here it the minimal test case:

      class MyClass {
          protected void foo() {
          }
      }

      interface MyInterface {
          public void foo();
      }

      // MixedClass compiles fine
      class MixedClass extends MyClass implements MyInterface {
          public void foo() {
              super.foo();
          }
      }

      // this doesn't compile wit the message
      // foo() in MyClass cannot implement foo() in MyInterface
      // which isn't correct, because it perfectly can do it in the subclass
      public class GenericProblem<T extends MyClass & MyInterface> {

      }

      This problem is reproducible with the latest JDK 7

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                alexp Alexander Potochkin (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: