瀏覽代碼

HPCC-12428 Java package support is broken

Java classloader requires . not / to separate packages, but we could not parse
a classname containing a .

Fix both ways - accept / as the package separator, and parse classnames that
contain ., so that either will be accepted.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 10 年之前
父節點
當前提交
91e7a6ca65
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      plugins/javaembed/javaembed.cpp

+ 4 - 1
plugins/javaembed/javaembed.cpp

@@ -1297,13 +1297,16 @@ public:
         {
         {
             prevtext.clear();
             prevtext.clear();
             // Name should be in the form class.method:signature
             // Name should be in the form class.method:signature
-            const char *funcname = strchr(text, '.');
+            const char *funcname = strrchr(text, '.');
             if (!funcname)
             if (!funcname)
                 throw MakeStringException(MSGAUD_user, 0, "javaembed: Invalid import name %s - Expected classname.methodname:signature", text.str());
                 throw MakeStringException(MSGAUD_user, 0, "javaembed: Invalid import name %s - Expected classname.methodname:signature", text.str());
             const char *signature = strchr(funcname, ':');
             const char *signature = strchr(funcname, ':');
             if (!signature)
             if (!signature)
                 throw MakeStringException(MSGAUD_user, 0, "javaembed: Invalid import name %s - Expected classname.methodname:signature", text.str());
                 throw MakeStringException(MSGAUD_user, 0, "javaembed: Invalid import name %s - Expected classname.methodname:signature", text.str());
             StringBuffer classname(funcname-text, text);
             StringBuffer classname(funcname-text, text);
+            // While it's probably preferred for people to use . as the separator in nested classes (to match java import statement),
+            // we accept / too (to match what you would see in the jar)
+            classname.replace('/', '.');
             funcname++;  // skip the '.'
             funcname++;  // skip the '.'
             StringBuffer methodname(signature-funcname, funcname);
             StringBuffer methodname(signature-funcname, funcname);
             signature++; // skip the ':'
             signature++; // skip the ':'