title: Accessing field using JNI
body: <p>I have a java class that has two fields - one is a private final double and the other is a private Map; I have added a public getter method for the Map. I am accessing them from my C code using JNI. I am having problems getting the Map via the field but have no problem getting it through the method:</p>
  
  <pre><code>    // The following lines of code work just fine
      jclass jCls = (*env)-&gt;GetObjectClass(env,object);
      jfieldID dblFldId = (*env)-&gt;GetFieldID(env,jCls,"nameOfDoubleVariable","D");
      jdouble dblVar = (*env)-&gt;GetDoubleField(env, object, dblFldId);
  
      // These lines don't work though
      jfieldID mapId = (*env)-&gt;GetFieldID(env,jCls,"nameOfMapVariable","()Ljava/util/Map;");
      jobject mapVar = (*env)-&gt;GetObjectField(env,object,mapId);
  </code></pre>
  
  <p>But if I replace the two lines that don't work with the following (essentially I am getting the map via the method instead of directly via the field) it does work:</p>
  
  <pre><code>    jmethodID m_GetMap = (*env)-&gt;GetMethodID(env,jCls,"getMap","()Ljava/util/Map;");
      jobject mapVar = (*env)-&gt;CallObjectMethod(env,object,m_GetMap);
  </code></pre>
  
  <p>Can anyone tell me why the method call works but not getting it from the field - I am sure I am doing something wrong!</p>