ADDITIONAL SYSTEM INFORMATION :
openjdk 17.0.3 2022-04-19
OpenJDK Runtime Environment (build 17.0.3+7-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.3+7-Debian-1deb11u1, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
When starting a jpackage launcher inside a Java application that was itself started with a jpackage launcher, instead of starting the second application, it outputs the same as `java --help`
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create two jar-files: one which starts the other one using the jpackage launcher and the other one doing something arbitrary (for simplicity, use a Hello World program; see "Source code for an executable test case" below). Then package the two using jpackage (Here, "a.jar" will attempt to start "b.jar" using the generated jpackage launcher):
# jpackage --name "a" --input path/to/a_jar --main-jar a.jar --type app-image --dest output-dir
# jpackage --name "b" --input path/to/a_jar --main-jar b.jar --type app-image --dest output-dir
After that, `cd` to `output-dir` and execute the following two commands:
# java -jar a/lib/app/a.jar
# a/bin/a
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both commands should behave exactly the same.
ACTUAL -
The first command behaves as expected:
[a] starting process
[a] process started, waiting for termination
[b] Hello World!
pure virtual method called
terminate called without an active exception
[a] b terminated.
The second command outputs this:
[a] starting process
[a] process started, waiting for termination
Usage: java [options] <mainclass> [args...]
(to execute a class)
or java [options] -jar <jarfile> [args...]
(to execute a jar file)
or java [options] -m <module>[/<mainclass>] [args...]
java [options] --module <module>[/<mainclass>] [args...]
(to execute the main class in a module)
or java [options] <sourcefile> [args]
(to execute a single source-file program)
Arguments following the main class, source file, -jar <jarfile>,
-m or --module <module>/<mainclass> are passed as the arguments to
main class.
...
pure virtual method called
terminate called without an active exception
[a] b terminated.
pure virtual method called
terminate called without an active exception
Aborted
(The `pure virtual method called` and `terminate called without an active exception` come from another issue I reported earlier)
---------- BEGIN SOURCE ----------
Code used for `a.jar`:
package a;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
System.out.println("[a] starting process");
var p = new ProcessBuilder("b/bin/b")
.inheritIO()
.start();
System.out.println("[a] process started, waiting for termination");
p.waitFor();
System.out.println("[a] b terminated.");
}
}
Code used for `b.jar`:
package b;
public class Main {
public static void main(String[] args) {
System.out.println("[b] Hello World!");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Before starting `b/bin/b`, remove the environment variable `_JPACKAGE_LAUNCHER`:
var builder = new ProcessBuilder("b/bin/b")
.inheritIO();
builder.environment().remove("_JPACKAGE_LAUNCHER");
var p = builder.start();
FREQUENCY : always
openjdk 17.0.3 2022-04-19
OpenJDK Runtime Environment (build 17.0.3+7-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.3+7-Debian-1deb11u1, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
When starting a jpackage launcher inside a Java application that was itself started with a jpackage launcher, instead of starting the second application, it outputs the same as `java --help`
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create two jar-files: one which starts the other one using the jpackage launcher and the other one doing something arbitrary (for simplicity, use a Hello World program; see "Source code for an executable test case" below). Then package the two using jpackage (Here, "a.jar" will attempt to start "b.jar" using the generated jpackage launcher):
# jpackage --name "a" --input path/to/a_jar --main-jar a.jar --type app-image --dest output-dir
# jpackage --name "b" --input path/to/a_jar --main-jar b.jar --type app-image --dest output-dir
After that, `cd` to `output-dir` and execute the following two commands:
# java -jar a/lib/app/a.jar
# a/bin/a
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both commands should behave exactly the same.
ACTUAL -
The first command behaves as expected:
[a] starting process
[a] process started, waiting for termination
[b] Hello World!
pure virtual method called
terminate called without an active exception
[a] b terminated.
The second command outputs this:
[a] starting process
[a] process started, waiting for termination
Usage: java [options] <mainclass> [args...]
(to execute a class)
or java [options] -jar <jarfile> [args...]
(to execute a jar file)
or java [options] -m <module>[/<mainclass>] [args...]
java [options] --module <module>[/<mainclass>] [args...]
(to execute the main class in a module)
or java [options] <sourcefile> [args]
(to execute a single source-file program)
Arguments following the main class, source file, -jar <jarfile>,
-m or --module <module>/<mainclass> are passed as the arguments to
main class.
...
pure virtual method called
terminate called without an active exception
[a] b terminated.
pure virtual method called
terminate called without an active exception
Aborted
(The `pure virtual method called` and `terminate called without an active exception` come from another issue I reported earlier)
---------- BEGIN SOURCE ----------
Code used for `a.jar`:
package a;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
System.out.println("[a] starting process");
var p = new ProcessBuilder("b/bin/b")
.inheritIO()
.start();
System.out.println("[a] process started, waiting for termination");
p.waitFor();
System.out.println("[a] b terminated.");
}
}
Code used for `b.jar`:
package b;
public class Main {
public static void main(String[] args) {
System.out.println("[b] Hello World!");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Before starting `b/bin/b`, remove the environment variable `_JPACKAGE_LAUNCHER`:
var builder = new ProcessBuilder("b/bin/b")
.inheritIO();
builder.environment().remove("_JPACKAGE_LAUNCHER");
var p = builder.start();
FREQUENCY : always
- relates to
-
JDK-8248239 jpackage adds some arguments twice in case it is re-executed by JLI
- Resolved