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

com.sun.tools.javac.tree.Pretty generates nested comments for enum

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 11
    • 9
    • tools
    • b01
    • generic
    • generic

      Output for a desugared tree (sourceOutput == false) thus cannot be compiled. Output for (sourceOutput == true) is correct so this may be considered a non-issue.

      enum Foo {AA, BB, CC { void m() {} }; void m() {};}

      Generates ---

      enum Foo {
          /*public static final*/ AA /* = new Foo() */,
          /*public static final*/ BB /* = new Foo() */,
          /*public static final*/ CC /* = new Foo()/*enum*/{
              
              void m() {
              }
          } */;
          
          void m() {
          }
      }

      Cause is

          public void visitVarDef(JCVariableDecl tree) {
      ...
                  if ((tree.mods.flags & ENUM) != 0) {
      ...
                          print(" /* = ");
                          printExpr(tree.init);
                          print(" */");
                      }

        1. sample.java
          0.1 kB
        2. Test.java
          2 kB

            sdama Srinivas Dama (Inactive)
            rfield Robert Field (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: