Code

fix bug 346721
authorjohanengelen <johanengelen@users.sourceforge.net>
Sun, 17 May 2009 19:58:51 +0000 (19:58 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Sun, 17 May 2009 19:58:51 +0000 (19:58 +0000)
src/bind/javabind.cpp

index cb8c778b1b6a64b006d8f618aff6f9c2f992c766..f7022584f73624bfa6a28a9603369856afd9632d 100644 (file)
@@ -927,8 +927,14 @@ bool JavaBinderyImpl::loadJVM()
     int versionMinor = (vers    ) & 0xffff;
     msg("Loaded JVM version %d.%d", versionMajor, versionMinor);
 
-    if (!setupGateway())
+    if (!setupGateway()) {
+        // set jvm = NULL, otherwise, this method will return true when called for the second time while the gateway might not have been created!
+        jvm->DestroyJavaVM();
+        jvm = NULL;
+        env = NULL;
+        err("Java bindings: setupGateway() failed");
         return false;
+    }
 
     return true;
 }