Why can't a class be unloaded without unloading the class loader?

The answer to 'unloading classes in java' says -

"The only way a class can be unloaded is to use the Classloader loader - garbage collection." I looked at JLS but could not understand it

Why is this so?

+5
source share
1 answer

The class is unloaded only during garbage collection, and for this there should not be any references to it. And the class loader keeps a reference to every class that it loads.

+13
source

All Articles