code: private void defineReadStructMethod()
      {
          MethodDefinition read = new MethodDefinition(
                  a(PUBLIC),
                  "read",
                  structType,
                  arg("protocol", TProtocol.class)
          ).addException(Exception.class);
  
          // TProtocolReader reader = new TProtocolReader(protocol);
          read.addLocalVariable(type(TProtocolReader.class), "reader");
          read.newObject(TProtocolReader.class);
          read.dup();
          read.loadVariable("protocol");
          read.invokeConstructor(type(TProtocolReader.class), type(TProtocol.class));
          read.storeVariable("reader");
  
          // read all of the data in to local variables
          Map<Short, LocalVariableDefinition> structData = readFieldValues(read);
  
          // build the struct
          LocalVariableDefinition result = buildStruct(read, structData);
  
          // push instance on stack, and return it
          read.loadVariable(result).retObject();
  
          classDefinition.addMethod(read);
      }
docs: Defines the read method for a struct.