| Modifier and Type | Field and Description |
|---|---|
| public static final String[] | ALLOWED_JDKS
The valid targetBytecode values. |
| public static final int | ASM_API_VERSION
The ASM API version used when loading/parsing classes and generating proxy adapter classes. |
| private BytecodeProcessor | |
| private List | classpath
Classpath for use during compilation |
| private final List | |
| private boolean | debug
If true, debugging code should be activated |
| public static final CompilerConfiguration | DEFAULT
A convenience for getting a default configuration. |
| public static final String | |
| private String | defaultScriptExtension
extension used to find a groovy file |
| private Set | disabledGlobalASTTransformations
Global AST transformations which should not be loaded even if they are defined in META-INF/services/org.codehaus.groovy.transform.ASTTransformation files. |
| public static final String | GROOVYDOC
Optimization Option for enabling attaching groovydoc as AST node metadata. |
| public static final String | INVOKEDYNAMIC
Optimization Option for enabling |
| public static final String | JDK10
This ( |
| public static final String | JDK11
This ( |
| public static final String | JDK12
This ( |
| public static final String | JDK13
This ( |
| public static final String | JDK14
This ( |
| public static final String | JDK15
This ( |
| public static final String | JDK16
This ( |
| public static final String | JDK17
This ( |
| public static final String | JDK4
This ( |
| public static final String | JDK5
This ( |
| public static final String | JDK6
This ( |
| public static final String | JDK7
This ( |
| public static final String | JDK8
This ( |
| public static final String | JDK9
This ( |
| public static final Map | JDK_TO_BYTECODE_VERSION_MAP
JDK version to bytecode version mapping. |
| private Map | jointCompilationOptions
options for joint compilation (null by default == no joint compilation) |
| public static final String | MEM_STUB
Joint Compilation Option for enabling generating stubs in memory. |
| private int | minimumRecompilationInterval
sets the minimum of time after a script can be recompiled. |
| private Map | optimizationOptions
options for optimizations (empty map by default) |
| private PrintWriter | output
The |
| public static final String | PARALLEL_PARSE
Optimization Option for enabling parallel parsing. |
| private boolean | parameters
If true, generates metadata for reflection on method parameters |
| private ParserPluginFactory | |
| public static final String | POST_JDK5
This constant is for comparing targetBytecode to ensure it is set to JDK 1.5 or later. |
| public static final String | PRE_JDK5
This constant is for comparing targetBytecode to ensure it is set to an earlier value than JDK 1.5. |
| private boolean | previewFeatures
Whether the bytecode version has preview features enabled (JEP 12) |
| private boolean | recompileGroovySource
if set to true recompilation is enabled |
| public static final String | RUNTIME_GROOVYDOC
Optimization Option for enabling attaching |
| private String | scriptBaseClass
Base class name for scripts (must derive from Script) |
| private Set | scriptExtensions
extensions used to find a groovy files |
| private String | sourceEncoding
Encoding for source files |
| private String | targetBytecode
sets the bytecode version target |
| private File | targetDirectory
Directory into which to write classes |
| private int | tolerance
The number of non-fatal errors to allow before bailing |
| private boolean | verbose
If true, the compiler should produce action information |
| private int | warningLevel
See |
| Access | Constructor and Description |
|---|---|
| public | |
| public | CompilerConfiguration(final CompilerConfiguration
The configuration to copy. configuration)Copy constructor. |
| public | CompilerConfiguration(final Properties
The properties to get flag values from. configuration)Sets the configuration flags/settings according to values from the supplied |
| Modifier and Type | Method and Description |
|---|---|
| public CompilerConfiguration | Returns: this configuration instancethe list of customizers to be added customizers)Adds compilation customizers to the compilation process. |
| public void | configure(final Properties
The properties to get flag values from. configuration)Method to configure a CompilerConfiguration by using Properties. |
| public BytecodeProcessor | |
| public List | |
| public List | Returns: the customizers (always not null)Returns the list of compilation customizers. |
| public boolean | |
| public String | |
| public Set | Returns: a list of global AST transformation fully qualified class namesReturns the list of disabled global AST transformation class names. |
| public Map | Returns: the optionsGets the joint compilation options for this configuration. |
| public int | |
| public Map | Returns: the options (always not null)Gets the optimization options for this configuration. |
| public PrintWriter | |
| public boolean | |
| public ParserPluginFactory | |
| public boolean | |
| public String | |
| public Set | |
| public String | |
| public String | Returns: bytecode compatibility levelReturns the compiler bytecode compatibility level. |
| public File | |
| public int | |
| public boolean | |
| public int | |
| public boolean | |
| public boolean | |
| public static boolean | Returns: true if the bytecode version is JDK 1.5+The parameter can take one of the values in bytecodeVersion)ALLOWED_JDKS.Checks if the specified bytecode version string represents a JDK 1.5+ compatible bytecode version. |
| public static boolean | Returns: true if the bytecode version is JDK 1.7+The parameter can take one of the values in bytecodeVersion)ALLOWED_JDKS.Checks if the specified bytecode version string represents a JDK 1.7+ compatible bytecode version. |
| public static boolean | Returns: true if the bytecode version is JDK 1.8+The parameter can take one of the values in bytecodeVersion)ALLOWED_JDKS.Checks if the specified bytecode version string represents a JDK 1.8+ compatible bytecode version. |
| public static boolean | Returns: true if the bytecode version is JDK 9.0+The parameter can take one of the values in bytecodeVersion)ALLOWED_JDKS.Checks if the specified bytecode version string represents a JDK 1.8+ compatible bytecode version. |
| public boolean | Returns: preview featuresWhether the bytecode version has preview features enabled (JEP 12) |
| public boolean | |
| public void | |
| public void | |
| public void | setClasspathList(final List<String>
list of strings containing the classpath parts parts)sets the classpath using a list of Strings |
| public void | |
| public void | |
| public void | setDisabledGlobalASTTransformations(final Set<String>
a set of fully qualified class names of global AST transformations
which should not be loaded. disabledGlobalASTTransformations)Disables the specified global AST transformations. |
| public void | setJointCompilationOptions(final Map<String, Object>
the options options)Sets the joint compilation options for this configuration. |
| public void | |
| public void | setOptimizationOptions(final Map<String, Boolean>
the options. options)Sets the optimization options for this configuration. |
| public void | setOutput(final PrintWriter output)
Deprecated
not used anymore, has no effect
Sets the output writer.
|
| public void | |
| public void | |
| public void | setPreviewFeatures(final boolean
whether to support preview features previewFeatures)Sets whether the bytecode version has preview features enabled (JEP 12). |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | setTargetBytecode(final String
the bytecode compatibility level version)Sets the bytecode compatibility level. |
| private void | |
| public void | |
| public void | |
| private void | |
| public void | setTolerance(final int tolerance)
Sets the error tolerance, which is the number of non-fatal errors (per unit) that should be tolerated before compilation is aborted. |
| public void | |
| public void |
| ALLOWED_JDKS | back to summary |
|---|---|
| public static final String[] ALLOWED_JDKS The valid targetBytecode values. | |
| ASM_API_VERSION | back to summary |
|---|---|
| public static final int ASM_API_VERSION The ASM API version used when loading/parsing classes and generating proxy adapter classes. | |
| bytecodePostprocessor | back to summary |
|---|---|
| private BytecodeProcessor bytecodePostprocessor | |
| classpath | back to summary |
|---|---|
| private List<String> classpath Classpath for use during compilation | |
| compilationCustomizers | back to summary |
|---|---|
| private final List<CompilationCustomizer> compilationCustomizers | |
| debug | back to summary |
|---|---|
| private boolean debug If true, debugging code should be activated | |
| DEFAULT | back to summary |
|---|---|
| public static final CompilerConfiguration DEFAULT A convenience for getting a default configuration. Do not modify it!
See | |
| DEFAULT_SOURCE_ENCODING | back to summary |
|---|---|
| public static final String DEFAULT_SOURCE_ENCODING | |
| defaultScriptExtension | back to summary |
|---|---|
| private String defaultScriptExtension extension used to find a groovy file | |
| disabledGlobalASTTransformations | back to summary |
|---|---|
| private Set<String> disabledGlobalASTTransformations Global AST transformations which should not be loaded even if they are defined in META-INF/services/org.codehaus.groovy.transform.ASTTransformation files. By default, none are disabled. | |
| GROOVYDOC | back to summary |
|---|---|
| public static final String GROOVYDOC Optimization Option for enabling attaching groovydoc as AST node metadata. | |
| INVOKEDYNAMIC | back to summary |
|---|---|
| public static final String INVOKEDYNAMIC Optimization Option for enabling | |
| JDK10 | back to summary |
|---|---|
| public static final String JDK10 This ( | |
| JDK11 | back to summary |
|---|---|
| public static final String JDK11 This ( | |
| JDK12 | back to summary |
|---|---|
| public static final String JDK12 This ( | |
| JDK13 | back to summary |
|---|---|
| public static final String JDK13 This ( | |
| JDK14 | back to summary |
|---|---|
| public static final String JDK14 This ( | |
| JDK15 | back to summary |
|---|---|
| public static final String JDK15 This ( | |
| JDK16 | back to summary |
|---|---|
| public static final String JDK16 This ( | |
| JDK17 | back to summary |
|---|---|
| public static final String JDK17 This ( | |
| JDK4 | back to summary |
|---|---|
| public static final String JDK4 This ( | |
| JDK5 | back to summary |
|---|---|
| public static final String JDK5 This ( | |
| JDK6 | back to summary |
|---|---|
| public static final String JDK6 This ( | |
| JDK7 | back to summary |
|---|---|
| public static final String JDK7 This ( | |
| JDK8 | back to summary |
|---|---|
| public static final String JDK8 This ( | |
| JDK9 | back to summary |
|---|---|
| public static final String JDK9 This ( | |
| JDK_TO_BYTECODE_VERSION_MAP | back to summary |
|---|---|
| public static final Map<String, Integer> JDK_TO_BYTECODE_VERSION_MAP JDK version to bytecode version mapping. | |
| jointCompilationOptions | back to summary |
|---|---|
| private Map<String, Object> jointCompilationOptions options for joint compilation (null by default == no joint compilation) | |
| MEM_STUB | back to summary |
|---|---|
| public static final String MEM_STUB Joint Compilation Option for enabling generating stubs in memory. | |
| minimumRecompilationInterval | back to summary |
|---|---|
| private int minimumRecompilationInterval sets the minimum of time after a script can be recompiled. | |
| optimizationOptions | back to summary |
|---|---|
| private Map<String, Boolean> optimizationOptions options for optimizations (empty map by default) | |
| output | back to summary |
|---|---|
| private PrintWriter output The | |
| PARALLEL_PARSE | back to summary |
|---|---|
| public static final String PARALLEL_PARSE Optimization Option for enabling parallel parsing. | |
| parameters | back to summary |
|---|---|
| private boolean parameters If true, generates metadata for reflection on method parameters | |
| pluginFactory | back to summary |
|---|---|
| private ParserPluginFactory pluginFactory | |
| POST_JDK5 | back to summary |
|---|---|
| public static final String POST_JDK5
Deprecated
This constant is for comparing targetBytecode to ensure it is set to JDK 1.5 or later. | |
| PRE_JDK5 | back to summary |
|---|---|
| public static final String PRE_JDK5
Deprecated
This constant is for comparing targetBytecode to ensure it is set to an earlier value than JDK 1.5. | |
| previewFeatures | back to summary |
|---|---|
| private boolean previewFeatures Whether the bytecode version has preview features enabled (JEP 12) | |
| recompileGroovySource | back to summary |
|---|---|
| private boolean recompileGroovySource if set to true recompilation is enabled | |
| RUNTIME_GROOVYDOC | back to summary |
|---|---|
| public static final String RUNTIME_GROOVYDOC Optimization Option for enabling attaching | |
| scriptBaseClass | back to summary |
|---|---|
| private String scriptBaseClass Base class name for scripts (must derive from Script) | |
| scriptExtensions | back to summary |
|---|---|
| private Set<String> scriptExtensions extensions used to find a groovy files | |
| sourceEncoding | back to summary |
|---|---|
| private String sourceEncoding Encoding for source files | |
| targetBytecode | back to summary |
|---|---|
| private String targetBytecode sets the bytecode version target | |
| targetDirectory | back to summary |
|---|---|
| private File targetDirectory Directory into which to write classes | |
| tolerance | back to summary |
|---|---|
| private int tolerance The number of non-fatal errors to allow before bailing | |
| verbose | back to summary |
|---|---|
| private boolean verbose If true, the compiler should produce action information | |
| warningLevel | back to summary |
|---|---|
| private int warningLevel See | |
| CompilerConfiguration | back to summary | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| public CompilerConfiguration() Sets the compiler flags/settings to default values. The following system properties are referenced when setting the configuration: The following system properties are referenced when setting the configuration optimization options:
| |||||||||||||||||||||||||
| CompilerConfiguration | back to summary |
|---|---|
| public CompilerConfiguration(final CompilerConfiguration configuration) Copy constructor. Use this if you have a mostly correct configuration for your compilation but you want to make a some changes programmatically. An important reason to prefer this approach is that your code will most likely be forward compatible with future changes to this configuration API. An example of this copy constructor at work: // In all likelihood there is already a configuration in your code's context // for you to copy, but for the sake of this example we'll use the global default. CompilerConfiguration myConfiguration = new CompilerConfiguration(CompilerConfiguration.DEFAULT); myConfiguration.setDebug(true);
| |
| CompilerConfiguration | back to summary | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| public CompilerConfiguration(final Properties configuration) throws ConfigurationException Sets the configuration flags/settings according to values from the supplied
And you also have to contend with a possible SecurityException when
getting the system properties (See System#getProperties()).
A safer approach would be to copy a default
CompilerConfiguration and make your changes there using the setter:
The following properties are referenced when setting the configuration:// In all likelihood there is already a configuration for you to copy, // but for the sake of this example we'll use the global default. CompilerConfiguration myConfiguration = new CompilerConfiguration(CompilerConfiguration.DEFAULT); myConfiguration.setDebug(true);
| |||||||||||||||||||||||||||||||||
| addCompilationCustomizers | back to summary |
|---|---|
| public CompilerConfiguration addCompilationCustomizers(final CompilationCustomizer... customizers) Adds compilation customizers to the compilation process. A compilation customizer is a class node operation which performs various operations going from adding imports to access control.
| |
| configure | back to summary |
|---|---|
| public void configure(final Properties configuration) throws ConfigurationException Method to configure a CompilerConfiguration by using Properties.
For a list of available properties look at
| |
| getBytecodePostprocessor | back to summary |
|---|---|
| public BytecodeProcessor getBytecodePostprocessor() | |
| getClasspath | back to summary |
|---|---|
| public List | |
| getCompilationCustomizers | back to summary |
|---|---|
| public List Returns the list of compilation customizers.
| |
| getDebug | back to summary |
|---|---|
| public boolean getDebug() Returns true if debugging operation has been requested. | |
| getDefaultScriptExtension | back to summary |
|---|---|
| public String getDefaultScriptExtension() | |
| getDisabledGlobalASTTransformations | back to summary |
|---|---|
| public Set Returns the list of disabled global AST transformation class names. | |
| getJointCompilationOptions | back to summary |
|---|---|
| public Map Gets the joint compilation options for this configuration. | |
| getMinimumRecompilationInterval | back to summary |
|---|---|
| public int getMinimumRecompilationInterval() | |
| getOptimizationOptions | back to summary |
|---|---|
| public Map Gets the optimization options for this configuration. | |
| getOutput | back to summary |
|---|---|
| public PrintWriter getOutput()
Deprecated not used anymore Gets the currently configured output writer.
| |
| getParameters | back to summary |
|---|---|
| public boolean getParameters() Returns true if parameter metadata generation has been enabled. | |
| getPluginFactory | back to summary |
|---|---|
| public ParserPluginFactory getPluginFactory() | |
| getRecompileGroovySource | back to summary |
|---|---|
| public boolean getRecompileGroovySource() | |
| getScriptBaseClass | back to summary |
|---|---|
| public String getScriptBaseClass() Gets the name of the base class for scripts. It must be a subclass of Script. | |
| getScriptExtensions | back to summary |
|---|---|
| public Set | |
| getSourceEncoding | back to summary |
|---|---|
| public String getSourceEncoding() Gets the currently configured source file encoding. | |
| getTargetBytecode | back to summary |
|---|---|
| public String getTargetBytecode() Returns the compiler bytecode compatibility level. Defaults to the minimum officially supported bytecode version for any particular Groovy version.
| |
| getTargetDirectory | back to summary |
|---|---|
| public File getTargetDirectory() Gets the target directory for writing classes. | |
| getTolerance | back to summary |
|---|---|
| public int getTolerance() Returns the requested error tolerance. | |
| getVerbose | back to summary |
|---|---|
| public boolean getVerbose() Returns true if verbose operation has been requested. | |
| getWarningLevel | back to summary |
|---|---|
| public int getWarningLevel() Gets the currently configured warning level. See | |
| isGroovydocEnabled | back to summary |
|---|---|
| public boolean isGroovydocEnabled() Checks if groovydoc is enabled. | |
| isIndyEnabled | back to summary |
|---|---|
| public boolean isIndyEnabled() Checks if invoke dynamic is enabled. | |
| isPostJDK5 | back to summary |
|---|---|
| public static boolean isPostJDK5(final String bytecodeVersion) Checks if the specified bytecode version string represents a JDK 1.5+ compatible bytecode version.
| |
| isPostJDK7 | back to summary |
|---|---|
| public static boolean isPostJDK7(final String bytecodeVersion) Checks if the specified bytecode version string represents a JDK 1.7+ compatible bytecode version.
| |
| isPostJDK8 | back to summary |
|---|---|
| public static boolean isPostJDK8(final String bytecodeVersion) Checks if the specified bytecode version string represents a JDK 1.8+ compatible bytecode version.
| |
| isPostJDK9 | back to summary |
|---|---|
| public static boolean isPostJDK9(final String bytecodeVersion) Checks if the specified bytecode version string represents a JDK 1.8+ compatible bytecode version.
| |
| isPreviewFeatures | back to summary |
|---|---|
| public boolean isPreviewFeatures() Whether the bytecode version has preview features enabled (JEP 12)
| |
| isRuntimeGroovydocEnabled | back to summary |
|---|---|
| public boolean isRuntimeGroovydocEnabled() Checks if runtime groovydoc is enabled. | |
| setBytecodePostprocessor | back to summary |
|---|---|
| public void setBytecodePostprocessor(final BytecodeProcessor bytecodePostprocessor) | |
| setClasspath | back to summary |
|---|---|
| public void setClasspath(final String classpath) Sets the classpath. | |
| setClasspathList | back to summary |
|---|---|
| public void setClasspathList(final List<String> parts) sets the classpath using a list of Strings | |
| setDebug | back to summary |
|---|---|
| public void setDebug(final boolean debug) Turns debugging operation on or off. | |
| setDefaultScriptExtension | back to summary |
|---|---|
| public void setDefaultScriptExtension(final String defaultScriptExtension) | |
| setDisabledGlobalASTTransformations | back to summary |
|---|---|
| public void setDisabledGlobalASTTransformations(final Set<String> disabledGlobalASTTransformations) Disables the specified global AST transformations. In order to avoid class loading side effects,
it is not recommended to use MyASTTransformation.class.getName() but instead directly use the class
name as a string. Disabled AST transformations only apply to automatically loaded global AST
transformations, that is to say transformations defined in a
META-INF/services/org.codehaus.groovy.transform.ASTTransformation file.
If you explicitly add a global AST transformation in your compilation process,
for example using the | |
| setJointCompilationOptions | back to summary |
|---|---|
| public void setJointCompilationOptions(final Map<String, Object> options) Sets the joint compilation options for this configuration. Using null will disable joint compilation. | |
| setMinimumRecompilationInterval | back to summary |
|---|---|
| public void setMinimumRecompilationInterval(final int time) | |
| setOptimizationOptions | back to summary |
|---|---|
| public void setOptimizationOptions(final Map<String, Boolean> options) Sets the optimization options for this configuration. No entry or a true for that entry means to enable that optimization, a false means the optimization is disabled. Valid keys are "all" and "int".
| |
| setOutput | back to summary |
|---|---|
| public void setOutput(final PrintWriter output)
Deprecated not used anymore, has no effect Sets the output writer.
| |
| setParameters | back to summary |
|---|---|
| public void setParameters(final boolean parameters) Turns parameter metadata generation on or off. | |
| setPluginFactory | back to summary |
|---|---|
| public void setPluginFactory(final ParserPluginFactory pluginFactory) | |
| setPreviewFeatures | back to summary |
|---|---|
| public void setPreviewFeatures(final boolean previewFeatures) Sets whether the bytecode version has preview features enabled (JEP 12).
| |
| setRecompileGroovySource | back to summary |
|---|---|
| public void setRecompileGroovySource(final boolean recompile) | |
| setScriptBaseClass | back to summary |
|---|---|
| public void setScriptBaseClass(final String scriptBaseClass) Sets the name of the base class for scripts. It must be a subclass of Script. | |
| setScriptExtensions | back to summary |
|---|---|
| public void setScriptExtensions(final Set<String> scriptExtensions) | |
| setSourceEncoding | back to summary |
|---|---|
| public void setSourceEncoding(final String encoding) Sets the encoding to be used when reading source files. | |
| setTargetBytecode | back to summary |
|---|---|
| public void setTargetBytecode(final String version) Sets the bytecode compatibility level. The parameter can take one of the
values in
| |
| setTargetBytecodeIfValid | back to summary |
|---|---|
| private void setTargetBytecodeIfValid(final String version) | |
| setTargetDirectory | back to summary |
|---|---|
| public void setTargetDirectory(final File directory) Sets the target directory. | |
| setTargetDirectory | back to summary |
|---|---|
| public void setTargetDirectory(final String directory) Sets the target directory. | |
| setTargetDirectorySafe | back to summary |
|---|---|
| private void setTargetDirectorySafe(final String directory) | |
| setTolerance | back to summary |
|---|---|
| public void setTolerance(final int tolerance) Sets the error tolerance, which is the number of non-fatal errors (per unit) that should be tolerated before compilation is aborted. | |
| setVerbose | back to summary |
|---|---|
| public void setVerbose(final boolean verbose) Turns verbose operation on or off. | |
| setWarningLevel | back to summary |
|---|---|
| public void setWarningLevel(final int level) Sets the warning level. See | |