其中的javac.exe用于蚂蚁javac任务?(Which javac.exe is used b

2019-06-25 08:16发布

我面临的一个问题。 我改名javac.exe我的机器上,发现蚂蚁javac任务依然正常工作。

是否有人从那里得到它的文件javac.exe知道吗?

Answer 1:

其实,我认为,在默认情况下蚂蚁试图直接使用此代码执行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是关于一些蚂蚁的当前classpath,它会皮卡类,并启动它。 这导致在事实的javac.exe可以被重命名为任何你想要的,它仍然会正常工作。 因此,要回答你的问题,它实际上没有执行任何“的javac.exe”的。

有javac任务的其他实现,但我认为这是一个默认为所有的编译器1.3+



Answer 2:

你可以尝试开始在这里检查一下是什么在全局配置build.compiler财产,也可以在其他地方指点



文章来源: Which javac.exe is used by ant javac task?