public class Compiler extends AbstractCompiler
ICompiler.| Modifier and Type | Field and Description |
|---|---|
static 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). |
bootClassPath, classFileCreator, classFileFinder, classPath, debugLines, debugSource, debugVars, encoding, extensionDirectories, sourceFinderCREATE_NEXT_TO_SOURCE_FILE, FIND_NEXT_TO_SOURCE_FILE, NO_DESTINATION_DIRECTORY| Constructor and 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 |
| Modifier and Type | Method and Description |
|---|---|
void |
compile(Resource[] sourceResources) |
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 |
setBootClassPath(File[] directoriesAndArchives) |
void |
setClassPath(File[] directoriesAndArchives) |
void |
setCompileErrorHandler(ErrorHandler compileErrorHandler)
Installs a custom
ErrorHandler. |
void |
setExtensionDirectories(File[] directories) |
void |
setIClassLoader(IClassLoader iClassLoader)
Loads "auxiliary classes", typically from BOOTCLASSPATH + EXTDIR + CLASSPATH (but not from the
"destination directory"!).
|
void |
setVerbose(boolean verbose) |
void |
setWarningHandler(WarningHandler warningHandler)
By default, warnings are discarded, but an application my install a custom
WarningHandler. |
void |
storeClassFile(ClassFile classFile,
File sourceFile)
Stores the byte code of this
ClassFile in the file system. |
compile, setCharacterEncoding, setClassFileCreator, setClassFileFinder, setClassFileFinder, setDebugLines, setDebugSource, setDebugVars, setDestinationDirectory, setEncoding, setSourceFinder, setSourcePathpublic static final StringPattern[] DEFAULT_WARNING_HANDLE_PATTERNS
Compiler(File[], File[],
File[], File[], File, String, boolean, boolean, boolean, boolean, StringPattern[], boolean).public Compiler()
@Deprecated public Compiler(ResourceFinder sourceFinder, IClassLoader parentIClassLoader)
Compiler() and the various configuration setters instead@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)
Compiler() and the various configuration setters insteadpublic void setCompileErrorHandler(@Nullable ErrorHandler compileErrorHandler)
ErrorHandler. The default ErrorHandler prints the first 20 compile errors to
System.err and then throws a CompileException.
Passing null restores the default ErrorHandler.
Notice that scan and parse errors are not redirected to this ErrorHandler, instead, they
cause a CompileException to be thrown. Also, the Compiler may choose to throw CompileExceptions in certain, fatal compile error situations, even if an ErrorHandler is installed.
In other words: In situations where compilation can reasonably continue after a compile error, the ErrorHandler is called; all other error conditions cause a CompileException to be thrown.
setCompileErrorHandler in interface ICompilersetCompileErrorHandler in class AbstractCompilerpublic void setWarningHandler(@Nullable WarningHandler warningHandler)
WarningHandler.setWarningHandler in interface ICompilersetWarningHandler in class AbstractCompilerwarningHandler - null to indicate that no warnings be issuedpublic EnumSet<JaninoOption> options()
public Compiler options(EnumSet<JaninoOption> options)
public void compile(Resource[] sourceResources) throws CompileException, IOException
CompileExceptionIOExceptionpublic static File getClassFile(String className, File sourceFile, @Nullable File destinationDirectory)
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"
className - E.g. "pkg1.pkg2.Outer$Inner"sourceFile - E.g. "srcdir/Outer.java"destinationDirectory - E.g. "destdir"public void storeClassFile(ClassFile classFile, File sourceFile) throws IOException
ClassFile in the file system. Directories are created as necessary.classFile - sourceFile - Required to compute class file path if no destination directory givenIOExceptionpublic void setIClassLoader(IClassLoader iClassLoader)
public void setVerbose(boolean verbose)
public void setBootClassPath(File[] directoriesAndArchives)
setBootClassPath in interface ICompilersetBootClassPath in class AbstractCompilerpublic void setExtensionDirectories(File[] directories)
setExtensionDirectories in interface ICompilersetExtensionDirectories in class AbstractCompilerpublic void setClassPath(File[] directoriesAndArchives)
setClassPath in interface ICompilersetClassPath in class AbstractCompilerCopyright © 2019. All rights reserved.