On Jan 21, 6:31 am, Karl Pauls <karlpa...@gmail.com> wrote: > > Since the 'test' TestClass instance is created with reference to the > > new class-loader, I'd expect that after this line executes, > > test.getClass().getClassLoader() will return an instance of > > CustomClassLoader, but I always get the default PathClassLoader > > returned. > > Why would you expect that? Java uses parent delegation first so it > will find the class in the parent and return that one -- hence, its > classloader is the parent.
It uses parent delegation *by default*. You can override it. (See e.g. dalvik/tests/068-classloader/src/FancyLoader.java for an example.) However, if you do, your custom loader has to take responsibility for actually loading the class. This can get messy in a hurry.
-- 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