ModuleClassLoader inheritance issue

Alexey Fedorov alexey.x.fedorov at oracle.com
Tue Feb 28 04:55:53 PST 2012


Hello!

I'm playing with modular JDK and trying to modify default 
ModuleClassLoader behavior:

> public class MyModuleClassLoader extends ModuleClassLoader {
>
>     public MyModuleClassLoader(ModuleSystem ms) {
>         super(ms);
>     }
>
>     // bla-bla-bla ...
>
> }

But when I call isModulePresent(String) for this new class,

> ModuleClassLoader classLoader = new 
> MyModuleClassLoader(ModuleSystem.base());
> boolean currentModulePresent = 
> classLoader.isModulePresent("bla-bla-bla"); 

I see that ClassCastException is thrown:

> java.lang.ClassCastException: mypackage.MyModuleClassLoader cannot be cast to org.openjdk.jigsaw.Loader
> 	at java.lang.module.ModuleClassLoader.isModulePresent(ModuleClassLoader.java:86)

Is java.lang.module.ModuleClassLoader class planned to be final? Or does 
modular-jdk Team plan to add some documentation containing 
overriding/inheritance rules for new Modular API?

--
Thank you,
Alexey



More information about the jigsaw-dev mailing list