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

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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 11
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b01
    • CPU:
      generic
    • OS:
      generic

      Description

      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(" */");
                      }

        Attachments

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

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: