-
Enhancement
-
Resolution: Fixed
-
P3
-
None
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.
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.
- relates to
-
JDK-8174823 Module system implementation refresh (3/2017)
- Resolved