Hi,
Your understanding is wrong: there can be one class X for each
classloader.  Your practice of using multiple classes with the same
fully-qualified name in the same application is questionable, as it can
easily lead to human errors.

Yoav Shapira
Millennium Research Informatics


>-----Original Message-----
>From: Eric M. Kascic [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, March 24, 2004 10:49 AM
>To: [EMAIL PROTECTED]
>Subject: Esoteric class loading question/loading constraints/loader
>constraints
>
>I am somewhat stupified by some class loading results I am seeing from
>Tomcat.  If I put some class X that refers to class Y in my servlet
jar,
>the WebappClassLoader loads X.  I DO NOT put class Y in my servlet.jar.
>Instead, I put class Y in a jar that is put in common/lib.  When Y is
>finally loaded as a result of X being loaded, the StandardClassLoader
>loads it (as the WebappClassLoader delegates to the
>StandardClassLoader).
>
>Now the stupifying part: class Y has a reference to a class X, *BUT* I
>have put that class X in Y's jar.  Bottom line, there is to be two
>different class X's, one loaded by WebappClassLoader (for the specific
>webapp) and one by the StandardClassLoader (for common).  Based upon my
>understanding of how the JVM tries to ensure "type safety" across
>ClassLoaders,  StandardClassLoader loading the second version of class
X
>should fail with a LinkageError - because the defining loader for X is
>already WebappClassLoader, and here we are trying to say the defining
>loader is now StandardClassLoader.
>
>The rub: Tomcat does not throw a LinkageError.  Instead it goes ahead
>and loads the second class X just fine.  Doing an output of
>getClass().getClassLoader() in the constructors of both class X's shows
>that is being loaded in two different defining loaders.  Am I missing
>something?  Given that the so-called loader/loading constraints are
>enforced by the JVM, not any particular ClassLoader/app, I am
>dumbfounded by this behavior.
>
>Thanks in advance for any insights.



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to