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). |
CREATE_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 |
setCharacterEncoding(String characterEncoding) |
void |
setClassFileCreator(ResourceCreator classFileCreator) |
void |
setClassFileFinder(ResourceFinder classFileFinder) |
void |
setCompileErrorHandler(ErrorHandler compileErrorHandler)
Installs a custom
ErrorHandler. |
void |
setDebugLines(boolean value) |
void |
setDebugSource(boolean value) |
void |
setDebugVars(boolean value) |
void |
setEncoding(Charset encoding) |
void |
setIClassLoader(IClassLoader iClassLoader)
Loads "auxiliary classes", typically from BOOTCLASSPATH + EXTDIR + CLASSPATH (but not from the
"destination directory"!).
|
void |
setSourceFinder(ResourceFinder sourceFinder) |
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. |
setBootClassPath, setClassPath, setExtensionDirectories, setSourcePathcompile, setDestinationDirectory, setRebuildpublic 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 class AbstractCompilerpublic void setWarningHandler(@Nullable WarningHandler warningHandler)
WarningHandler.setWarningHandler 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
compile in class ICompilerCompileExceptionIOExceptionpublic 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)
AbstractCompilersetIClassLoader in class AbstractCompilerpublic void setClassFileFinder(@Nullable ResourceFinder classFileFinder)
setClassFileFinder in class ICompilerpublic void setClassFileCreator(@Nullable ResourceCreator classFileCreator)
setClassFileCreator in class ICompilerclassFileCreator - Stores the generated class files (a.k.a. "-d"); special value ICompiler.CREATE_NEXT_TO_SOURCE_FILE means "create each .class file in the same directory as
its source file"public void setEncoding(@Nullable Charset encoding)
setEncoding in class ICompilerpublic void setCharacterEncoding(@Nullable String characterEncoding)
setCharacterEncoding in class ICompilerpublic void setDebugLines(boolean value)
setDebugLines in class ICompilerpublic void setDebugVars(boolean value)
setDebugVars in class ICompilerpublic void setDebugSource(boolean value)
setDebugSource in class ICompilerpublic void setVerbose(boolean verbose)
setVerbose in class ICompilerpublic void setSourceFinder(ResourceFinder sourceFinder)
setSourceFinder in class ICompilerCopyright © 2019. All rights reserved.