ClassLoader.getParent to throw exception for module classloader

Paul Sandoz paul.sandoz at oracle.com
Fri Jun 22 03:36:08 PDT 2012


On Jun 22, 2012, at 11:42 AM, Alan Bateman wrote:

> On 22/06/2012 09:55, Paul Sandoz wrote:
>> :
>> 
>> 
>> I updated the webrev for future reference.
>> 
> BTW: What is the reason for Platform.isModuleClassLoader when you can simply check if this is an instanceof ModuleClassLoader?
> 

Me being pedantic. But i did think of some valid reasons :-) 

Anyone can currently extend ModuleClassLoader:

  ModuleClassLoader mcl = new ModuleClassLoader(ModuleSystem.base()) {};

Which i guess is a separate problem.

Should we be checking for an instance of Loader? We can make Loader package private and then in ServiceLoader also do:

        if (Platform.isModuleClassLoader(loader)) {
            ...
        } else {
            ...
        }

The general point is we can just change the implementation of Platform.isModuleClassLoader() if our assumptions on what a module class loader is changes.

Paul.




More information about the jigsaw-dev mailing list