Skip to content

Commit

Permalink
fix(bundler/launcher): Don't pass argv[0] to Java.
Browse files Browse the repository at this point in the history
args in Java don't include the command.
  • Loading branch information
e3ndr committed Nov 9, 2024
1 parent 521006e commit c5aad6c
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions bundler/src/main/c/src/java.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,20 @@ void *call_java_main(void *tenv)
return NULL;
}

jobjectArray args = (*env)->NewObjectArray(env, argc, (*env)->FindClass(env, "java/lang/String"), NULL);
for (jint i = 0; i < argc; i++)
jobjectArray args;
if (argc > 1)
{
jstring arg = (*env)->NewStringUTF(env, argv[i]);
(*env)->SetObjectArrayElement(env, args, i, arg);
// Start at IDX=1 so that Java doesn't receive the executable command.
int argcMinusExec = argc - 1;
args = (*env)->NewObjectArray(env, argcMinusExec, (*env)->FindClass(env, "java/lang/String"), NULL);
for (jint i = 0; i < argcMinusExec; i++)
{
jstring arg = (*env)->NewStringUTF(env, argv[i + 1]);
(*env)->SetObjectArrayElement(env, args, i, arg);
}
}
else
args = (*env)->NewObjectArray(env, 0, (*env)->FindClass(env, "java/lang/String"), NULL);

(*env)->CallStaticVoidMethod(env, main_class, main_method, args);

Expand Down
Binary file modified bundler/src/main/resources/aarch64-linux-gnu.2.36/launcher
Binary file not shown.
Binary file modified bundler/src/main/resources/aarch64-macos-none/launcher
Binary file not shown.
Binary file modified bundler/src/main/resources/arm-linux-gnueabihf.2.36/launcher
Binary file not shown.
Binary file modified bundler/src/main/resources/powerpc64le-linux-gnu.2.36/launcher
Binary file not shown.
Binary file modified bundler/src/main/resources/x86_64-linux-gnu.2.36/launcher
Binary file not shown.
Binary file modified bundler/src/main/resources/x86_64-macos-none/launcher
Binary file not shown.
Binary file modified bundler/src/main/resources/x86_64-windows-msvc/launcher.exe
Binary file not shown.

0 comments on commit c5aad6c

Please sign in to comment.