javac is overly aggressive on overload warnings

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P3
    • None
    • Affects Version/s: 8
    • Component/s: tools
    • None

      javac warns about overload on subclasses trying to override a method from superclass where the method cause a overload warning even when the warning is suppressed.

      See attached test case,

      There are two behaviors I found odd, to reproduce what I described,
      build with javac -Xlint:all TestOverload.java,

      1. There is still one warning to be suppressed, at line 30,

      > TestOverload.java:30: warning: [overloads] bar(IntFoo) in Impl is potentially ambiguous with bar(Foo<Integer>) in IntBar
      > public void bar(IntFoo foo) {
      > ^
      > 1 warning

      The source(Interface IntBar) where the problem is introduced is having SuppressWarnings, have all subclasses to do SuppressWarnings seems a little too much, also the message is not
      obvious on what is the ambiguous. I misunderstood it as saying it
      doesn't know which function to override.

      2. If I remove the two lines of @SuppressWarnings at line 15 and 20, I
      expected both line will cause overloads warning, but I only get one.
      After suppress that one, then compile gives me another one.

      Expected behavior:
      1. The attached code should compile cleanly.
      2. In IntBar, SuppressWarnings should only be needed on the new method causing overload warning, that is void bar(IntFoo arg)

            Assignee:
            Unassigned
            Reporter:
            Henry Jen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: