Class StackTraceDeobfuscator

java.lang.Object
com.google.gwt.core.server.StackTraceDeobfuscator
Direct Known Subclasses:
StackTraceDeobfuscator

public abstract class StackTraceDeobfuscator extends Object
Deobfuscates stack traces on the server side. This class requires that you have turned on emulated stack traces, via <set-property name="compiler.stackMode" value="emulated" /> in your .gwt.xml module file for browsers that don't support sourcemaps or <set-property name="compiler.useSourceMaps" value="true"/> for browsers that support it (e.g. Chrome), and moved your symbol map files to a location accessible by your server-side code. You can use the GWT compiler -deploy command line argument to specify the location of the folder into which the generated symbolMaps directory is written. By default, the final symbolMaps directory is war/WEB-INF/deploy/yourmodulename/symbolMaps/.
  • Constructor Details

    • StackTraceDeobfuscator

      public StackTraceDeobfuscator()
  • Method Details

    • fromResource

      public static StackTraceDeobfuscator fromResource(String symbolMapsPath)
      Creates a deobfuscator that loads symbol and source map files under given resource path. Uses StackTraceObfuscator's ClassLoader.
    • fromFileSystem

      public static StackTraceDeobfuscator fromFileSystem(String symbolMapsDirectory)
      Creates a deobfuscator that loads symbol and source map files from the given directory.
    • fromUrl

      public static StackTraceDeobfuscator fromUrl(URL urlPath)
      Creates a deobfuscator that loads symbol and source map files beneath the given URL.
    • setLazyLoad

      public void setLazyLoad(boolean lazyLoad)
      If set to true, only symbols requested to be deobfuscated are cached and the rest is discarded. This provides a large memory savings at the expense of occasional extra disk reads. Note that, this will only have effect on symbol maps that haven't been fully loaded yet.
    • deobfuscateStackTrace

      public final void deobfuscateStackTrace(Throwable throwable, String strongName)
      Replaces the stack traces in the given Throwable and its causes with deobfuscated stack traces wherever possible.
      Parameters:
      throwable - the Throwable that needs its stack trace to be deobfuscated
      strongName - the GWT permutation strong name
    • resymbolize

      public final StackTraceElement[] resymbolize(StackTraceElement[] st, String strongName)
      Convenience method which resymbolizes an entire stack trace to extent possible.
      Parameters:
      st - the stack trace to resymbolize
      strongName - the GWT permutation strong name
      Returns:
      a best effort resymbolized stack trace
    • resymbolize

      public final StackTraceElement resymbolize(StackTraceElement ste, String strongName)
      Best effort resymbolization of a single stack trace element.
      Parameters:
      ste - the stack trace element to resymbolize
      strongName - the GWT permutation strong name
      Returns:
      the best effort resymbolized stack trace element
    • getSourceMapInputStream

      protected InputStream getSourceMapInputStream(String permutationStrongName, int fragmentNumber) throws IOException
      Throws:
      IOException
    • getSymbolMapInputStream

      protected InputStream getSymbolMapInputStream(String permutationStrongName) throws IOException
      Retrieves a new InputStream for the given permutation strong name. This implementation, which subclasses may override, returns a InputStream for the permutation-strong-name.symbolMap file.
      Parameters:
      permutationStrongName - the GWT permutation strong name
      Returns:
      a new InputStream
      Throws:
      IOException
    • openInputStream

      protected abstract InputStream openInputStream(String fileName) throws IOException
      Opens a new InputStream for a symbol or source map file.
      Parameters:
      fileName - name of the symbol or source map file
      Returns:
      an input stream for reading the file (doesn't need to be buffered).
      Throws:
      IOException - if an I/O error occurs while creating the input stream.