RFR: 8329420: Java 22 (and 23) launcher calls default constructor although main() is static [v2]
Jan Lahoda
jlahoda at openjdk.org
Tue Apr 16 13:30:00 UTC 2024
On Tue, 16 Apr 2024 10:03:21 GMT, David Holmes <dholmes 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 419:
>
>> 417: invokeInstanceMainWithArgs(JNIEnv *env, jclass mainClass, jobjectArray mainArgs) {
>> 418: jmethodID constructor = (*env)->GetMethodID(env, mainClass, "<init>", "()V");
>> 419: CHECK_EXCEPTION_FAIL();
>
> Shouldn't this also not be checked until you know you have an instance method?
You mean to first check whether the method exists, and only then try to lookup the constructor? Not sure if that has observable effects, but I can do that.
I missed [JDK-8329581](https://bugs.openjdk.org/browse/JDK-8329581) before, my plan is to adjust this "check for exception and clear it" check to only work for `NoSuchMethodError`, and let the exception pass for any other exception.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18753#discussion_r1567361164
More information about the core-libs-dev
mailing list