Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Context class loader and custom class loader

radiatejavaMay 18 2005 — edited Jul 8 2005
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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 5 2005
Added on May 18 2005
2 comments
328 views