瀏覽代碼

Merge pull request #4907 from dcamper/master

HPCC-10131: Add support for optional 'jvmlibpath' property in environment.conf; add additional error checking to JVM initialization.

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 11 年之前
父節點
當前提交
ce2e4609a4
共有 1 個文件被更改,包括 22 次插入5 次删除
  1. 22 5
      plugins/javaembed/javaembed.cpp

+ 22 - 5
plugins/javaembed/javaembed.cpp

@@ -80,21 +80,34 @@ public:
         StringArray optionStrings;
         const char* origPath = getenv("CLASSPATH");
         StringBuffer newPath;
-        newPath.append("-Djava.class.path=").append(origPath);
+        newPath.append("-Djava.class.path=");
+        if (origPath && *origPath)
+        {
+            newPath.append(origPath).append(ENVSEPCHAR);
+        }
         StringBuffer envConf;
         envConf.append(CONFIG_DIR).append(PATHSEPSTR).append("environment.conf");
         Owned<IProperties> conf = createProperties(envConf.str(), true);
         if (conf && conf->hasProp("classpath"))
         {
-            newPath.append(ENVSEPCHAR);
             conf->getProp("classpath", newPath);
+            newPath.append(ENVSEPCHAR);
         }
         else
         {
-            newPath.append(ENVSEPCHAR).append(INSTALL_DIR).append(PATHSEPCHAR).append("classes");
+            newPath.append(INSTALL_DIR).append(PATHSEPCHAR).append("classes").append(ENVSEPCHAR);
         }
-        newPath.append(ENVSEPCHAR).append(".");
+        newPath.append(".");
         optionStrings.append(newPath);
+        
+        if (conf && conf->hasProp("jvmlibpath"))
+        {
+            StringBuffer libPath;
+            libPath.append("-Djava.library.path=");
+            conf->getProp("jvmlibpath", libPath);
+            optionStrings.append(libPath);
+        }
+        
         if (conf && conf->hasProp("jvmoptions"))
         {
             optionStrings.appendList(conf->queryProp("jvmoptions"), ENVSEPSTR);
@@ -107,6 +120,7 @@ public:
         JavaVMOption* options = new JavaVMOption[optionStrings.length()];
         ForEachItemIn(idx, optionStrings)
         {
+            DBGLOG("javaembed: Setting JVM option: %s",(char *)optionStrings.item(idx));
             options[idx].optionString = (char *) optionStrings.item(idx);
             options[idx].extraInfo = NULL;
         }
@@ -116,9 +130,12 @@ public:
         vm_args.version = JNI_VERSION_1_6;
         /* load and initialize a Java VM, return a JNI interface pointer in env */
         JNIEnv *env;       /* receives pointer to native method interface */
-        JNI_CreateJavaVM(&javaVM, (void**)&env, &vm_args);
+        int createResult = JNI_CreateJavaVM(&javaVM, (void**)&env, &vm_args);
 
         delete [] options;
+        
+        if (createResult != 0)
+            throw MakeStringException(0, "javaembed: Unable to initialize JVM (%d)",createResult);
     }
     ~JavaGlobalState()
     {