Upgrading an existing ClassLoader to support modules
Alan Bateman
Alan.Bateman at oracle.com
Wed Oct 26 18:58:40 UTC 2016
On 26/10/2016 16:53, Thomas Watson wrote:
> :
>
> If you are mapping your own custom class loaders using
> Layer.defineModules(Configuration, Function<String, ClassLoader>) then you
> need to be sure to override the method ClassLoader.findResource(String,
> String) for your custom class loaders when running on Java 9. Otherwise
> you will find Class.getResource always returning null. Sorry if this is
> widely known here, but it surprised me.
>
(I've changed the subject line as this is not related to the patch to
add support for naming class loaders).
If you are upgrading an existing class loader to support load of classes
and resources from modules then you need to override the 2-arg findClass
and 2-arg findResource methods. Both methods do have javadoc to say this
(but you are right, you have to go look for it). Note that there is
deliberately no subtype of ClassLoader defining these two as abstract
methods, ditto for an interface that would add this support.
-Alan
More information about the jigsaw-dev
mailing list