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

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      os_x

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: