title: Jni method crashes the JVM after two calls
body: <p>Well, my problem is that I've got a C++ method that I call from my Java application using Jni. The problem is that the method works well at first call but when it's called a second time, the JVM crashes. There is the displayed error :</p>
  
  <pre><code>#
  # A fatal error has been detected by the Java Runtime Environment:
  #
  #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x77d0e39e, pid=3776, tid=3100
  #
  # JRE version: 6.0_29-b11
  # Java VM: Java HotSpot(TM) Client VM (20.4-b02 mixed mode, sharing windows-x86 )
  # Problematic frame:
  # C  [ntdll.dll+0x2e39e]
  #
  # An error report file with more information is saved as:
  # C:\Users\OPTIMAL1\workspace\XtremeGUI\hs_err_pid3776.log
  #
  # If you would like to submit a bug report, please visit:
  #   http://java.sun.com/webapps/bugreport/crash.jsp
  # The crash happened outside the Java Virtual Machine in native code.
  # See problematic frame for where to report the bug.
  #
  </code></pre>
  
  <p>And here is the C++ method that is called from my Java app using Jni :</p>
  
  <pre><code>JNIEXPORT void JNICALL Java_MainFrame_Jni_Functions_displayParameterResults  (JNIEnv *env, jobject obj){
  
  cout &lt;&lt; "begin!!!!!!!!!!!!!!" &lt;&lt; endl;
  
  cout &lt;&lt; "before!!!!!!!!!!!!!!" &lt;&lt; endl;
  jclass jclazz = env-&gt;FindClass("MainFrame/Jni/TablesObjects");
  cout &lt;&lt; "after***************" &lt;&lt; jclazz &lt;&lt;endl;
  
  
  int size = xtremeDataGA.resultsData.parameter.size();
  jdouble* jdbl = new jdouble(size);
  for(int i=0; i&lt;size; i++)
      jdbl[i] = xtremeDataGA.resultsData.parameter.at(i).at(0).at(0);
  jdoubleArray jdblArr = env-&gt;NewDoubleArray(size);
  env-&gt;SetDoubleArrayRegion(jdblArr, 0, size, jdbl);
  
  
  jclass jStringClass   = env-&gt;FindClass("java/lang/String"); 
  jobjectArray jStringArray = env-&gt;NewObjectArray(6, jStringClass, 0);
  for(int i=0; i&lt;6; i++)
      env-&gt;SetObjectArrayElement(jStringArray, i, env-&gt;NewStringUTF("a") );
  
  
  jmethodID mid = env-&gt;GetStaticMethodID(jclazz, "resultsParameterInsertCol", "([Ljava/lang/Object;[D)V");
  env-&gt;CallStaticVoidMethod(jclazz, mid, jStringArray, jdblArr);
  
  cout &lt;&lt; "end!!!!!!!!!!!!!!" &lt;&lt; endl;
  }
  </code></pre>
  
  <p><strong>EDIT :</strong> The problem is solved. There wasn't any syntax / coding error. The error was due to a global object declaration that I needed to re-declare locally.</p>