Re: a problem about understanding jboss
david wolf wrote On 11/09/06 12:54,:
I was reading the jboss docs and came across the following statement:
'Most developers know that the type of a class in Java is a function of
the fully qualified name of the class. However the type is also a
function of the java.lang.ClassLoader that is used to define that
class."
What does this mean?
It means that if you have two ClassLoaders, L1 and L2,
and each of them loads a class named com.dot.SomeClass,
there are two different classes named com.dot.SomeClass
floating around in the JVM. Even if the two classes have
exactly the same bytecode -- even if they were loaded from
the exact same .class file -- they are different classes
because one is in L1's "domain" and the other is in L2's.
I mean what does the function mean in this statement?
They're using "function of" in a rather loose pseudo-
mathematical sense: If changing X produces a change in Y,
we may say that Y "is a function of" X. The area of a
square "is a function of" the length of its sides; your
chance of winning at poker "is a function of" the other
players' skill; the attentiveness of a salesman "is a
function of" how much he thinks he can sell you.
IMHO the quoted use is not a particularly good one.
The identity of a loaded class *is* the combination of
its fully-qualified name and the ClassLoader that loaded
it, and it would be more straightforward simply to say so
instead of to drag in this "function of" verbiage. True,
the identity function is a function (the identity function
maps a thing to itself: X is a function of X), so what's
said isn't wrong -- it's just wordier than it needs to be.
--
Eric.Sosman@sun.com