title: JNI_CreateJavaVM() runs O.K. 1x, but after that: failed with result: -5 (Win64, Cython, Python)
body: <p><strong>Error</strong>:</p>
  <p>Does not occur on run 1, but on any subsequent run, Python kernel dies and has to be restarted:</p>
  <pre><code>JNI_CreateJavaVM() failed with result: -5
  [SpyderKernelApp] WARNING | No such comm: aa125bd78d0711ebb9a2001a7dda7113 
  </code></pre>
  <p><strong>Environment</strong>:</p>
  <ul>
  <li>All current as of 3/2021</li>
  <li>Win64</li>
  <li>Anaconda (actually mini-anaconda)</li>
  <li>Java runtime for Win64</li>
  <li>Saxon/C (compiled for Win64) 1.2.1 running with Saxon-HE 9.9.1.5C from Saxonica</li>
  </ul>
  <p><strong>Test scripts</strong></p>
  <p>These Saxon/c provided test scripts produce the same behavior. Run O.K. one time but on second run cause the python kernel to crash:</p>
  <ul>
  <li>saxon_example.py</li>
  <li>saxon_example2.py</li>
  <li>saxon_example3.py</li>
  </ul>
  <p><strong>Speculation?</strong></p>
  <p>No in-depth experience under the hood here with cross compiling, cython, C++, JNI, etc.</p>
  <p>Perhaps the first such JNI request loads the JavaVM on Windows and it remains running. (...How does it eventually know to exit?) Subsequent requests via JNI are not sent to the correct memory location i.e. <em>&quot;WARNING | No such comm: aa125bd78d0711ebb9a2001a7dda7113&quot;</em>? Pointer problem?</p>
  <p><strong>Attempt 1</strong>
  Removed all prior versions of Java runtime (win64). Reinstalled latest Java runtime. No change.</p>
  <p><strong>Update 2</strong></p>
  <p>Andrew, thanks for the info.</p>
  <p>I'm finding this situation has a few &quot;layers&quot; to it. The library I'm trying to run from Python is saxon/c. Saxon starts out in life as Java, compiled to object code (compatible with Win64) using Excelsior JET Enterprise 15.3 MP1 (10/2019). Other parts are in C and C++ compiled with Windows Visual C++ compiler. Finally cpython is also used during the build process.</p>
  <p>Pretty sure a conventional Java run time (that runs typical JAR files is not needed, as Excelsior yields object code?  I think Excelsior JET Enterprise does supplies some ancillary object code for its Java compiler, much the same as Visual C++ has required run times. So precisely how the JNI code is incorporated I'm not sure?</p>
  <p>Adding some &quot;fog&quot; to the situation - Excelsior headquartered in Russia exited, the Java compiler business, eliminating all support and reportedly sold out to the Chinese telecom firm Huawei who promptly removed all traces of the Excelsior website. (Can't make this stuff up!)</p>
  <p>The python scripts run once fine but on the second run they crash the python kernel with the JNI comm error. Somehow restarting the python kernel fixes things, yet all attempts to get rid of the saxonc.PySaxonProcessor object are ineffective.</p>
  <pre><code>import saxonc
  
  with saxonc.PySaxonProcessor(license=False) as proc:
     print(dir(proc))  #shows proc is running
  
  proc.release()
  proc=None
  del proc
  '''
  </code></pre>