javac fails to report ambiguous method as jdk1.2 javac did

XMLWordPrintable

    • Type: Bug
    • Resolution: Not an Issue
    • Priority: P2
    • None
    • Affects Version/s: 1.3.0
    • Component/s: tools
    • None
    • generic
    • solaris_2.5

      Javac should fail when compiling the testcase below:

      == cls1.java ==
      package p1;

      import p2.cls2;

      public class cls1 extends cls2 {
          public void method1() {
              cls2 c = new cls2();
              c.method2(null);
          }
      }

      === cls2.java ===
      package p2;

      public class cls2 {

          protected void method2(Integer i) {
              System.out.println(" Integer");
          }

          public void method2(String s) {
              System.out.println(" String");
          }

      }

      Actually both method2()'s are accessible and none of them is more specific than
      another one.
      So, the reference to c.method2(null) in cls1.cls1() is ambiguous.

      !!! Please note that if the super.method2(null) is written instead of
      c.method2(null) in cls1.cls1() javac issues an error about the ambiguous
      reference to cls2.method2().

            Assignee:
            William Maddox (Inactive)
            Reporter:
            Thomas Preisler (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: