Context class loader and custom class loader
Hi,
I need clarification between a Custom class loader and a (thread) context class loader. Here is my problem:
1. Say I have a custom class loader XLoader used to load class X. Class X is not in the classpath and we need to use XLoader for that. Class X has reference to class Y. I load class X using class.forName("X", true, new XLoader()). As per the documentation, both the context class loader and the custom class loader are used to load the needed classes. So which one is used here to load class Y ?
2. Also, impl of loadClass method is such that it checks to see if a class has been loaded already by the given class loader. If not, it delegates the loading to its parent loader and so on up the hierarchy. Is there any example, where we can see that instead of current loader delegating the loading of a class to its parent, it has used context class loader (by calling getContextClassLoader()) to load the class?