Class SmapUtil

java.lang.Object
org.apache.jasper.compiler.SmapUtil

public class SmapUtil extends Object
Contains static utilities for generating SMAP data based on the current version of Jasper.
  • Constructor Details

    • SmapUtil

      public SmapUtil()
      Default constructor.
  • Method Details

    • generateSmap

      public static Map<String, SmapStratum> generateSmap(JspCompilationContext ctxt, Node.Nodes pageNodes) throws IOException
      Generates an appropriate SMAP representing the current compilation context. (JSR-045.)
      Parameters:
      ctxt - Current compilation context
      pageNodes - The current JSP page
      Returns:
      a SMAP for the page
      Throws:
      IOException - Error writing SMAP
    • installSmap

      public static void installSmap(Map<String, SmapStratum> smapInfo) throws IOException
      Installs SMAP data into the compiled class files by writing the SourceDebugExtension attribute.
      Parameters:
      smapInfo - the SMAP data keyed by fully qualified class name
      Throws:
      IOException - if an I/O error occurs while writing class files
    • evaluateNodes

      public static void evaluateNodes(Node.Nodes nodes, SmapStratum s, HashMap<String, SmapStratum> innerClassMap, boolean breakAtLF)
      Traverses the JSP AST nodes and populates the given SmapStratum with line mapping data.
      Parameters:
      nodes - the root JSP AST nodes
      s - the stratum to populate with line mappings
      innerClassMap - map to collect SMAP data for inner classes
      breakAtLF - whether to generate a mapping for each line feed in template text
    • loadSmap

      public static SmapStratum loadSmap(String className, ClassLoader cl)
      Loads SMAP data for the given class by reading the embedded SourceDebugExtension attribute from the class file or an external .smap resource.
      Parameters:
      className - the fully qualified class name
      cl - the class loader to use for loading the resource
      Returns:
      the parsed SmapStratum, or null if no or invalid SMAP data is found