I've accepted this statement for so many years but have never asked why it is the case. When two classloaders load the same binary bits of a class (e.g. Foo for discussion sake) from the filesystem, are the two original "bit representations" of Foo decorated with information of the classloader that loaded it ?
More or less, yes. Loading a class creates a Class object; that Class knows which loader loaded it. A given ClassLoader will load only one class by a given name. The VM Spec talks about class identity being determined by a (name, ClassLoader) pair; the Class object provides that association.
Each object has a reference to its Class object, and two objects loaded by different loaders can belong to classes with identical names, but distinct Class objects; in this case the two objects are said to belong to different classes.
Originally posted by Pho Tek: I would like to ask another question on classloading.
You will have a bigger chance of getting good answers by asking it in a new thread, with a matching subject line.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus