title: Classes instantiated with different classloaders in the same Dalvik/JVM cannot "see" each other
body: <p>I'm working on an Android application with pluggable .jar modules.</p>
  
  <p>My problem is, when I load two different .jar files, the classes from the first .jar file cannot "see" (Class.forName()) classes from the second .jar file and vice-versa. I load external .jars from the main application with DexClassLoader.</p>
  
  <p><em>=== Here is an example situation ===</em></p>
  
  <p>We have two modules:</p>
  
  <ul>
  <li>First.jar (with classes FirstA and FirstB, packaged in classes.dex)</li>
  <li>Second.jar (with class SecondA, again in classes.dex)</li>
  </ul>
  
  <p>By using DexClassLoader I load First.jar. Everthing is OK.
  Then again by using DexClassLoader I load Second.jar and SecondA cannot "see" FirstA or FirstB with Class.forName(). I get java.lang.ClassNotFoundException. When I check for FirstA from SecondA with Class.forName() I'm not setting the classloader parameter.</p>
  
  <p><em>=== End of example situation ===</em></p>
  
  <p>I was thinking that when a class is loaded into the dalvik/jvm, it will be visible/accessible from all other classes in that same dalvik/jvm. This is not the case or I'm totally wrong?
  What I have to do in order to make SecondA to see classes from First.jar (Class.forName())?</p>
  
  <p>Any suggestions or resources I can learn from are welcome!
  I'm stuck guys!</p>
  
  <p>EDIT: </p>
  
  <ul>
  <li>All modules are loaded runtime. </li>
  <li>Every module is loaded by different instance of DexClassLoader because I'm required to provide path to the .jar file and I cannot pack all modules in one jar.</li>
  </ul>