Skip to content

Commit

Permalink
Remove stale Java support
Browse files Browse the repository at this point in the history
Directly tied to OMPI. Java apps are still supported, but now
must specify to "preload files" and include the list of jar
files to be pre-positioned.

Signed-off-by: Ralph Castain <rhc@pmix.org>
  • Loading branch information
rhc54 committed May 28, 2022
1 parent 48e44f4 commit 551c927
Showing 1 changed file with 1 addition and 142 deletions.
143 changes: 1 addition & 142 deletions src/prted/prte_app_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,7 @@ static int create_app(prte_schizo_base_module_t *schizo, char **argv, pmix_list_
app->app.maxprocs = count;
}

/* see if we need to preload the binary to
* find the app - don't do this for java apps, however, as we
* can't easily find the class on the cmd line. Java apps have to
* preload their binary via the preload_files option
*/
appname = pmix_basename(app->app.cmd);
if (0 == strcmp(appname, "java")) {
opt = pmix_cmd_line_get_param(&results, PRTE_CLI_PRELOAD_BIN);
if (NULL != opt) {
PMIX_INFO_LIST_ADD(rc, app->info, PMIX_SET_SESSION_CWD, NULL, PMIX_BOOL);
PMIX_INFO_LIST_ADD(rc, app->info, PMIX_PRELOAD_BIN, NULL, PMIX_BOOL);
}
}
/* check for preload files */
opt = pmix_cmd_line_get_param(&results, "preload-files");
if (NULL != opt) {
PMIX_INFO_LIST_ADD(rc, app->info, PMIX_PRELOAD_FILES, opt->values[0], PMIX_STRING);
Expand All @@ -247,135 +235,6 @@ static int create_app(prte_schizo_base_module_t *schizo, char **argv, pmix_list_
goto cleanup;
}

/* if this is a Java application, we have a bit more work to do. Such
* applications actually need to be run under the Java virtual machine
* and the "java" command will start the "executable". So we need to ensure
* that all the proper java-specific paths are provided
*/
if (0 == strcmp(appname, "java")) {
/* see if we were given a library path */
found = false;
for (i = 1; NULL != app->app.argv[i]; i++) {
if (NULL != strstr(app->app.argv[i], "java.library.path")) {
char *dptr;
/* find the '=' that delineates the option from the path */
if (NULL == (dptr = strchr(app->app.argv[i], '='))) {
/* that's just wrong */
rc = PRTE_ERR_BAD_PARAM;
goto cleanup;
}
/* step over the '=' */
++dptr;
/* yep - but does it include the path to the mpi libs? */
found = true;
if (NULL == strstr(app->app.argv[i], prte_install_dirs.libdir)) {
/* doesn't appear to - add it to be safe */
if (':' == app->app.argv[i][strlen(app->app.argv[i] - 1)]) {
pmix_asprintf(&value, "-Djava.library.path=%s%s", dptr,
prte_install_dirs.libdir);
} else {
pmix_asprintf(&value, "-Djava.library.path=%s:%s", dptr,
prte_install_dirs.libdir);
}
free(app->app.argv[i]);
app->app.argv[i] = value;
}
break;
}
}
if (!found) {
/* need to add it right after the java command */
pmix_asprintf(&value, "-Djava.library.path=%s", prte_install_dirs.libdir);
pmix_argv_insert_element(&app->app.argv, 1, value);
free(value);
}

/* see if we were given a class path */
found = false;
for (i = 1; NULL != app->app.argv[i]; i++) {
if (NULL != strstr(app->app.argv[i], "cp")
|| NULL != strstr(app->app.argv[i], "classpath")) {
/* yep - but does it include the path to the mpi libs? */
found = true;
/* check if mpi.jar exists - if so, add it */
value = pmix_os_path(false, prte_install_dirs.libdir, "mpi.jar", NULL);
if (access(value, F_OK) != -1) {
set_classpath_jar_file(app, i + 1, "mpi.jar");
}
free(value);
/* check for oshmem support */
value = pmix_os_path(false, prte_install_dirs.libdir, "shmem.jar", NULL);
if (access(value, F_OK) != -1) {
set_classpath_jar_file(app, i + 1, "shmem.jar");
}
free(value);
/* always add the local directory */
pmix_asprintf(&value, "%s:%s", app->app.cwd, app->app.argv[i + 1]);
free(app->app.argv[i + 1]);
app->app.argv[i + 1] = value;
break;
}
}
if (!found) {
/* check to see if CLASSPATH is in the environment */
found = false; // just to be pedantic
for (i = 0; NULL != environ[i]; i++) {
if (0 == strncmp(environ[i], "CLASSPATH", strlen("CLASSPATH"))) {
value = strchr(environ[i], '=');
++value; /* step over the = */
pmix_argv_insert_element(&app->app.argv, 1, value);
/* check for mpi.jar */
value = pmix_os_path(false, prte_install_dirs.libdir, "mpi.jar", NULL);
if (access(value, F_OK) != -1) {
set_classpath_jar_file(app, 1, "mpi.jar");
}
free(value);
/* check for shmem.jar */
value = pmix_os_path(false, prte_install_dirs.libdir, "shmem.jar", NULL);
if (access(value, F_OK) != -1) {
set_classpath_jar_file(app, 1, "shmem.jar");
}
free(value);
/* always add the local directory */
pmix_asprintf(&value, "%s:%s", app->app.cwd, app->app.argv[1]);
free(app->app.argv[1]);
app->app.argv[1] = value;
pmix_argv_insert_element(&app->app.argv, 1, "-cp");
found = true;
break;
}
}
if (!found) {
/* need to add it right after the java command - have
* to include the working directory and trust that
* the user set cwd if necessary
*/
char *str, *str2;
/* always start with the working directory */
str = strdup(app->app.cwd);
/* check for mpi.jar */
value = pmix_os_path(false, prte_install_dirs.libdir, "mpi.jar", NULL);
if (access(value, F_OK) != -1) {
pmix_asprintf(&str2, "%s:%s", str, value);
free(str);
str = str2;
}
free(value);
/* check for shmem.jar */
value = pmix_os_path(false, prte_install_dirs.libdir, "shmem.jar", NULL);
if (access(value, F_OK) != -1) {
pmix_asprintf(&str2, "%s:%s", str, value);
free(str);
str = str2;
}
free(value);
pmix_argv_insert_element(&app->app.argv, 1, str);
free(str);
pmix_argv_insert_element(&app->app.argv, 1, "-cp");
}
}
}

// parse any environment-related cmd line options
rc = schizo->parse_env(prte_launch_environ, &app->app.env, &results);
if (PRTE_SUCCESS != rc) {
Expand Down

0 comments on commit 551c927

Please sign in to comment.