JDK-8284067 : jpackage'd launcher reports non-zero exit codes with error prompt
  • Type: Bug
  • Component: tools
  • Sub-Component: jpackage
  • Affected Version: 17,18,19
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • CPU: x86_64
  • Submitted: 2022-03-28
  • Updated: 2022-09-02
  • Resolved: 2022-04-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 19
17.0.5-oracleFixed 19 b17Fixed
Related Reports
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
When the java application exits with a non-zero exit code, starting with JDK 17.0.2 this is reported by the .exe launcher generated by jpackage. This breaks applications that use exit codes to report results to their surrounding context.

This is a regression introduced by (seemingly left over debug code from) JDK-8272328

REGRESSION : Last worked in version 17

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
jpackage + run the attached program

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
app exits with status code 1
ACTUAL -
error prompt displays "Child process exited with code 1"

---------- BEGIN SOURCE ----------
public static void main(String[] args) {
  System.exit(1);
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
export PATH=%PATH%;C:\path\to\installation\app

FREQUENCY : always



Comments
Fix request [17u] I backport this for parity with 17.0.5-oracle. Clean backport after backporting 8282007. SAP nighlty testing passed.
24-07-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/593 Date: 2022-07-22 18:00:36 +0000
22-07-2022

Changeset: b9cc3bc1 Author: Alexey Semenyuk <asemenyuk@openjdk.org> Date: 2022-04-06 11:49:36 +0000 URL: https://git.openjdk.java.net/jdk/commit/b9cc3bc1bf61572f2813f057eea7326fd0c2bd14
06-04-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8064 Date: 2022-03-31 20:08:13 +0000
31-03-2022

Replace --- if (exitCode != 0) { JP_THROW(tstrings::any() << "Child process exited with code " << exitCode); } --- in https://github.com/openjdk/jdk/blob/master/src/jdk.jpackage/windows/native/applauncher/WinLauncher.cpp with --- exit(exitCode); --- This will mock jvm behavior.
31-03-2022

The issue is caused 17.0.2 onwards. It may be due to the backport of the fix https://bugs.openjdk.java.net/browse/JDK-8272328. JDK 17 - pass: JDK 17.0.2 onwards: fail
31-03-2022

This is a simple command to use- jpackage --type app-image --input tgt --main-class Main --main-jar myjar.jar. The launcher exits with the error message Child process exited with code 1. Screenshot of the error message is attached.
31-03-2022

Requested the submitter for the exact jpackage command used.
31-03-2022