RFR: 8318812: LauncherHelper.checkAndLoadMain closes jar file that's about to be re-opened
Alan Bateman
alanb at openjdk.org
Wed Feb 14 16:19:03 UTC 2024
On Wed, 14 Feb 2024 15:49:01 GMT, Christian Stein <cstein at openjdk.org> wrote:
>> src/java.base/share/classes/sun/launcher/LauncherHelper.java line 596:
>>
>>> 594: String mainValue;
>>> 595: try {
>>> 596: Manifest manifest = jarFile.getManifest();
>>
>> I think the try-catch around the block can be dropped and you can put a more targeted try-catch around getManifest, at least I think that is the only case remaining in getMainClassFromJar that needs error handling now.
>
> Dropping that outer try-catch will lead to many whitespace-only changes due to un-indenting lines of the former block. Proceed or keep the indentation stable by making that internal method throw IOE and insert a comment-only block like:
>
>
> /* keep indentation stable */ {
> Manifest manifest = jarFile.getManifest();
> // ...
> }
> Dropping that outer try-catch will lead to many whitespace-only changes due to un-indenting lines of the former block. Proceed or keep the indentation stable by making that internal method throw IOE and insert a comment-only block like:
>
> ```java
> /* keep indentation stable */ {
> Manifest manifest = jarFile.getManifest();
> // ...
> }
> ```
I think it's okay to shift-tab to re-align it after you remove the try-catch. It's a small patch and the changes are easy to see.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17843#discussion_r1489736759
More information about the core-libs-dev
mailing list