ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <co...@cortexebusiness.com.au>
Subject RE: Ant Classloader - Context Classloader
Date Tue, 24 Jul 2001 03:07:23 GMT
> From: Stephane Bailliez [mailto:sbailliez@imediation.com]
>
> > -----Original Message-----
> > From: cmanolache@yahoo.com [mailto:cmanolache@yahoo.com]
> >
> > I think it's important to _use_ the context classloader, not
> > only to set it ( i.e. in all Class.forName or similar ).
>
> > Assuming ant is run inside a webapp or similar environment (
> > where user code is loaded in a separate classloader ), there are few
> > cases where the current code will not work.
>
> What are some known problems about the use of Class.forName()
> instead of the
> context classloader ?

I can give you another example from JNDI - when you use the InitialContext,
you pass it the classname of a factory object. Now since the InitialContext
is part of the JDK, if it were to use Class.forName, you would only be able
to find factory classes in the system classpath. This code, however, uses
the context classloader associated with the current thread which allows a
class in the JDK to instantiate a class not on the system classpath. That is
cool.

Unfortunately this is not widespread. JAXP, for instance uses Class.forName
to load the SAXPArser class you specify.

Conor


Mime
View raw message