Interface JctCompilation
This provides access to a number of useful pieces of information including the file manager used for the compilation, compiler logs, and diagnostics.
- Since:
- 0.0.1
- Author:
- Ashley Scopes
-
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable ModuleContainerGroup
Get the module container group for the annotation processor module path.default @Nullable PackageContainerGroup
Get the package container group for the annotation processor path.Get the command line arguments that were passed to the compiler.default @Nullable OutputContainerGroup
Get the output container group for class outputs.default @Nullable PackageContainerGroup
Get the package container group for the class path.Get the compilation units used in the compilation.Get the diagnostics that were reported by the compilation, in the order that they were reported.Get the file manager that was used to store and manage files.default @Nullable ModuleContainerGroup
Get the module container group for the module path.default @Nullable ModuleContainerGroup
Get the module container group for the module source path.default @Nullable OutputContainerGroup
Get the output container group for the native header file outputs.Get the lines of output produced by the compiler, if any were captured.default @Nullable ModuleContainerGroup
Get the module container group for the patch module path.default @Nullable PackageContainerGroup
Get the package container group for the platform class path (a.k.a. the bootstrap class path).default @Nullable OutputContainerGroup
Get the output container group for source outputs.default @Nullable PackageContainerGroup
Get the package container group for the source path.default @Nullable ModuleContainerGroup
Get the module container group for all system modules that are part of the JDK distribution.default @Nullable ModuleContainerGroup
Get the module container group for the upgrade module path.boolean
Determine if warnings were treated as errors.default boolean
Determine if the compilation was a failure or not.boolean
Determine if the compilation was successful or not.
-
Method Details
-
getArguments
Get the command line arguments that were passed to the compiler.- Returns:
- the command line arguments.
- Since:
- 0.5.0
-
isFailOnWarnings
boolean isFailOnWarnings()Determine if warnings were treated as errors.- Returns:
true
if warnings were treated as errors, orfalse
otherwise.
-
isSuccessful
boolean isSuccessful()Determine if the compilation was successful or not.- Returns:
true
if successful, orfalse
if not successful.
-
isFailure
Determine if the compilation was a failure or not.- Returns:
true
if not successful, orfalse
if successful.
-
getOutputLines
Get the lines of output produced by the compiler, if any were captured.This is separate to diagnostics.
- Returns:
- the lines of output.
-
getCompilationUnits
Get the compilation units used in the compilation.- Returns:
- the compilation units.
-
getDiagnostics
Get the diagnostics that were reported by the compilation, in the order that they were reported.- Returns:
- the diagnostics
-
getFileManager
Get the file manager that was used to store and manage files.This can be used to obtain a classloader for any compiled sources, which can then be used to reflectively test what the compiler produced.
- Returns:
- the file manager.
-
getClassOutputs
Get the output container group for class outputs.This usually consists of any
*.class
files produced by the compiler, and is equivalent totarget/classes
in a Maven project.- Returns:
- the output container group, or
null
if it does not exist.
-
getSourceOutputs
Get the output container group for source outputs.This consists of any generated source code created by annotation processors, and is equivalent to
target/generated-sources
in a Maven project.- Returns:
- the output container group, or
null
if it does not exist.
-
getClassPath
Get the package container group for the class path.This represents the class path used for compilation.
- Returns:
- the package container group, or
null
if it does not exist.
-
getSourcePath
Get the package container group for the source path.This is equivalent to
src/main/java
andsrc/main/resources
in a Maven project.- Returns:
- the package container group, or
null
if it does not exist.
-
getAnnotationProcessorPath
Get the package container group for the annotation processor path.- Returns:
- the package container group, or
null
if it does not exist.
-
getAnnotationProcessorModulePath
Get the module container group for the annotation processor module path.- Returns:
- the module container group, or
null
if it does not exist.
-
getPlatformClassPath
Get the package container group for the platform class path (a.k.a. the bootstrap class path).You generally do not need to use this. The platform class path mechanism has been mostly replaced by the use of the system modules path as of Java 11. It is simply provided for backwards compatibility.
- Returns:
- the package container group, or
null
if it does not exist.
-
getNativeHeaderOutputs
Get the output container group for the native header file outputs.If you invoke
javac
with the-H
flag, then this represents the directory that C/C++ header file stubs for JNI are written to.- Returns:
- the output container group, or
null
if it does not exist.
-
getModuleSourcePath
Get the module container group for the module source path.Many build tools do not provide a direct equivalent of this mechanism as of now, but this is a source path introduced in Java 9 that allows specifying multiple named JPMS modules to compile under a single compilation invocation.
For example, you may use this in a project to compile an API module, a default implementation module, and a module containing unit tests all together.
- Returns:
- the module container group, or
null
if it does not exist.
-
getUpgradeModulePath
Get the module container group for the upgrade module path.You generally will not need to use this, as this is a mechanism used to upgrade modules in-place incrementally with fixes without redistributing the entire application.
- Returns:
- the module container group, or
null
if it does not exist.
-
getSystemModules
Get the module container group for all system modules that are part of the JDK distribution.This will usually just point to the Java standard library.
- Returns:
- the module container group, or
null
if it does not exist.
-
getModulePath
Get the module container group for the module path.This is equivalent to the class path, but holds any JPMS modules.
- Returns:
- the module container group, or
null
if it does not exist.
-
getPatchModulePath
Get the module container group for the patch module path.You generally will not need to use this. It consists of patchable module sources that can be used to inject additional classes into a module. This can be used for cases like unit tests where you wish to embed the unit test classes into the existing application module to exploit features such as package private access.
- Returns:
- the module container group, or
null
if it does not exist.
-