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

Resource names used by the ClassLoader/Class/ModuleReader APIs should be specified clearly

XMLWordPrintable

      The ClassLoader and Class getResourceXXX methods have always been poorly specified with the result that they are used in the wild in brittle ways. For example, some libraries treat these APIs a bit like file system APIs and expect to be able to locate directories or use file system elements such as "." and "..".

      With modules then resources are read with a ModuleReader and it's hard to support some of the unspecified/brittle usages while at the same time enforcing resource encapsulation.

      This issue tracks re-examining this area with view to updating the ClassLoader and maybe ModuleReader specs to properly define resource names. The javadoc should set expectations as to whether directories can be located, also whether leading, trailing, and embedded '/' be allowed. One possibility is for the ModuleReader methods to throw IllegalArgumentException for malformed resource names. There are also migration issues to capture so there will be existing code that incorrectly uses the ClassLoader APIs to locate its own resources.

            alanb Alan Bateman
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: