Class CallDepthThreadLocalMap


  • public class CallDepthThreadLocalMap
    extends java.lang.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.

    • Constructor Detail

      • CallDepthThreadLocalMap

        public CallDepthThreadLocalMap()
    • Method Detail

      • getCallDepth

        public static CallDepth getCallDepth​(java.lang.Class<?> k)
      • incrementCallDepth

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

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

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