Basically, we have a customer who use the jar command to zip up data files generated in a directory, most of the time the files don't exist. With JDK11, the jar archive is not created, and they see their tests failing. Their tests were probably written to suit the JDK8 behavior.
However, if this behavior introduced in JDK9 was intentional, I am good with it. Thank you for the advice! Thanks, Pasam Soujanya. ________________________________ From: Alan Bateman <[email protected]> Sent: Tuesday, March 15, 2022 2:27 PM To: Pasam Soujanya1 <[email protected]> Cc: [email protected] <[email protected]>; [email protected] <[email protected]> Subject: [EXTERNAL] Re: Behavior change in the jar tool JDK11 vs JDK8. On 15/03/2022 08:18, Pasam Soujanya1 wrote: I tried "tar" with a target that does not exist, and the tar file got created successfully (with an error message about the missing file) and with the exit code 0 (success). Same behavior ZjQcmQRYFpfptBannerStart This Message Is From an External Sender This message came from outside your organization. ZjQcmQRYFpfptBannerEnd On 15/03/2022 08:18, Pasam Soujanya1 wrote: I tried "tar" with a target that does not exist, and the tar file got created successfully (with an error message about the missing file) and with the exit code 0 (success). Same behavior is seen with JDK8 jar too. From JDK11 onward, the output jar isn't created and the exit code is 1(failure). So, to summarise: "jar" from Java 8 seems to be on the lines of "tar". Do we want to continue with this "jar" behaviour which is not the same as "tar" ? The behavior since JDK 9 is to delete the temporary file when there is an error. This looks to be the correct behavior. If it were changed back then people would complain that jar is leaving files behind when it fails. I'm curious how you run into this. Is this a script that runs with +e or doesn't check the exit status? -Alan
