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

binary compatibility rules cause wrong method to be called!

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • tools
    • None
    • generic
    • solaris_8

      The current binary compatibility rules require the marked call
      to be statically resolved to T2.m() at compile time, but to
      generate T2a as the qualifying type in the binary. This results
      in the wrong method being called at runtime.

      //////////////////////////////////////////////////////////
      import java.util.*;

      import static java.lang.System.out;

      public class T2 {

          public static void main(String[] args) {
      Collection c = T2a.m(new ArrayList<String>()); // => "T2a.m"
          }

          static Collection m(List<String> p) {
      out.println("T2.m");
      return null;
          }
      }


      class T2a extends T2 {

          static Collection m(List<Number> p) {
      out.println("T2a.m");
      return null;
          }
      }

            ahe Peter Ahe
            gafter Neal Gafter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: