gudii9
asked on
ClassLoaders in java
Two objects loaded by different class loaders are never equal even if they carry the same values.
This means a class is uniquely identified in the context of the associated classloader. This applies to singletons too, where each classloader will have its own singleton.
I was reading as above. I have not understood what it means.
please advise
Any links resources ideas highly appreciated. Thanks in advance
I do not think two classloaders(on the same JVM) can load the same object , it wld create conflicts when trying to access the class. But the same object on different JVMs is possible.
It means that a class can be loaded by two different classloaders, and in the context of the JVM these classes are considered *not* the same, even if, in fact, they are byte-for-byte the same class. So if you have a class A which is loaded by both classloader X and classloader Y then, as far as the JVM is concerned, you have *two different* classes. This is what the phrase
a class is uniquely identified in the context of the associated classloadermeans.
ASKER
how is classloader is different or related to JVM. In which practical scenario this situation happens? I never come across this scenario earlier. please advise
All classloaders are loaded by the JVM. When the JVM starts it loads the bootstrap classloader, and this in turn loads all other classes, including the rest of the classloaders that will load their own classes and so on.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.