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

null pointer check too late for qualifying expr of anon class creation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.2
    • 1.4.0
    • tools
    • mantis
    • generic
    • solaris_8

      /*
      Jikes and javac both compile this such that the null check is performed
      in C$1, AFTER the increment, so the output is 2. However, 15.9.4
      states that the null check occurs first, so the output is required
      to be 1.
      */

      class C {
          class Inner {
              Inner(int i) {}
          }
          public static void main(String[] args) {
              int i = 1;
              try {
                  C c = null;
                  c.new Inner(i++) {};
              } catch (NullPointerException e) {
                  System.out.println(i);
              }
          }
      }

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: