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

4.5: When are wildcards "the same"?

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      The following shows that javac is inconsistent in determining
      which overriders are allowed:

      class Box<T extends Number> {}

      class T1 { // works
          static class A {
              void f(Box<?> box) {}
          }
          static class B extends A {
              void f(Box<? extends Object> box) {}
          }
      }

      class T2 { // works
          static class A {
              void f(Box<?> box) {}
          }
          static class B extends A {
              void f(Box<? extends Number> box) {}
          }
      }

      class T3 { // works
          static class A {
              void f(Box<? extends Object> box) {}
          }
          static class B extends A {
              void f(Box<?> box) {}
          }
      }

      class T4 { // works
          static class A {
              void f(Box<? extends Number> box) {}
          }
          static class B extends A {
              void f(Box<?> box) {}
          }
      }

      class T5 { // fails
          static class A {
              void f(Box<? extends Object> box) {}
          }
          static class B extends A {
              void f(Box<? extends Number> box) {}
          }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dlsmith Dan Smith
                Reporter:
                gafter Neal Gafter
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Imported:
                  Indexed: