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

(cl spec) clarify spec of ClassLoader.getPackages() about run-time package

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 5.0
    • Fix Version/s: 10
    • Component/s: core-libs

      Description

      A DESCRIPTION OF THE REQUEST :
      Javadoc currently reads: "Returns all of the Packages defined by this class loader and its ancestors". Yet this is not really true. Packages that represent folders inside another package defined in this class loader will not appear in the returned list until at least one class has been loaded from the package. For example, if the classpath contains an entry "com.abc.mainpkg", the class loader may be able to load "com.abc.mainpkg.subpkg.Foo", but until it actually does (or loads something from "subpkg"), the return value for getPackages() may not include "com.abc.mainpkg.subpkg". Thus, the javadoc is misleading.

      JUSTIFICATION :
      Because developers design their code wrong and then have to rewrite it when the method doesn't work as advertised.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Change the doc. Perhaps add an explanation at the end along the lines of this. "Note: packages that represent folders inside another package may not appear in the returned list of packages until at least one class has been loaded from the folder."

        Attachments

          Activity

            People

            • Assignee:
              mchung Mandy Chung
              Reporter:
              rmandalasunw Ranjith Mandala (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: