ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephane Bailliez <>
Subject RE: Ant Classloader - Context Classloader
Date Mon, 23 Jul 2001 15:07:37 GMT
> -----Original Message-----
> From: []
> 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 read here and there some bug reports in some JDK, but this is not that
clear to me.

The class.forName is supposed to use the caller classloader from what I can
see in the source.
However it is not clear for me what the caller classloader is and if it
works in all cases.
Assuming you are in class A part of the webapp (and thus loaded by the
context classloader), doing a Class.forName in a method of class A, are we
supposed to have:
 context classloader == ClassLoader.getCallerClassLoader() ==
A.class.getClassLoader() ?

When I browsed through Turbine code I was amazed to see all calls to
Class.forName(String) because I had in my mind: Class.forName(String) ==
evil. But I'm unable to give Jason some reasonable arguments to switch to
replace these calls by taking the 3 params Class.forName and use the context
classloader explicitely.

 St├ęphane Bailliez 
 Software Engineer, Paris - France 
 iMediation - 
 Disclaimer: All the opinions expressed above are mine and not those from my

View raw message