code: private static StackTraceElement[] cropStackTrace(StackTraceElement[] callStack,
                                                      int maxDepth) {
      int realDepth = callStack.length;
      if (maxDepth > 0) {
        realDepth = Math.min(maxDepth, realDepth);
      }
      StackTraceElement[] realStack = new StackTraceElement[realDepth];
      System.arraycopy(callStack, 0, realStack, 0, realDepth);
      return realStack;
    }
docs: Crop the stack trace with a max depth.
  
  @param callStack the original stack trace
  @param maxDepth  the max depth of real stack trace that will be cropped,
  0 means no limitation
  @return the cropped stack trace