public static <T extends Throwable>T readStackTrace(T throwable,StreamInput in) throws IOException {
  final int stackTraceElements=in.readVInt();
  StackTraceElement[] stackTrace=new StackTraceElement[stackTraceElements];
  for (int i=0; i < stackTraceElements; i++) {
    final String declaringClasss=in.readString();
    final String fileName=in.readOptionalString();
    final String methodName=in.readString();
    final int lineNumber=in.readVInt();
    stackTrace[i]=new StackTraceElement(declaringClasss,methodName,fileName,lineNumber);
  }
  throwable.setStackTrace(stackTrace);
  int numSuppressed=in.readVInt();
  for (int i=0; i < numSuppressed; i++) {
    throwable.addSuppressed(in.readThrowable());
  }
  return throwable;
}

public static < T extends Throwable > T readStackTrace ( T throwable , StreamInput in ) throws IOException { final int stackTraceElements = in . readVInt ( ) ; StackTraceElement [ ] stackTrace = new StackTraceElement [ stackTraceElements ] ; for ( int i = 0 ; i < stackTraceElements ; i ++ ) { final String declaringClasss = in . readString ( ) ; final String fileName = in . readOptionalString ( ) ; final String methodName = in . readString ( ) ; final int lineNumber = in . readVInt ( ) ; stackTrace [ i ] = new StackTraceElement ( declaringClasss , methodName , fileName , lineNumber ) ; } throwable . setStackTrace ( stackTrace ) ; int numSuppressed = in . readVInt ( ) ; for ( int i = 0 ; i < numSuppressed ; i ++ ) { throwable . addSuppressed ( in . readThrowable ( ) ) ; } return throwable ; }
deserializes stacktrace elements as well as suppressed exceptions from the given output stream and adds it to the given exception .
