ADDITIONAL SYSTEM INFORMATION :
OS: Windows 10 / 11
Java 21.0.2 / 17.0.10
A DESCRIPTION OF THE PROBLEM :
I created a jpackage app that restarts itself to dynamically configure the runtime environment.
All restarted app processes will exit when the initially started app process process exits.
It seems that it is relatedJDK-8301247 and JDK-8272328.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile Main.java.
2. Create jar as jpackage_test.jar into res dir.
3. Create app-image using jpackage command.
jpackage --type app-image --input res --dest dst --main-jar jpackage_test.jar --main-class Main
4. Execute dst/Main/Main.exe. It shows a JFrame with a JButton labeled "Restart this app as a child process";
5. Push JButton to restart Main.exe as a child process.
6. Press the close box of JFrame shown by the initially started Main.exe to exit the process.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The lifecycle of Main.exe that is initially started does not affect the lifecycle of restarted Main.exe.
ACTUAL -
If you terminate the Main.exe that initially started, all the restarted Main.exe will terminate.
---------- BEGIN SOURCE ----------
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class Main {
private static final String ENV_RESTARTED = "RESTARTED";
private static String restarted;
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
restarted = System.getenv(ENV_RESTARTED);
if(restarted==null) {
restarted = "0";
}
JFrame frame = new JFrame(restarted);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button = new JButton("Restart this app as a child process");
button.addActionListener((e) -> {
try {
String appPath = System.getProperty("jpackage.app-path");
ProcessBuilder builder = new ProcessBuilder(appPath);
Map<String,String> env = builder.environment();
env.put(ENV_RESTARTED, Integer.toString(Integer.valueOf(restarted)+1));
builder.start();
}
catch(Exception ex) {
ex.printStackTrace();
}
});
frame.setContentPane(button);
frame.pack();
frame.setVisible(true);
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround.
FREQUENCY : always
OS: Windows 10 / 11
Java 21.0.2 / 17.0.10
A DESCRIPTION OF THE PROBLEM :
I created a jpackage app that restarts itself to dynamically configure the runtime environment.
All restarted app processes will exit when the initially started app process process exits.
It seems that it is related
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile Main.java.
2. Create jar as jpackage_test.jar into res dir.
3. Create app-image using jpackage command.
jpackage --type app-image --input res --dest dst --main-jar jpackage_test.jar --main-class Main
4. Execute dst/Main/Main.exe. It shows a JFrame with a JButton labeled "Restart this app as a child process";
5. Push JButton to restart Main.exe as a child process.
6. Press the close box of JFrame shown by the initially started Main.exe to exit the process.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The lifecycle of Main.exe that is initially started does not affect the lifecycle of restarted Main.exe.
ACTUAL -
If you terminate the Main.exe that initially started, all the restarted Main.exe will terminate.
---------- BEGIN SOURCE ----------
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class Main {
private static final String ENV_RESTARTED = "RESTARTED";
private static String restarted;
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
restarted = System.getenv(ENV_RESTARTED);
if(restarted==null) {
restarted = "0";
}
JFrame frame = new JFrame(restarted);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button = new JButton("Restart this app as a child process");
button.addActionListener((e) -> {
try {
String appPath = System.getProperty("jpackage.app-path");
ProcessBuilder builder = new ProcessBuilder(appPath);
Map<String,String> env = builder.environment();
env.put(ENV_RESTARTED, Integer.toString(Integer.valueOf(restarted)+1));
builder.start();
}
catch(Exception ex) {
ex.printStackTrace();
}
});
frame.setContentPane(button);
frame.pack();
frame.setVisible(true);
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround.
FREQUENCY : always
- relates to
-
JDK-8325203 System.exit(0) kills the launched 3rd party application
- Resolved