Class JDTJavaCompiler

java.lang.Object
org.apache.jasper.compiler.JDTJavaCompiler
All Implemented Interfaces:
JavaCompiler

public class JDTJavaCompiler extends 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 Details

    • settings

      private final Map settings
    • ctxt

      private JspCompilationContext ctxt
    • errDispatcher

      private ErrorDispatcher errDispatcher
    • log

      private Logger log
    • javaFileName

      private String javaFileName
    • USE_INTROSPECTION_TO_INVOKE_GET_PROBLEM

      private static boolean USE_INTROSPECTION_TO_INVOKE_GET_PROBLEM
    • GET_PROBLEM_METH

      private static Method GET_PROBLEM_METH
  • Constructor Details

    • JDTJavaCompiler

      public JDTJavaCompiler()
  • Method Details

    • init

      public void init(JspCompilationContext ctxt, ErrorDispatcher errDispatcher, boolean suppressLogging)
      Description copied from interface: JavaCompiler
      Initializations
      Specified by:
      init in interface JavaCompiler
    • release

      public void release()
      Description copied from interface: JavaCompiler
      Release resouces used in the current compilation
      Specified by:
      release in interface JavaCompiler
    • setExtdirs

      public void setExtdirs(String exts)
      Specified by:
      setExtdirs in interface JavaCompiler
    • setClassPath

      public void setClassPath(List<File> cpath)
      Description copied from interface: JavaCompiler
      Java Compiler options.
      Specified by:
      setClassPath in interface JavaCompiler
    • getClassLastModified

      public long getClassLastModified()
      Description copied from interface: JavaCompiler
      Return the time the class file was generated.
      Specified by:
      getClassLastModified in interface JavaCompiler
    • getJavaWriter

      public Writer getJavaWriter(String javaFileName, String javaEncoding) throws JasperException
      Description copied from interface: JavaCompiler
      Get 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:
      getJavaWriter in interface JavaCompiler
      Throws:
      JasperException
    • setDebug

      public void setDebug(boolean debug)
      Specified by:
      setDebug in interface JavaCompiler
    • setSourceVM

      public void setSourceVM(String sourceVM)
      Specified by:
      setSourceVM in interface JavaCompiler
    • setTargetVM

      public void setTargetVM(String targetVM)
      Specified by:
      setTargetVM in interface JavaCompiler
    • saveClassFile

      public void saveClassFile(String className, String classFileName)
      Description copied from interface: JavaCompiler
      Save the generated class file to disk, if not already done.
      Specified by:
      saveClassFile in interface JavaCompiler
    • doJavaFile

      public void doJavaFile(boolean keep)
      Description copied from interface: JavaCompiler
      Remove/save the generated Java File from/to disk
      Specified by:
      doJavaFile in interface JavaCompiler
    • compile

      public JavacErrorDetail[] compile(String targetClassName, Node.Nodes pageNodes) throws JasperException
      Description copied from interface: JavaCompiler
      Start Java compilation
      Specified by:
      compile in interface JavaCompiler
      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