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

Cannot access ModuleTree in a CompilationUnitTree

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 17
    • 9, 10, 11, 12, 13, 14, 15, 16
    • tools
    • None
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: