实际上,我相信默认情况下,Ant会尝试直接使用以下代码执行Java编译器类:
try { Class c = Class.forName ("com.sun.tools.javac.Main"); Object compiler = c.newInstance (); Method compile = c.getMethod ("compile", new Class [] {(new String [] {}).getClass ()}); int result = ((Integer) compile.invoke(compiler, new Object[] {cmd.getArguments()})) .intValue (); return (result == MODERN_COMPILER_SUCCESS); } catch (Exception ex) { if (ex instanceof BuildException) { throw (BuildException) ex; } else { throw new BuildException("Error starting modern compiler", ex, location); } }
代码来自这里 。
这意味着,如果库tools.jar位于Ant的当前类路径上,它将拾取该类并启动它。这导致javac.exe可以重命名为您想要的任何名称,它仍然可以工作。因此,要回答您的问题,它实际上不执行任何“ javac.exe”。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)