Class JavaCompiler

All Implemented Interfaces:
Generator, Renamable, ResourceProvider

public class JavaCompiler extends JavaTool

The JavaCompiler generator provides two types of resources.

  1. The JavaSourceFiles of the project as configured with addSources(FileTree) in response to a ResourceRequest with ResourceType JavaTypes.JavaSourceTreeType (or a more general type).

  2. The ClassFiles that result from compiling the sources in response to a ResourceRequest with ResourceType JavaTypes.ClassTreeType (or a more general type such as JavaTypes.CodeContributionType).

No attempt has been made to define types for the options of the java compiler. Rather, the options are passed as strings as the ToolProvider API suggests. There are some noteworthy exceptions for options that are directly related to resource types (files, directory trees, paths) from the builder context.

If no "-g..." option is specified, the generator adds "-g" and thus generates full debug information. If you want to restore the default behavior of the java compiler, you have to specify "-g:[lines, source]" explicitly.

JPMS support

When the sources contain a module-info.java, or when the module mode is set to ModuleMode.MODULE, compilation uses the module-path (--module-path) for code contributions that contain a module descriptor. Non-modular code contributions remain on the classpath (-cp). In ModuleMode.AUTO mode (the default), module compilation is activated automatically when a module-info.java is found among the sources.