RFR: 8329581: Java launcher no longer prints a stack trace
Alan Bateman
alanb at openjdk.org
Tue Apr 16 10:33:00 UTC 2024
On Tue, 16 Apr 2024 08:25:01 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> src/java.base/share/classes/sun/launcher/LauncherHelper.java line 912:
>>
>>> 910: private static final int MAIN_WITHOUT_ARGS = 1;
>>> 911: private static final int MAIN_NONSTATIC = 2;
>>> 912: private static int mainType = 0;
>>
>> Nit: transferring information from java to C in this way is usually done, AFAICS, by accessing static fields directly (GetStaticFieldID+GetStaticXXXField). There is also a helper function that wraps this, see JNU_GetStaticFieldByName. Not sure if you have that available in libjli though. There are many examples for both patterns.
>>
>> I also would consider just declaring two booleans here, isStatic and hasArgs, which that would be a bit clearer to read instead of combining both into a single flag variable, and no need to keep flag values synced across java/C.
>
> Thinking about this some more, would it not be possible to just use the mainMethod directly down in C?
The changes JEP 463 went through many iterations, it was a fine balance of avoiding too many transitions and upscales, and at the same time, have something that can be maintained. There are several JBS issues on this issue now, probably because there just wasn't enough tests introduced with the JEP.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18786#discussion_r1567124485
More information about the core-libs-dev
mailing list