title: ClassCastException: Class implementing the interface, still getting classcast
body: <p>I have a class which is implementing an interface with generics.</p>
  
  <pre><code>class MainClass {
      interface MyInterface &lt;T extends MyInterface.A&gt; {
          static class A {
          }
      }
  }
  
  //I have another class which implements this interface:
  class ImplementingClass implements MyInterface&lt;A&gt; {
  }
  
  //I am loading MyInterface class from a jar in a different place: 
  static loadJar(){
      String dexPath = new ContextWrapper(context).getCacheDir().getAbsolutePath();
      DexClassLoader classLoader = new DexClassLoader(JAR_FILE, dexPath, null, ClassLoader.getSystemClassLoader());
      Class c = classLoader.loadClass("ImplementingClass");
      MyInterface nvQS = (MyInterface) c.newInstance();
  }
  </code></pre>
  
  <p>I am getting a class cast exception. I am not sure why is that? The class is implementing the interface. I tried it with the generics as well but I still get the exception. </p>
  
  <p>Please let me know in case I am not clear. Thanks.</p>
  
  <p>Including the Exception :
  java.lang.ClassCastException: ImplementingClass cannot be cast to MainClass$MyInterface</p>
  
  <p>Hey, the interface is build as a java static library in android. The jar and the jar loader will be compiled against separate copies right? Is that a problem? Do you think that is why I might be getting a class cast?  </p>