Hi guys,

I'm trying to replace the class loader with my custom class loader. I
don't want to replace the default functionality, only add new
functionality.

The goal is that every new class instance that calls:
getClass().getResourceAsStream(resName)

will load the requested resource in the way I define in my
CustomClassLoader.

My code contains the following:
ClassLoader classLoader = new CustomClassLoader
(ClassLoaderTestActivity.class.getClassLoader()); // Create my own
class loader with the default class loader as parent.

Thread.currentThread().setContextClassLoader(classLoader); // This is
just for testing

TestClass test = (TestClass)Class.forName("com.test.TestClass", true,
classLoader).newInstance() ;

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.

My only assumption so far is that since my CustomClassLoader only
overrides specific functionality, and the ClassLoader that actually
calls 'defineClass' is the default one, the TestClass instance is
never associated with my ClassLoader.

Any help would be highly appreciated.
Thanks,
Lior
-- 
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