Sunil Kumar
Sunil Kumar

Reputation: 5657

Which class loader will be parent of class loader created inside a thread?

Suppose my application class loader is CL_A.

I have a user class loader CL_B , obvious child of CL_A.

Now my application is running in a Thread associated with CL_B class loader.And inside this thread I have one more User class loader CL_C.

Now which class loader CL_A or CL_B is the parent class loader of CL_C ? If CL_B,why not CL_A ?

Upvotes: 0

Views: 50

Answers (1)

Friwi
Friwi

Reputation: 492

The answer is CL_B as each classloader's parent is the classloader that loaded the class that initialized the classloader. Each classloader only knows his direct parent.

The only important thing is, that your thread's class gets loaded by CL_B, then CL_C's parent is CL_B.

Upvotes: 1

Related Questions