Class StackTraceFilter

  • All Implemented Interfaces:
    java.io.Serializable

    public class StackTraceFilter
    extends java.lang.Object
    implements java.io.Serializable
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.StackTraceElement[] filter​(java.lang.StackTraceElement[] target, boolean keepTop)
      Example how the filter works (+/- means good/bad): [a+, b+, c-, d+, e+, f-, g+] -> [a+, b+, d+, e+, g+] Basically removes all bad from the middle.
      java.lang.StackTraceElement filterFirst​(java.lang.Throwable target, boolean isInline)
      This filtering strategy makes use of a fast-path computation to retrieve stackTraceElements from a Stacktrace of a Throwable.
      java.lang.String findSourceFile​(java.lang.StackTraceElement[] target, java.lang.String defaultValue)
      Finds the source file of the target stack trace.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • JAVA_LANG_ACCESS

        private static java.lang.Object JAVA_LANG_ACCESS
      • GET_STACK_TRACE_ELEMENT

        private static java.lang.reflect.Method GET_STACK_TRACE_ELEMENT
    • Constructor Detail

      • StackTraceFilter

        public StackTraceFilter()
    • Method Detail

      • filter

        public java.lang.StackTraceElement[] filter​(java.lang.StackTraceElement[] target,
                                                    boolean keepTop)
        Example how the filter works (+/- means good/bad): [a+, b+, c-, d+, e+, f-, g+] -> [a+, b+, d+, e+, g+] Basically removes all bad from the middle. If any good are in the middle of bad those are also removed.
      • filterFirst

        public java.lang.StackTraceElement filterFirst​(java.lang.Throwable target,
                                                       boolean isInline)
        This filtering strategy makes use of a fast-path computation to retrieve stackTraceElements from a Stacktrace of a Throwable. It does so, by taking advantage of sun.misc.SharedSecrets and sun.misc.JavaLangAccess.

        The sun.misc.SharedSecrets provides a method to obtain an instance of an sun.misc.JavaLangAccess. The latter class has a method to fast-path into Throwable.getStackTrace() and retrieve a single StackTraceElement. This prevents the JVM from having to generate a full stacktrace, which could potentially be expensive if stacktraces become very large.

        Parameters:
        target - The throwable target to find the first StackTraceElement that should not be filtered out per CLEANER.
        Returns:
        The first StackTraceElement outside of the CLEANER
      • findSourceFile

        public java.lang.String findSourceFile​(java.lang.StackTraceElement[] target,
                                               java.lang.String defaultValue)
        Finds the source file of the target stack trace. Returns the default value if source file cannot be found.