private void createCloneSerialization(ClassNode cNode, List<FieldNode> list, List<String> excludes) {
final BlockStatement body = new BlockStatement();
// def baos = new ByteArrayOutputStream()
final Expression baos = new VariableExpression("baos");
body.addStatement(new ExpressionStatement(new DeclarationExpression(baos, ASSIGN, new ConstructorCallExpression(BAOS_TYPE, MethodCallExpression.NO_ARGUMENTS))));
// baos.withObjectOutputStream{ it.writeObject(this) }
BlockStatement writeClosureCode = new BlockStatement();
final Expression it = new VariableExpression("it");
writeClosureCode.addStatement(new ExpressionStatement(new MethodCallExpression(it, "writeObject", VariableExpression.THIS_EXPRESSION)));
ClosureExpression writeClosure = new ClosureExpression(new Parameter[]{}, writeClosureCode);
writeClosure.setVariableScope(new VariableScope());
body.addStatement(new ExpressionStatement(new MethodCallExpression(baos, "withObjectOutputStream", new ArgumentListExpression(writeClosure))));
// def bais = new ByteArrayInputStream(baos.toByteArray())
final Expression bais = new VariableExpression("bais");
ConstructorCallExpression bytes = new ConstructorCallExpression(BAIS_TYPE, new TupleExpression(new MethodCallExpression(baos, "toByteArray", MethodCallExpression.NO_ARGUMENTS)));
body.addStatement(new ExpressionStatement(new DeclarationExpression(bais, ASSIGN, bytes)));
// return bais.withObjectInputStream(getClass().classLoader){ it.readObject() }
BlockStatement readClosureCode = new BlockStatement();
readClosureCode.addStatement(new ExpressionStatement(new MethodCallExpression(it, "readObject", MethodCallExpression.NO_ARGUMENTS)));
ClosureExpression readClosure = new ClosureExpression(new Parameter[]{}, readClosureCode);
readClosure.setVariableScope(new VariableScope());
Expression klass = new MethodCallExpression(VariableExpression.THIS_EXPRESSION, "getClass", MethodCallExpression.NO_ARGUMENTS);
Expression classLoader = new MethodCallExpression(klass, "getClassLoader", MethodCallExpression.NO_ARGUMENTS);
Expression result = new MethodCallExpression(bais, "withObjectInputStream", new ArgumentListExpression(classLoader, readClosure));