Class CallDepthThreadLocalMap


  • public final class CallDepthThreadLocalMap
    extends Object
    Utility to track nested instrumentation.

    For example, this can be used to track nested calls to super() in constructors by calling #incrementCallDepth at the beginning of each constructor.

    This works the following way. When you enter some method that you want to track, you call incrementCallDepth(java.lang.Class<?>) method. If returned number is larger than 0, then you have already been in this method and are in recursive call now. When you then leave the method, you call decrementCallDepth(java.lang.Class<?>) method. If returned number is larger than 0, then you have already been in this method and are in recursive call now.

    In short, the semantic of both methods is the same: they will return value 0 if and only if current method invocation is the first one for the current call stack.

    • Method Detail

      • incrementCallDepth

        public static int incrementCallDepth​(Class<?> k)
      • decrementCallDepth

        public static int decrementCallDepth​(Class<?> k)
      • reset

        public static void reset​(Class<?> k)