RFR: 8329420: Java 22 (and 23) launcher calls default constructor although main() is static [v2]

Jan Lahoda jlahoda at openjdk.org
Mon Apr 15 07:36:05 UTC 2024


On Sun, 14 Apr 2024 06:51:37 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Reflecting review feedback.
>
> src/java.base/share/native/libjli/java.c line 434:
> 
>> 432:     CHECK_EXCEPTION_FAIL();
>> 433:     jobject mainObject = (*env)->NewObject(env, mainClass, constructor);
>> 434:     CHECK_EXCEPTION_NULL_PASS(mainObject);
> 
> There will be a pending exception if NewObject returns NULL. I think it would be a lot easier to read if this were to just check if mainObject is NULL and return 1. Same comment for the other usage in invokeInstanceMainWithoutArgs. That would avoid CHECK_EXCEPTION_NULL_PASS which is very confusing to see at the use-sites.

Thanks! I've done that here:
https://github.com/openjdk/jdk/pull/18753/commits/2022aa5a0d21f930d9b49d1bb0b91ecf7e60ead2

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/18753#discussion_r1565302792


More information about the core-libs-dev mailing list