title: JNI - How to modify a parameter when calling a Java method from C++?
body: <p>I have a Java method something like this</p>
  
  <pre><code>public boolean ReadBool(String ValueName, Boolean Value)  
  {  
    boolean Retval = ...;  
    ...  
    Value = true;  
    ...  
    return bRetval;  
  }
  </code></pre>
  
  <p>that I call from native code (C++) like this:</p>
  
  <pre><code>jMethodID MethodId = pEnv-&gt;GetMethodID(ClassId, "ReadBool", "(Ljava/lang/String;Ljava/lang/Boolean;)Z");  
  // What goes instead of "??" ?  
  bool bOk = pEnv-&gt;CallBooleanMethod(myobject, MethodId, pEnv-&gt;NewStringUTF("Value1"), "??");
  </code></pre>
  
  <p>My intention is for the Java method to "return" a boolean value in Value. I understand that a built-in boolean will not work for this purpose. Is it possible to do this with a Boolean wrapper? How does one construct the object to pass in place of "??" ?</p>
  
  <p>I have googled around, but some questions remain. For example, I suppose I could pass an object created by calling Boolean's &lt;init&gt; "method". But wouldn't the assignment in the Java ReadBool make Value refer to a newly created wrapper, throwing away that first object? In that case I would have called &lt;init&gt; for nothing. I think it should be possible to create (in the native code) something that Java sees as an object that is null and whose type is Boolean. Is that possible? Or am I on the wrong track altogether?</p>