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

TreePathScanner.visitClass is not called for new class statements of classes without a body

XMLWordPrintable

    • x86
    • os_x

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      When using TreePathScanner, visitClass is not called for new class statements without a body. For example, given the following source code:

      public class InnerClass {
          private final InnerInnerClass clazz = new InnerInnerClass();

          private class InnerInnerClass {
          }
      }

      three class files would be generated - InnerClass.class, InnerClass$1.class, and InnerClass$InnerInnerClass.class

      However, onVisit is only called twice, for the InnerClass class, and the InnerInnerClass classes, but not the anonymously named class created from the new statement. Changing the source to the following works as expected:

      public class InnerClass {
          private final InnerInnerClass clazz = new InnerInnerClass() { };

          private class InnerInnerClass {
          }
      }

      Either this is a bug or a flaw in the API as there doesn't seem to be any other way to get all of the binary names that will be generated from a given compilation unit's source code.


      REPRODUCIBILITY :
      This bug can be reproduced always.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: