Originally nb-javac  (see Overview: nb-javac) was maintained in a separate repository: hg.netbeans.org/main/nb-javac - Since version 15, it is hosted by Arvind's team on GitHub: https://github.com/oracle/nb-javac - "nb-javac" consists of two libraries ( nb-javac-api.jar  and nb-javac-impl.jar ) located in "extra" cluster, see: Overview: NetBeans Structure.

What does nb-javac do that's different to vanilla javac?

A few years back, the NetBeans team wrote a page describing what nb-javac does in addition to/differently to vanilla javac. Some of the things listed above are not part of nb-javac anymore (e.g., cancelling and some part of the error recovery paragraph) but it still gives a reasonable overview and is good to get an idea what kinds of things nb-javac does. Here is the copy ready to be made up to date:

Recompleting Symbols from Sources

Consider the following usecase: let there be two classes, A and B available both in source code and (up-to-date) class files. These classes are interdependent (each refers to the other). Let there be a refactoring, that needs to work over both these files. The refactoring needs Trees (to access method bodies, to get offsets, etc), and these trees need to be attributed.

There are the following ways for the refactoring to work:

Recompleting of Symbols is also used:

The ability to recomplete a Symbol from source file is one of the most important part of the NetBeans fork/patch.


Stable annonymous innerclass numbers

When a Scope is created, the corresponding Tree is duplicated and attributed. This may lead into incorrect Symbols created for anonymous innerclasses. It is necessary to ensure that the anonymous innerclass numbers will match the numbers that would be produced by a batch compiler. This needs to be ensured even in case when the Scope is created before the tree is attributed.


Error Recovery

While editing, the code in the editor contains compilation errors almost all the time. It is therefore unacceptable to loose e.g. code completion only because of a missing semicolon, or because of an (unrelated) unresolvable symbol.

The list of current changes includes (not an exhaustive list):


Cancellability

NetBeans need to be able to stop javac processing even inside one phase (parse/member enter/attribute). This is used e.g. when the user types into the editor, and the current instance of javac is already processing an obsolette source code. Then, there is no point in wasting time and memory in continuing the processing of the file.


Inferring Binary Names

Consider file A.java, containing classes B and C, and file D.java, referencing B and C. If file D.java is being parsed (and class file for B and C do not exist yet), the javac is currently unable to locate file A.java. Yet, the IDE may have the information about the content of the A.java file. So, the problem is how to pass this information into the javac. ClassNamesForFileOraculum is currently used for this.


Support for Reparsing Method Bodies

If the user changes are contained only inside one method body, it is desirable to reparse only the body of the one method. This leads into faster reparse times and less garbage on the heap. The NetBeans' fork/patch contains support for reparsing methods bodies.


Repair

In the NetBeans' fork/patch, there is a new phase, Repair, running after Flow. For source code with compilation errors, this phase converts the "uncompilable" trees into "compilable" trees.

New attributes are added to the classfiles to keep:


Annotation Processing

In vanilla javac, new Symbols are created for classes/methods/fields in the sources for each annotation processing round. This is rewritten in the NetBeans' fork/patch to use the symbol recompleting. Symbols, once created, are used in all rounds on annotation processing and also for the final compilation. Annotation processing is also supported when completing symbols from sources. Exceptions thrown by annotation processors are logged, but do not stop the compilation.


IDE Mode

A special option, "ideMode", has been introduced by the NetBean's fork/patch to improve javac behavior in the following cases:


Miscallenous