Cannot access ModuleTree in a CompilationUnitTree

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 17
    • Affects Version/s: 9, 10, 11, 12, 13, 14, 15, 16
    • Component/s: tools
    • None
    • b07

      There is currently no way to access a ModuleTree from a CompilationUnitTree.

      This is made most evident by looking at the "USE" of ModuleTree in the API specs.

      https://docs.oracle.com/en/java/javase/15/docs/api/jdk.compiler/com/sun/source/tree/class-use/ModuleTree.html

      Note that JLS 7.3 defines:

      CompilationUnit:
         OrdinaryCompilationUnit
         ModularCompilationUnit

      OrdinaryCompilationUnit:
         [PackageDeclaration] {ImportDeclaration} {TypeDeclaration}

      ModularCompilationUnit:
         {ImportDeclaration} ModuleDeclaration

      https://docs.oracle.com/javase/specs/jls/se15/html/jls-7.html#jls-7.3

      It is therefore appropriate to provide access to the ModuleDeclaration when that is the content.

            Assignee:
            Jonathan Gibbons
            Reporter:
            Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: