> From: Stephane Bailliez [mailto:[EMAIL PROTECTED] > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > > > 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
