title: How to pass null argument to a Java method from native code
body: <p>I am currently trying to debug a problem we are having with a Java logger that is being called from our native code.</p>
  
  <pre><code>/* convert C to Java String */
  java_string = (*env)-&gt;NewStringUTF(env, string);
  
  /* call log method on logger instance */
  (*env)-&gt;CallVoidMethod(env, logger, log_method_id, java_string);
  </code></pre>
  
  <p>Looking at the Java code I can see that if java_string was erroneously null, this could potentially cause us problems. I wanted to temporarily hack the above code to return a Java null to compare the resulting failure against what we see in the field. How can I make java_string be a Java null?</p>
  
  <p>I have tried the following:-</p>
  
  <pre><code>/* convert C to Java String */
  java_string = NULL;
  
  /* call log method on logger instance */
  (*env)-&gt;CallVoidMethod(env, logger, log_method_id, java_string); 
  </code></pre>
  
  <p>but this appears to result in the string "null" being sent to the Java method.</p>
  
  <p>Just to be clear, I have no intention of deliberately passing null to this method, I only want to test what would happen with the resulting NullPointerException since we are calling the Java code from C.</p>