标准的Sun javac能做增量编译吗? [英] Can standard Sun javac do incremental compiling?

查看:641
本文介绍了标准的Sun javac能做增量编译吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我开始使用Eclipse的java编译器,因为它明显比标准javac快。我被告知,它的速度更快,因为它执行增量编译。但我仍然有点不确定这,因为我找不到任何权威的文档关于 - eclispse和太阳的编译器增量功能。是的,Sun的编译器总是编译每个源文件,Eclipse的编译器只编译更改的文件和受这种更改影响的文件?



编辑:我不使用Eclipse自动建立功能,但我设置

  -Dbuild.compiler = org.eclipse.jdt.core.JDTCompilerAdapter 

解决方案


是的,Sun的编译器总是编译每个源文件,Eclipse的编译器只编译更改的文件那些受这种变化影响的人?


我相信你对这两个数字都是正确的。



您当然可以强制Eclipse重新编译所有内容。



但是方程式的另一部分是Java构建工具只能编译已更改的类及其依赖类的树。



EDIT



在Ant中,可以通过两种方式进行增量编译:


  • 默认情况下, < javac> 任务比较时间戳 .java 和相应的 .class 文件,并且只告诉Java编译器重新编译比它们对应的对象文件或根本没有对象文件。


  • < depend> 任务还考虑类之间的依赖性,分析嵌入在 .class 文件中的依赖项信息。确定 .class 文件过期后,< depend> 任务删除它们,所以以下< javac> 任务将重新编译它们。然而,这不完全是愚蠢的。例如,对源代码的大量改变可以导致< depend> 任务可以分析陈旧的依赖性。在 .class 文件格式中,某些类型的依赖(例如对静态常量)不明显。



    了解为什么Ant < depend> 不是万无一失的,请阅读文档



Recently I started to use Eclipse's java compiler, because it is significantly faster than standard javac. I was told that it's faster because it performs incremental compiling. But I'm still a bit unsure about this since I can't find any authoritative documentation about both - eclispse's and sun's - compilers "incremental feature". Is it true that Sun's compiler always compiles every source file and Eclipse's compiler compile only changed files and those that are affected by such a change?

Edit: I'm not using Eclipse autobuild feature but instead I'm setting

-Dbuild.compiler=org.eclipse.jdt.core.JDTCompilerAdapter

for my ant builds.

解决方案

Is it true that Sun's compiler always compiles every source file and Eclipse's compiler compile only changed files and those that are affected by such a change?

I believe that you are correct on both counts.

You can of course force Eclipse to recompile everything.

But the other part of the equation is that Java build tools like Ant and Maven are capable of only compiling classes that have changed, and their tree of dependent classes.

EDIT

In Ant, incremental compilation can be done in two ways:

  • By default the <javac> task compares the timestamps of .java and corresponding .class files, and only tells the Java compiler to recompile source files that are newer than their corresponding object files, or that don't have an object file at all.

  • The <depend> task also takes into account dependencies between classes, which it determines by reading and analysing the dependency information embedded in the .class files. Having determined which .class files are out of date, the <depend> task deletes them so a following <javac> task will recompile them. However, this is not entirely fool-proof. For example, extensive changes to the source code can lead to the <depend> task may be analysing stale dependencies. Also certain kinds of dependency (e.g. on static constants) are not apparent in the .class file format.

    To understand why Ant <depend> is not fool-proof, read the "Limitations" section of the documentation.

这篇关于标准的Sun javac能做增量编译吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆