ClassCastException in Custom class loader
824461Sep 19 2012 — edited Sep 25 2012I have created a custom class loder.
ClassLoaderDemo ccl = new ClassLoaderDemo(); //assume it is working fine
Class clas = ccl.loadClass( "com.MyObject" );
com.MyObjectSuperClass o1 = (com.MyObjectSuperClass)clas.newInstance();
Now I want to cast the loaded object to MyObjectSuperClass which is super class if MyObject. But I am getting the following exception
Exception in thread "main" java.lang.ClassCastException: com.MyObject cannot be cast to com.MyObjectSuperClass
Please help.