ClassLoader.getResources() only returns locations in a patch when using the module path and --patch-module

Alan Bateman Alan.Bateman at oracle.com
Tue Jul 3 09:53:23 UTC 2018


On 03/07/2018 09:28, Andy Wilkinson wrote:
> I recently raised a JDK issue [1] which, when triaged, was closed as not an
> issue. I think is incorrect and was advised by Dalibor Topic [2] to email
> this list so here I am.
>
> In a nutshell, it appears that when using the module path and
> --patch-module, a call to ClassLoader.getResources() will only return
> resources locations that are within the patch and ignores those that are in
> the original module.
It's not a bug. If you patch a module to override a resource in that 
module then the getResourceXXX methods will locate the resource in the 
patch.

If it helps, the reason the output of the Maven project in the bug 
report is confusing because the Maven Surefire plugin is run with the 
classes directory on the module path and the test-classes directory on 
the class path. The same resource is found in both so this is because 
two resources are located. In addition, the test is using the name of a 
directory so it's highly implementation specific if it will be found 
anyway (the test patches an exploded module with an exploded patch and 
names that locate resources can be located with both layouts).

-Alan


More information about the core-libs-dev mailing list