Package org.codehaus.janino

# Class Compiler

java.lang.Object
org.codehaus.commons.compiler.AbstractCompiler
org.codehaus.janino.Compiler

All Implemented Interfaces:
  `ICompiler`

public class Compiler extends AbstractCompiler
JANINO implementation of `ICompiler`.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final StringPattern[]`
`DEFAULT_WARNING_HANDLE_PATTERNS`
The default value for the warningHandlerPatterns parameter of `Compiler(File[], File[], File[], File[], File, String, boolean, boolean, boolean, boolean, StringPattern[], boolean)`.

### Fields inherited from class org.codehaus.commons.compiler.AbstractCompiler

`bootClassPath, classFileCreator, classFileFinder, classPath, compileErrorHandler, debugLines, debugSource, debugVars, extensionDirectories, sourceCharset, sourceFinder, sourceVersion, targetVersion, warningHandler`

### Fields inherited from interface org.codehaus.commons.compiler.ICompiler

`CREATE_NEXT_TO_SOURCE_FILE, FIND_NEXT_TO_SOURCE_FILE, NO_DESTINATION_DIRECTORY`

## Constructor Summary

Constructors
Constructor
Description
`Compiler()`
Initializes a new compiler.
`Compiler(File[] sourcePath, File[] classPath, File[] extDirs, File[] bootClassPath, File destinationDirectory, String characterEncoding, boolean verbose, boolean debugSource, boolean debugLines, boolean debugVars, StringPattern[] warningHandlePatterns, boolean rebuild)`
Deprecated.
Use `Compiler()` and the various configuration setters instead
`Compiler(ResourceFinder sourceFinder, IClassLoader parentIClassLoader)`
Deprecated.
Use `Compiler()` and the various configuration setters instead

## Method Summary

Modifier and Type
Method
Description
`void`
`compile(Resource[] sourceResources)`
See `ICompiler.compile(File[])`.
`static File`
`getClassFile(String className, File sourceFile, File destinationDirectory)`
Constructs the name of a file that could store the byte code of the class with the given name.
`EnumSet<JaninoOption>`
`options()`
`Compiler`
`options(EnumSet<JaninoOption> options)`
Sets the options for all future compilations.
`void`
`setIClassLoader(IClassLoader iClassLoader)`
Explicitly sets the `IClassLoader` that will be used to load "auxiliary classes".
`void`
`setVerbose(boolean verbose)`
Equivalent of `-verbose`.
`void`
`storeClassFile(ClassFile classFile, File sourceFile)`
Stores the byte code of this `ClassFile` in the file system.

### Methods inherited from class org.codehaus.commons.compiler.AbstractCompiler

`compile, setBootClassPath, setCharacterEncoding, setClassFileCreator, setClassFileFinder, setClassFileFinder, setClassPath, setCompileErrorHandler, setDebugLines, setDebugSource, setDebugVars, setDestinationDirectory, setEncoding, setExtensionDirectories, setSourceCharset, setSourceFinder, setSourcePath, setSourceVersion, setTargetVersion, setWarningHandler`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DEFAULT_WARNING_HANDLE_PATTERNS

public static final StringPattern[] DEFAULT_WARNING_HANDLE_PATTERNS
The default value for the warningHandlerPatterns parameter of `Compiler(File[], File[], File[], File[], File, String, boolean, boolean, boolean, boolean, StringPattern[], boolean)`.

## Constructor Details

### Compiler

public Compiler()
Initializes a new compiler.

### Compiler

@Deprecated public Compiler(ResourceFinder sourceFinder, IClassLoader parentIClassLoader)
Deprecated.
Use `Compiler()` and the various configuration setters instead

### Compiler

@Deprecated public Compiler(File[] sourcePath, File[] classPath, @Nullable File[] extDirs, @Nullable File[] bootClassPath, @Nullable File destinationDirectory, @Nullable String characterEncoding, boolean verbose, boolean debugSource, boolean debugLines, boolean debugVars, StringPattern[] warningHandlePatterns, boolean rebuild)
Deprecated.
Use `Compiler()` and the various configuration setters instead

## Method Details

### options

public EnumSet<JaninoOption> options()

Returns:
  A reference to the currently effective compilation options; changes to it take effect immediately

### options

public Compiler options(EnumSet<JaninoOption> options)
Sets the options for all future compilations.

### compile

public void compile(Resource[] sourceResources) throws CompileException, IOException
Description copied from interface: `ICompiler`
See `ICompiler.compile(File[])`.

Parameters:
  `sourceResources` - Contain the compilation units to compile
Throws:
  `CompileException`
  `IOException`

### getClassFile

public static File getClassFile(String className, File sourceFile, @Nullable File destinationDirectory)
Constructs the name of a file that could store the byte code of the class with the given name.

If destinationDirectory is non-`null`, the returned path is the destinationDirectory plus the package of the class (with dots replaced with file separators) plus the class name plus ".class". Example: "destdir/pkg1/pkg2/Outer$Inner.class"

If destinationDirectory is null, the returned path is the directory of the sourceFile plus the class name plus ".class". Example: "srcdir/Outer$Inner.class"

Parameters:
  `className` - E.g. `"pkg1.pkg2.Outer$Inner"`
  `sourceFile` - E.g. `"srcdir/Outer.java"`
  `destinationDirectory` - E.g. `"destdir"`

### storeClassFile

public void storeClassFile(ClassFile classFile, File sourceFile) throws IOException
Stores the byte code of this `ClassFile` in the file system. Directories are created as necessary.

Parameters:
  `classFile` -
  `sourceFile` - Required to compute class file path if no destination directory given
Throws:
  `IOException`

### setIClassLoader

public void setIClassLoader(IClassLoader iClassLoader)
Explicitly sets the `IClassLoader` that will be used to load "auxiliary classes". If this method is used, then `AbstractCompiler.setBootClassPath(File[])`, `AbstractCompiler.setExtensionDirectories(File[])` and `AbstractCompiler.setClassPath(File[])` have no more effect.

### setVerbose

public void setVerbose(boolean verbose)
Description copied from interface: `ICompiler`
Equivalent of `-verbose`.