java.lang.Object
net.i2p.servlet.util.JspC

public class JspCextends Object
Build-time wrapper that calls org.apache.jasper.JspC reflectively and then exits, so the build does not depend on the Jasper API at compile time. The build forks a JVM to run this. Running JspC in-process does not terminate on Tomcat 8.5.33 or 9.0.11 and later, where the JSP compilation is threaded and the thread pool workers are not daemon threads. See https://tomcat.apache.org/tomcat-8.5-doc/changelog.html If the system property build.reproducible is "true", the arguments are rewritten to compile the jsps in a fixed order, and to force a single compiler thread where the jasper in use supports -threadCount, so that the generated web.xml is reproducible. Warning - used in build process only, not included in runtime jars, not for external use. Only for use in build scripts, obviously not a public API. See apps/routerconsole/java/build.xml for more information.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final String
    Path to the Jasper jar, used when the system's own Tomcat is in play.
    private static final boolean
    True to try to make the generated web.xml byte-for-byte reproducible.
    private static final boolean
    True to get the Tomcat version out of the jasper jar's manifest instead of ours.
    private static final String
    First Tomcat 8.x version to support multiple threads and the -threadCount arg.
    private static final String
    First Tomcat 9.x version to support multiple threads and the -threadCount arg.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static Attributes
    Jar manifest attributes
    private static void
    collectJspFiles(File dir, List<File> files)
    Recursively collect the *.jsp files under dir, sorted.
    private static String[]
    fixupArgs(String[] args)
    Only call this if we want reproducible builds.
    static void
    main(String[] args)
    Runs Tomcat JspC with the given arguments, rewriting them when build.reproducible is set.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • THREADS_VERSION_8

      private static final String THREADS_VERSION_8
      First Tomcat 8.x version to support multiple threads and the -threadCount arg.
      See Also:
    • THREADS_VERSION_9

      private static final String THREADS_VERSION_9
      First Tomcat 9.x version to support multiple threads and the -threadCount arg.
      See Also:
    • REPRODUCIBLE

      private static final boolean REPRODUCIBLE
      True to try to make the generated web.xml byte-for-byte reproducible.
    • SYSTEM_TOMCAT

      private static final boolean SYSTEM_TOMCAT
      True to get the Tomcat version out of the jasper jar's manifest instead of ours.
    • JASPER_JAR

      private static final String JASPER_JAR
      Path to the Jasper jar, used when the system's own Tomcat is in play.
  • Constructor Details

    • JspC

      public JspC()
      Constructor. The build script drives compilation through main(String[]), reading every option from the system properties and arguments, so an instance carries no state.
  • Method Details

    • main

      public static void main(String[] args)
      Runs Tomcat JspC with the given arguments, rewriting them when build.reproducible is set.
      Parameters:
      args - arguments forwarded to org.apache.jasper.JspC, after fixupArgs(String[])
      Throws:
      IllegalArgumentException - if -webapp is repeated, has no value, or does not name an existing directory; fixupArgs() runs outside the try below
    • fixupArgs

      private static String[] fixupArgs(String[] args)
      Only call this if we want reproducible builds. Convert "-webapp dir/" arguments in the args to a sorted list of files, for reproducible builds.
      Parameters:
      args - the command line arguments to rewrite
      Returns:
      args unchanged if there is no -webapp argument, otherwise the rewritten list using -uriroot, one thread, and the sorted JSP file paths
    • collectJspFiles

      private static void collectJspFiles(File dir, List<File> files)
      Recursively collect the *.jsp files under dir, sorted.
      Parameters:
      dir - the directory to scan
      files - the list the sorted .jsp files are added to
    • attributes

      private static Attributes attributes(String f)
      Jar manifest attributes
      Parameters:
      f - the jar file path whose META-INF/MANIFEST.MF is read
      Returns:
      null if not found