Why does Eclipse use its own compiler (ECJ) instead of Javac?-zhihu
Several factors, I suppose.
First, when Eclipse started writing its compiler, javac was not open source and was a closed-source component in the Sun JDK. If Eclipse wanted to use it, it could only treat it as an external command or external library, and not customize it at the source code level.
And at the time, javac provided good support for various language services (such as syntax highlighting and auto-completion) when embedded in an IDE, but it was still just a compiler. Therefore, it was not suitable for providing services beyond compilation to the IDE.
Second, to provide various convenient functions for Java, the Eclipse IDE needs to have syntax highlighting, syntax/semantic analysis, and corresponding error prompts, auto-completion, Code Model, and so on. Once these features are implemented, it is only a step away from a complete Java source code -> byte code compiler – byte code generation. This step is basically the simplest part of the Java compiler, so why not do it?
Read more here: Source link
