Hi!

I'm working to integrate the JPMS into our application server in a way that
the applications can run in a layer each, but I faced something strange:
our current behavior without layers,
calling ClassLoader::getResources in the classloader
provided by us, it will return a return "foo".
In the conversion to layer, it was clear to me that I would need to use
the ModuleLayer::defineModulesWithOneLoader, so the application
classloading behavior wouldn't change and the ModuleReader
would use the same source of resources that the classloader is using.

However, calling the ClassLoader::getResources in the classloader
provided by the Module system, it is finding the resource
in itself and on the parent, so it finds the same resource twice.

As our applications aren't expected to work with the same
resource twice, it broke in some places where we cannot change.

I've created a simple example of what is occurring [1].
I know there are behavior specific for getting a class if it is in a module,
but I don't know if this may be a bug in the resource loading mechanism.
In the example, the returned values are different to illustrate, but in my
case, it
returns two exact URLs for the same resource as the source for the module
reader
and the classloader is the same.

[1] https://gist.github.com/Thihup/8e53bc991272452e63a6055f05690ba5

Reply via email to