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

Add methods for Elements.getAll{Type, Package, Module}Elements

XMLWordPrintable

        As part of adding modules to the platform, the long-standing condition that there would be at most one type/package for the same canonical name was rendered untrue: two modules can have (non-exported) types or packages whose names are the same.

        This is a wrinkle for the javax.lang.model.Elements methods which map from names to type or package elements. The existing methods

            PackageElement getPackageElement(CharSequence name)
            TypeElement getTypeElement(CharSequence name)

        were redefined to return null if a type/package could not be uniquely found (JDK-8133896). In addition, overloads of these methods taking a module parameter were added to the API:

            PackageElement getPackageElement(ModuleElement module, CharSequence name)
            TypeElement getTypeElement(ModuleElement module, CharSequence name)

        However, this still leaves no easy way to return the same-named elements from whichever module they may be defined in.

        One API approach to address this issue would be Elements.getAll{Type, Package}Elements methods. In addition, it is helpful to have a way to see all known modules.

              darcy Joe Darcy
              darcy Joe Darcy
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: