public static StackTraceElement[] toStackTrace(List<StackTraceElementMessage> traceList) {
    if (traceList == null || traceList.isEmpty()) {
      return new StackTraceElement[0]; // empty array
    }
    StackTraceElement[] trace = new StackTraceElement[traceList.size()];
    for (int i = 0; i < traceList.size(); i++) {
      StackTraceElementMessage elem = traceList.get(i);
      trace[i] = new StackTraceElement(elem.getDeclaringClass(), elem.getMethodName(),
        elem.hasFileName() ? elem.getFileName() : null, elem.getLineNumber());
    }
    return trace;
  }
Unwind a serialized array of {@link StackTraceElementMessage}s to a {@link StackTraceElement}s.
@param traceList list that was serialized
@return the deserialized list or <tt>null</tt> if it couldn't be unwound (e.g. wasn't set on
        the sender).
hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/util/ForeignExceptionUtil.java