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

error status changed to warning for "Can't reference super before ..."

XMLWordPrintable

    • 1.1beta3
    • sparc
    • solaris_2.5
    • Not verified



      Name: laC46010 Date: 11/26/96


      JLS explicitly states (JLS, 8.6.5, p. 179):

      "An explicit constructor invocation statement may not refer to any
      instance variables or instance methods declared in this class or any
      superclass, or use this or super in any expression; otherwise, a
      compile-time error occurs."

      JDK1.1M Java compiler have changed status of the error message
      "Can't reference super before the superclass constructor has been called"
      to warning. As a result the JCK1.1 tests checking the above assertion fail:

      lang/CLSS/clss217/clss21704/clss21704.result
      lang/CLSS/clss217/clss21705/clss21705.result
      lang/CLSS/clss217/clss21706/clss21706.result
      lang/CLSS/clss217/clss21707/clss21707.result
      lang/CLSS/clss217/clss21712/clss21712.result
      lang/CLSS/clss217/clss21713/clss21713.result
      lang/CLSS/clss217/clss21714/clss21714.result
      lang/CLSS/clss217/clss21716/clss21716.result

      See one of them below.

      /export/ld32/jdk_1.1M/bin/javac -d /export/ld12/java/leo/res/dev-jdk1.1-f/classes tests/lang/CLSS/clss217/clss21704/clss21704.java

      tests/lang/CLSS/clss217/clss21704/clss21704.java:17: Can't reference super before the superclass constructor has been called.
      this(super.field1);
      ^
      1 warning

      Test source:

      ------------------------------------------------------------------
      // Ident: @(#)clss21704.java 1.1 96/11/11
      // Copyright 11/11/96 Sun Microsystems, Inc. All Rights Reserved
      package javasoft.sqe.tests.lang.clss217.clss21704;


      import java.io.PrintStream;
       
      class clss21704_b {
      int field1 = 666;
      }
      class clss21704_a extends clss21704_b {
      int field1 = 777;
      clss21704_a(int arg) {
      field1 = arg;
      }
      clss21704_a() {
      this(super.field1);
      }
      }

      public class clss21704 {
        public static void main(String argv[])
        {
           System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
        }
        public static int run(String argv[],PrintStream out) {
      clss21704_a x = new clss21704_a();
      return 2;
        }
      }

      ------------------------------------------------------------------


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

            jrose John Rose
            leosunw Leo Leo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: