ClassLoader.getResources() only returns locations in a patch when using the module path and --patch-module
awilkinson at pivotal.io
Tue Jul 3 08:28:00 UTC 2018
I recently raised a JDK issue  which, when triaged, was closed as not an
issue. I think is incorrect and was advised by Dalibor Topic  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.
There's a Git repository  that should reproduce the problem when you run
with ./mvnw test using Java 9 or later. The problem appears when using
Maven as Surefire launches the test VM with the main classes on the module
path and the test classes patched into the module. As a result, tests are
able to load classes from both the module and the patch but getResources()
only returns locations within the patch. As far as I can tell, Surefire is
configuring the JVM correctly when it launches it so this appears to be a
bug in the JDK.
More information about the core-libs-dev