On Apr 17, 12:08 am, Eborix13 <[email protected]> wrote:
>   My question was not: why can't I use 2 classes loaded with different
> class loaders. My question has to do with the way Android implements
> the dynamical class loading thing. It won't let you load a class using
> this.getClass().getClassLoader() as the "parent" parameter in the
> DexClassLoader(String dexPath, String dexOutputDir, String libPath,
> ClassLoader parent) constructor. Instead you have to use
> MyClass.getSystemClassLoader() as the "parent" parameter. Why is that?

You can use this' class loader as the parent.  None of the problems
you described appeared to be related to problems of hierarchy, except
in so far as one combination resulted in a particular class being
resolved from an unexpected place.  It's possible I'm not fully
understanding your situation though.

> Why can't I load the class using the classloader which loaded all my
> classes up until then?

PathClassLoader, which is the underlying implementation for the system/
application loader and the user-defined loader that the app framework
uses, is constructed with an immutable path.  Additions and removals
are not allowed.  It doesn't *have* to work this way, but things are
more straightforward when it does.

I'm not sure how this question relates to your earlier question.  If
you create a class loader for Blah.dex, and want to load a class
called Splat from it, Blah.dex's class loader gets to decide how Splat
is found.  Blah's parent doesn't matter until Splat starts referring
to classes that aren't defined in Blah.dex.

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

Reply via email to