ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Lund <>
Subject Classloading and CompilerAdapter problem
Date Wed, 08 Jul 2009 12:17:09 GMT
Hi All

I'm not sure if this is a bug, or just works as it should:

but when using ant to invoke the java runtime compiler this fails if ant is loaded from a parent
ClassLoader to tools.jar even though tools.jar is in the current context
classloader for the thread.

It fails in finding the compiler:->

>>From CompilerAdapterFactory:
 private static boolean doesModernCompilerExist() {
        try {
            return true;
        } catch (ClassNotFoundException cnfe) {
            try {
                ClassLoader cl =
                if (cl != null) {
                    return true;
            } catch (ClassNotFoundException cnfe2) {
                // Ignore Exception
        return false;

, which is pretty much a nonsense implementation as 

     Class.forName('') is the same as

both will fail or both will succeed.

but why not use the Thread.currentThread.getContextClassLoader()
That would lead to the most flexible solution.
Hans Lund      

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message