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

NullPointerException missing in an explicit superconstructor invocation

XMLWordPrintable

    • hopper
    • sparc
    • solaris_7
    • Verified



      Name: ngR10089 Date: 03/06/2001



      JLS, 2nd Ed., 8.8.5.1 says:

      "Let C be the class being instantiated, let S be the direct superclass of C,
      and let i be the instance being created. The evaluation of an explicit
      constructor invocation proceeds as follows:

        o . . .

          o . . .

            o If the superclass constructor invocation is qualified, then the Primary
              expression p immediately preceding ".super" is evaluated. If the
              primary expression evaluates to null, a NullPointerException is raised,
              and the superclass constructor invocation completes abruptly."


      Java compiler jdk1.4.0beta-b54 creates class file that does not provide
      NullPointerException raising.

      > java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b54)
      Java HotSpot(TM) Client VM (build 1.4beta-B54, mixed mode)

      > javac -d . clss362.java
      > java -verify javasoft.sqe.tests.clss362
      > echo $status
      97
      >
      -----------------clss362.java------------------
      package javasoft.sqe.tests;

      import java.io.PrintStream;

      public class clss362 {
          public static void main(String argv[]) {
              System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
          }
          public static int run(String argv[],PrintStream out) {
              clss362a.c r = null;
              try {
                  r = new clss362a().new c();
              } catch (NullPointerException e) {
                  out.println(e);
                  return 0/*STATUS_PASSED*/;
              } catch (Throwable e) {
                  out.println("failed: "+e);
              }
              return 2/*STATUS_FAILED*/;
          }
      }
      class clss362a {
          class a {
              int a1 = 5;
          }
          class c extends a {
              c() {
                  null.super();
              }
          }
      }
      ----------------------------------------------------

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

            gafter Neal Gafter (Inactive)
            nvgsunw Nvg Nvg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: