They should be the same thing as far as any of the docs I have read,
but the observed difference is that Class.forName maintains a cache
of Class objects keyed by name. Once a class is loaded by a given
ClassLoader, it is that version of the class that is returned regardless
of what the ClassLoader passed to Class.forName will return. We
have run up against this with reloading EJBs and RMI proxies as the
RMI subsystem makes use of the Class.forName(..., ClassLoader)
call when dealing with MarshalledObjects.

xxxxxxxxxxxxxxxxxxxxxxxx
Scott Stark
Chief Technology Officer
JBoss Group, LLC
xxxxxxxxxxxxxxxxxxxxxxxx
----- Original Message -----
From: "Hiram Chirino" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 02, 2002 7:29 PM
Subject: [JBoss-dev] getContextClassLoader() vs. Class.forName(x,y,z)


> Question for you classloading feaks out there, what is the difference
> between:
>
> x = "some.class.name";
> Thread.currentThread().getContextClassLoader().loadClass(x);
>
> and
>
> x = "some.class.name";
> Class.forName(x, false,
>      Thread.currentThread().getContextClassLoader());
>
> Peter Levart, submitted a patch that replaces a statment like the first
with
> a statment like the seconds.   It's supposed to allow "loading
> array class for a base class that hasn't been loaded yet."
>
> My thing is, it seems like they do the same thing.  What's the difference?
>
> Regards,
> Hiram



_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to