title: I am calling back to java from a c++ dll and CallVoidMethod causes an EXCEPTION_ACCESS_VIOLATION. What am I missing
body: <p>Environment<br>
  C++ DLL created using Visual Studio 2017
  Java program running under Intellij using its supplied Java environement</p>
  
  <p>When I run the java application I get the std::cout messages up to the callback message
  Then the system halts</p>
  
  <p>When I attach the debugger in Visual Studio I get an access violation at address 0x0...0240</p>
  
  <p>Something about the CallVoidMethod is incorrect but I am unsure what. So far I have been unable to find answers that apply to this simple case online.</p>
  
  <p>Code</p>
  
  <p>JAVA</p>
  
  <pre><code>public class Main {
      public native void executeNativeCode();
      static {
          System.loadLibrary("JNITarget" );
      }
      // write your code here
      public static void main(String[] args) {
          new Main().executeNativeCode();
          System.out.println("Java Done");
      }
  
      public void helloWorld() {
          System.out.println("Hello World from Java!");
      }
  
  
   }
  </code></pre>
  
  <p>C++</p>
  
  <pre><code>// JNITarget.cpp : Defines the exported functions for the DLL application.
  //
  
  //#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include "jni.h"
  #include "com_poc_Main.h"
  #include "JNITarget.h"
  
  JNIEXPORT void JNICALL Java_com_poc_Main_executeNativeCode(JNIEnv * env, jobject thisObj) {
      std::cout &lt;&lt; "Hello World from C++!" &lt;&lt; std::endl;
  
      std::cout &lt;&lt; "Get java class object" &lt;&lt; std::endl;
      jclass thisClass = env-&gt;GetObjectClass(thisObj);
      std::cout &lt;&lt; "Get callback method" &lt;&lt; std::endl;
      jmethodID callback = env-&gt;GetMethodID(thisClass, "helloWorld", "()V");
      std::cout &lt;&lt; "Call callback method" &lt;&lt; std::endl;
      env-&gt;CallVoidMethod(thisClass, callback);
      std::cout &lt;&lt; "C++ done" &lt;&lt; std::endl;
  
      return;
  }```
  </code></pre>