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

c.s.t.javac.tree.Pretty.visitNewArray() prints duplicate dimension markers

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • 8
    • tools
    • b103
    • Verified

      When pretty printing a new array that has an initializer, the "[]" markers are printed twice:

      if (tree.elemtype != null) {
      ...
          if (tree.elems != null) {
      ...
              print("[]");
          }
      ...
      }
      if (tree.elems != null) {
          if (tree.elemtype != null) print("[]");
      ...
      }

      Thus, a source file with "new Class[]{MethodType.class}" is printed as "new Class[][]{MethodType.class}".

      I tried this with the latest promoted 8:
      $ j8 -version
      java version "1.8.0-ea"
      Java(TM) SE Runtime Environment (build 1.8.0-ea-b90)
      Java HotSpot(TM) 64-Bit Server VM (build 25.0-b32, mixed mode)

            ksrini Kumar Srinivasan
            ahgross Andrew Gross
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: