private <T> T makeCopy(final Object task, Class<T> objClass) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SerializationUtilities.serializePlan(task, baos);

    return SerializationUtilities.deserializePlan(
        new ByteArrayInputStream(baos.toByteArray()), objClass);
  }
This method makes a copy of the given object by serialization/de-serialization
ql/src/java/org/apache/hadoop/hive/ql/parse/PrepareStatementAnalyzer.java