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

Cannot access ModuleTree in a CompilationUnitTree

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9, 10, 11, 12, 13, 14, 15, 16
    • Fix Version/s: 17
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b07

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: