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
com.sun.tools.javac.Main 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 {
            Class.forName(MODERN_COMPILER);
            return true;
        } catch (ClassNotFoundException cnfe) {
            try {
                ClassLoader cl =
CompilerAdapterFactory.class.getClassLoader();
                if (cl != null) {
                    cl.loadClass(MODERN_COMPILER);
                    return true;
                }
            } catch (ClassNotFoundException cnfe2) {
                // Ignore Exception
            }
        }
        return false;
    }
 

, which is pretty much a nonsense implementation as 

     Class.forName('') is the same as
     CompilerAdapterFactory.class.getClassLoader().loadClass('') 

both will fail or both will succeed.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org

Reply via email to