title: Accessing a Java object in a Java object in C using JNI
body: <p>I'm relatively new to JNI and have gotten down the basics of messing with integers and arrays in Java objects using JNI.  Now I'm trying to modify/access a Java object within a Java object.</p>
  
  <p>I've been searching on the internet and on Stack Overflow and have yet to find out how to do this.</p>
  
  <p>Here's the example.</p>
  
  <p>In Java:</p>
  
  <pre><code>public class ObjectOne
  {
      private byte[] buff;
      ...
      ...
  }
  
  public class ObjectTwo
  {
      private ObjectOne obj;
      ...
      ...
  }
  </code></pre>
  
  <p>In JNI, how do I access "buff" from ObjectOne through ObjectTwo?  I tried something like this...</p>
  
  <pre><code>JNIEXPORT void JNICALL Java_accessBuffThroughObjectTwo(JNIEnv *env, jobject obj, jobject objectTwo)
  {
      jclass clazz;
      jclass bufferClazz;
      jobject bufferJObject;
  
      clazz = (*env)-&gt;GetObjectClass(env, objectTwo);
      fid = (*env)-&gt;GetFieldID(env, clazz, "obj", "Ljava/lang/Object;");
      bufferJObject = (*env)-&gt;GetObjectField(env, javascsicommand, fid);
      bufferClazz = (*env)-&gt;GetObjectClass(env, bufferJObject);  &lt;-- Fails here for Access Violation
      fid = (*env)-&gt;GetFieldID(env, bufferClazz, "buff", "[B");
  }
  </code></pre>
  
  <p>Any help on what I'm doing wrong?  </p>