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

hiding versus generics versus binary compatibility

    Details

    • Subcomponent:
    • Introduced In Build:
      5.0
    • Introduced In Version:
      5.0
    • Resolved In Build:
      b27
    • CPU:
      generic
    • OS:
      solaris_8
    • Verification:
      Not verified

      Description

      The following illustrates that the binary compatibility rules conflict
      with generics. The method resolved at compile time and at runtime are
      different, resulting in a runtime call to the wrong method.

      Date: Wed, 25 Feb 2004 14:15:59 -0800
      From: <###@###.###>
      Subject: Method isn't hidden, but acts like it is at runtime
      To: ###@###.###
      Cc: ###@###.###

      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;
          }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                gafter Neal Gafter
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: