W3cubDocs

/OpenJDK 21

Interface JavaCompiler.CompilationTask

All Superinterfaces:
Callable<Boolean>
All Known Implementing Classes:
JavacTask
Enclosing interface:
JavaCompiler
public static interface JavaCompiler.CompilationTask extends Callable<Boolean>
Interface representing a future for a compilation task. The compilation task has not yet started. To start the task, call the call method.

Before calling the call method, additional aspects of the task can be configured, for example, by calling the setProcessors method.

Method Summary

Modifier and Type Method Description
void addModules(Iterable<String> moduleNames)
Adds root modules to be taken into account during module resolution.
Boolean call()
Performs this compilation task.
void setLocale(Locale locale)
Sets the locale to be applied when formatting diagnostics and other localized data.
void setProcessors(Iterable<? extends Processor> processors)
Sets processors (for annotation processing).

Method Details

addModules

void addModules(Iterable<String> moduleNames)
Adds root modules to be taken into account during module resolution. Invalid module names may cause either IllegalArgumentException to be thrown, or diagnostics to be reported when the task is started.
Parameters:
moduleNames - the names of the root modules
Throws:
IllegalArgumentException - may be thrown for some invalid module names
IllegalStateException - if the task has started
Since:
9

setProcessors

void setProcessors(Iterable<? extends Processor> processors)
Sets processors (for annotation processing). This will bypass the normal discovery mechanism.
Parameters:
processors - processors (for annotation processing)
Throws:
IllegalStateException - if the task has started

setLocale

void setLocale(Locale locale)
Sets the locale to be applied when formatting diagnostics and other localized data.
Parameters:
locale - the locale to apply; null means apply no locale
Throws:
IllegalStateException - if the task has started

call

Boolean call()
Performs this compilation task. The compilation may only be performed once. Subsequent calls to this method throw IllegalStateException.
Specified by:
call in interface Callable<Boolean>
Returns:
true if and only all the files compiled without errors; false otherwise
Throws:
RuntimeException - if an unrecoverable error occurred in a user-supplied component. The cause will be the error in user code.
IllegalStateException - if called more than once

© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.compiler/javax/tools/JavaCompiler.CompilationTask.html