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

Binary compatibility implications of deleting method differ between 1.1 and JLS

    XMLWordPrintable

Details

    • 1.2
    • sparc
    • solaris_2.5
    • Not verified

    Description



      Name: vsC45997 Date: 12/14/96


      Let's consider a test checking the following assertion
      [The section "13.4.5 Class Body and Member Declarations" of The Java Language
      Specification contains the following]:

      "Deleting a class member or constructor that is not declared private
      may cause a linkage error if the member or constructor is used by a
      pre-existing binary, even if the member was an instance method that was
      overriding a superclass method. This is because, during resolution, the
      linker looks only in the class that was identified at compile time."

      The test below has been developed on the base of the example of the section
      13.4.5 which follows the assertion cited above.

      The test has been designed to demonstrate throwing "NoSuchMethodError"
      when a deleted method "m" is used.
          try {
            String s = new Super().m();
            out.println (s);
          }
          ....

      But JVM of JDK 1.1 uses the method "m" of the superclass Hyper
      in run-time and "NoSuchFieldError" is not thrown.

      The test consists of two files.

      // FILE: binc02401.java
      package javasoft.sqe.tests.lang.binc024.binc02401;
      import java.io.PrintStream;

      class Hyper {
        String m() { return "Hyper"; }
      }

      class Super extends Hyper {
        String m() { return "Super"; }
      }

      public class binc02401 {
        public static void main(String argv[])
        {
          System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
        }
        public static int run(String argv[],PrintStream out) {
          try {
            String s = new Super().m();
            out.println (s);
          }
          catch (NoSuchMethodError e) {
            out.println (e);
            return 0/*STATUS_PASSED*/;
          }
          out.println ("failed");
          return 2/*STATUS_FAILED*/;
        }
      }
          
          
      // FILE: binc02401a.java
      package javasoft.sqe.tests.lang.binc024.binc02401;

      class Hyper {
        String m() { return "Hyper"; }
      }

      class Super extends Hyper { }


      On JDK 1.1 we have the following output on this test:

      Hyper
      failed

      The test passes successfully on JDK 1.0.2.

      ======================================================================

      Attachments

        Activity

          People

            gbrachasunw Gilad Bracha (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: