Fix parcelling code for structs containing interfaces

This change implements the proper parcel serialization/deserialization
functionality for structs containing interfaces; previously, structs
containing interfaces+{arrays,strings,vectors} would not be handled
correctly. The compile-time error was of the form:

// Here, the member variable ("array") of a struct ("swi") is referenced
// using the member access operator. However, this results in an invalid
// identifier name.
error: expected ';' at end of declaration
    size_t _hidl_swi.array_parent;
                    ^

Also updated the C++ and Java hidl_test suites.

Bug: 111019943
Test: Ran the hidl_test suite, including the new test-case
Change-Id: Ibcd6517737ed9038832884df11f4274e0dd8970c
diff --git a/CompoundType.cpp b/CompoundType.cpp
index 178b132..400dc1f 100644
--- a/CompoundType.cpp
+++ b/CompoundType.cpp
@@ -313,9 +313,36 @@
         }
 
         for (const auto& field : *mFields) {
-            field->type().emitReaderWriter(out, name + "." + field->name(),
-                                            parcelObj, parcelObjIsPointer,
-                                            isReader, mode);
+            const std::string tempFieldName = "_hidl_temp_" + field->name();
+            const std::string fieldValue = name + "." + field->name();
+
+            out.block([&] {
+                if (isReader) {
+                    out << field->type().getCppResultType()
+                        << " "
+                        << tempFieldName
+                        << ";\n";
+                } else {
+                    out << field->type().getCppArgumentType()
+                        << " "
+                        << tempFieldName
+                        << " = "
+                        << fieldValue
+                        << ";\n";
+                }
+
+                field->type().emitReaderWriter(out, tempFieldName, parcelObj,
+                                               parcelObjIsPointer, isReader, mode);
+                if (isReader) {
+                    const std::string derefOperator = field->type().resultNeedsDeref()
+                                                      ? "*" : "";
+                    out << fieldValue
+                        << " = std::move("
+                        << derefOperator
+                        << tempFieldName
+                        << ");\n";
+                }
+            }).endl();
         }
     } else {
         const std::string parentName = "_hidl_" + name + "_parent";
@@ -398,7 +425,7 @@
 
 void CompoundType::emitJavaFieldInitializer(
         Formatter &out, const std::string &fieldName) const {
-    const std::string fieldDeclaration = "final " + fullJavaName() + " " + fieldName;
+    const std::string fieldDeclaration = fullJavaName() + " " + fieldName;
     emitJavaFieldDefaultInitialValue(out, fieldDeclaration);
 }