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

overriding with method of different arity is prohibited

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 5.0
    • Fix Version/s: 5.0
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b40
    • CPU:
      generic
    • OS:
      solaris_8

      Description

      Name: akR10088 Date: 01/27/2004



      JSR-201, "Adding Variable-Arity Methods (Varargs) to the Java Programming Language",
      Public Review Draft, reads:

      Notes on the Specification Changes
      JLS 8: Overriding

      Whether a method's arity is fixed or variable does not have any effect on its
      signature. Hence it is perfectly legal to override a fixed arity method with a
      varaible arity one (all other things being equal) and vice versa.


      However, java compiler (build 1.5.0-beta2-b35) reports errors, when a fixed
      arity method is overriben with a varaible arity one or vice versa.

      Following jck tests fail due to this bug:
      lang/CLSS/clss457/clss45701/clss45701.html
      lang/CLSS/clss457/clss45702/clss45702.html

      --------------------------------- clss45701.java -----------
      package javasoft.sqe.tests.lang.clss457.clss45701;
      import java.io.PrintStream;

      class Supper {
        int mmm(int ... list) {
      return list[0];
        }
      }
       
      public class clss45701 extends Supper {
        int mmm(int[] list) {
      return list[1];
        }

        public static int run(String argv[], PrintStream out) {
      Supper obj=new clss45701();
      return obj.mmm(2/*STATUS_FAILED*/, 0/*STATUS_PASSED*/);
        }

        public static void main(String argv[]) {
           System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
        }

      }
      --------------------------------- clss45702.java -----------
      package javasoft.sqe.tests.lang.clss457.clss45702;
      import java.io.PrintStream;

      class Supper {
        int mmm(int[] list) {
      return list[0];
        }
      }
       
      public class clss45702 extends Supper {
        int mmm(int ... list) {
      return list[1];
        }

        public static int run(String argv[], PrintStream out) {
      Supper obj=new clss45702();
      int[] list={2/*STATUS_FAILED*/, 0/*STATUS_PASSED*/};
      return obj.mmm(list);
        }

        public static void main(String argv[]) {
           System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
        }

      }
      -------------------------------------------
      executing tests:

      novo64% java -version
      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b35)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b35, mixed mode)
      novo64% javac -source 1.5 *java
      clss45701.java:20: mmm(int[]) in javasoft.sqe.tests.lang.clss457.clss45701.clss45701 cannot override mmm(int[]) in javasoft.sqe.tests.lang.clss457.clss45701.Supper; overriding method is missing '...'
        int mmm(int[] list) {
            ^
      clss45702.java:20: mmm(int[]) in javasoft.sqe.tests.lang.clss457.clss45702.clss45702 cannot override mmm(int[]) in javasoft.sqe.tests.lang.clss457.clss45702.Supper; overridden method has no '...'
        int mmm(int ... list) {
            ^
      2 errors


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

        Attachments

          Activity

            People

            Assignee:
            gafter Neal Gafter
            Reporter:
            rfqsunw Rfq Rfq (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: