Hi,

   Seeing that the new 1.5 pre-release has support for loading classes
dynamically I immediately tried to see if it works. I used the
DexClassLoader(String dexPath, String dexOutputDir, String libPath,
ClassLoader parent) constructor. But I soon found out that it works
only partially.

   What I am trying to do is dynamically load a class from a given jar
file which contains a classes.dex file. If I try to use the current
class loader (this.getClass().getClassLoader()) as the "parent"
parameter I get a "java.lang.IllegalAccessError: cross-loader access
from pre-verified class" error. But if I use the SystemClassLoader as
the "parent" parameter everything works out nicely. But using the
SystemClassLoader is a problem for me because the class that is loaded
using the SystemClassLoader is a subclass of a class which was
previously loaded by the current class loader. Casting the derived
class to the base class generates a ClassCastException because the
base class was not loaded with the same class loader as the derived
class.

  Is there a way to solve this problem? Am I doing something wrong? Is
there a way to dynamically load a class using the current class loader
instead of the system class loader? Is this problem caused by the fact
that the 1.5 release is incomplete yet, so perhaps this problem is
going to be solved in the final release?

Thank you...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to