title: get field values of the object and write it in the map
body: <p>I am trying to mirror object state (with specific fields) into a map</p>
  
  <pre><code>class ObjectState[T] {
    // object reference
    var objRef : T = _
    // map that mirrors current object state
    var stateMap : Map[String, Any] = _
  
    def registerFields(fields: List[String], objectInstance: T): Unit = {
      // just register
      objRef = objectInstance
      stateMap = fields.map(field =&gt; field -&gt; null)(collection.breakOut)
      Mirror.inMirrorObjectState(this)
    }
  
    object Mirror {
      // basically populate object state
      def inMirrorObjectState[T](state: ObjectState[T]): Unit = {
        val objectInstance = state.objRef
        stateMap.keySet foreach { key =&gt;
          println(s"Attempt to find ${key}")
          println(s"Fields: ${objectInstance.getClass.getFields.size}") // zero field size
          val field = objectInstance.getClass.getField(key) // exception
          stateMap += (key -&gt; field.get(objectInstance))
        }
      }
    }
  }
  </code></pre>
  
  <p>My object instance looks like this</p>
  
  <pre><code>val obj = new BasicObject
  obj.fieldA = "field"
  obj.fieldB = 10
  
  // 1. register object in OSM and get id - might be useful
  val id = OSMPlatform.registerObject(obj, List("fieldA", "fieldB"))
  </code></pre>
  
  <p>The class <code>BasicObject</code> looks like this</p>
  
  <pre><code>  class BasicObject {
      var fieldA : String = _
      var fieldB : Int = _
  
      override def toString: String = {
        "Basic object: $fieldA : $fieldB"
      }
    }
  </code></pre>
  
  <p>Then I try to create instance of my <code>ObjectState</code> class</p>
  
  <pre><code>  def registerObject(objectInstance: AnyRef, fields: List[String]): String = {
      val id = UUID.randomUUID().toString
      val objState = new ObjectState[AnyRef]
      objState.registerFields(fields, objectInstance)
  
      OSMContext.registerObject(id, objState)
      id
    }
  </code></pre>
  
  <p>But then I get exception</p>
  
  <pre><code>Exception in thread "main" java.lang.NoSuchFieldException: fieldA
  </code></pre>
  
  <p>On that line</p>
  
  <pre><code> val field = objectInstance.getClass.getField(key)
  </code></pre>
  
  <p>It seems it is unable to find that field. Why is that? Is it due to <code>T</code> type?</p>