Package org.apache.jasper.compiler
Class JDTJavaCompiler
- java.lang.Object
-
- org.apache.jasper.compiler.JDTJavaCompiler
-
- All Implemented Interfaces:
JavaCompiler
public class JDTJavaCompiler extends java.lang.Object implements JavaCompiler
JDT class compiler. This compiler will load source dependencies from the context classloader, reducing dramatically disk access during the compilation process.
-
-
Field Summary
Fields Modifier and Type Field Description private JspCompilationContextctxtprivate ErrorDispatchererrDispatcherprivate static java.lang.reflect.MethodGET_PROBLEM_METHprivate java.lang.StringjavaFileNameprivate java.util.logging.Loggerlogprivate java.util.Mapsettingsprivate static booleanUSE_INTROSPECTION_TO_INVOKE_GET_PROBLEM
-
Constructor Summary
Constructors Constructor Description JDTJavaCompiler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JavacErrorDetail[]compile(java.lang.String targetClassName, Node.Nodes pageNodes)Start Java compilationvoiddoJavaFile(boolean keep)Remove/save the generated Java File from/to disklonggetClassLastModified()Return the time the class file was generated.java.io.WritergetJavaWriter(java.lang.String javaFileName, java.lang.String javaEncoding)Get a Writer for the Java file.voidinit(JspCompilationContext ctxt, ErrorDispatcher errDispatcher, boolean suppressLogging)Initializationsvoidrelease()Release resouces used in the current compilationprivate static org.eclipse.jdt.core.compiler.IProblem[]safeGetProblems(org.eclipse.jdt.internal.compiler.CompilationResult result)Invoke CompilationResult#getProblems safely so that it works with 3.1.1 and more recent versions of the eclipse java compiler.voidsaveClassFile(java.lang.String className, java.lang.String classFileName)Save the generated class file to disk, if not already done.voidsetClassPath(java.util.List<java.io.File> cpath)Java Compiler options.voidsetDebug(boolean debug)voidsetExtdirs(java.lang.String exts)voidsetSourceVM(java.lang.String sourceVM)voidsetTargetVM(java.lang.String targetVM)
-
-
-
Field Detail
-
settings
private final java.util.Map settings
-
ctxt
private JspCompilationContext ctxt
-
errDispatcher
private ErrorDispatcher errDispatcher
-
log
private java.util.logging.Logger log
-
javaFileName
private java.lang.String javaFileName
-
USE_INTROSPECTION_TO_INVOKE_GET_PROBLEM
private static boolean USE_INTROSPECTION_TO_INVOKE_GET_PROBLEM
-
GET_PROBLEM_METH
private static java.lang.reflect.Method GET_PROBLEM_METH
-
-
Method Detail
-
init
public void init(JspCompilationContext ctxt, ErrorDispatcher errDispatcher, boolean suppressLogging)
Description copied from interface:JavaCompilerInitializations- Specified by:
initin interfaceJavaCompiler
-
release
public void release()
Description copied from interface:JavaCompilerRelease resouces used in the current compilation- Specified by:
releasein interfaceJavaCompiler
-
setExtdirs
public void setExtdirs(java.lang.String exts)
- Specified by:
setExtdirsin interfaceJavaCompiler
-
setClassPath
public void setClassPath(java.util.List<java.io.File> cpath)
Description copied from interface:JavaCompilerJava Compiler options.- Specified by:
setClassPathin interfaceJavaCompiler
-
getClassLastModified
public long getClassLastModified()
Description copied from interface:JavaCompilerReturn the time the class file was generated.- Specified by:
getClassLastModifiedin interfaceJavaCompiler
-
getJavaWriter
public java.io.Writer getJavaWriter(java.lang.String javaFileName, java.lang.String javaEncoding) throws JasperExceptionDescription copied from interface:JavaCompilerGet a Writer for the Java file. The writer is used by JSP compiler. This method allows the Java compiler control where the Java file should be generated so it knows how to handle the input for java compilation accordingly.- Specified by:
getJavaWriterin interfaceJavaCompiler- Throws:
JasperException
-
setDebug
public void setDebug(boolean debug)
- Specified by:
setDebugin interfaceJavaCompiler
-
setSourceVM
public void setSourceVM(java.lang.String sourceVM)
- Specified by:
setSourceVMin interfaceJavaCompiler
-
setTargetVM
public void setTargetVM(java.lang.String targetVM)
- Specified by:
setTargetVMin interfaceJavaCompiler
-
saveClassFile
public void saveClassFile(java.lang.String className, java.lang.String classFileName)Description copied from interface:JavaCompilerSave the generated class file to disk, if not already done.- Specified by:
saveClassFilein interfaceJavaCompiler
-
doJavaFile
public void doJavaFile(boolean keep)
Description copied from interface:JavaCompilerRemove/save the generated Java File from/to disk- Specified by:
doJavaFilein interfaceJavaCompiler
-
compile
public JavacErrorDetail[] compile(java.lang.String targetClassName, Node.Nodes pageNodes) throws JasperException
Description copied from interface:JavaCompilerStart Java compilation- Specified by:
compilein interfaceJavaCompiler- Parameters:
targetClassName- Name of the class under compilation- Throws:
JasperException
-
safeGetProblems
private static final org.eclipse.jdt.core.compiler.IProblem[] safeGetProblems(org.eclipse.jdt.internal.compiler.CompilationResult result)
Invoke CompilationResult#getProblems safely so that it works with 3.1.1 and more recent versions of the eclipse java compiler. See https://jsp.dev.java.net/issues/show_bug.cgi?id=13- Parameters:
result- The compilation result.- Returns:
- The same object than CompilationResult#getProblems
-
-