RFR: 8274397: [macOS] Stop setting env. var JAVA_MAIN_CLASS_<pid> in launcher code [v2]

Phil Race prr at openjdk.java.net
Wed Sep 29 03:12:39 UTC 2021

On Wed, 29 Sep 2021 01:46:32 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> Phil Race has updated the pull request incrementally with one additional commit since the last revision:
>>   8274397: [macOS] Stop setting env. var JAVA_MAIN_CLASS_<pid> in launcher code
> src/java.base/macosx/native/libjli/java_md_macosx.m line 879:
>> 877:     }
>> 878: 
>> 879:     (*env)->DeleteLocalRef(env, jKey);
> I am not sure about error handling, the jkey is not removed when NULL_CHECK is used. Also an exceptions are not cleared in case of NULL_CHECK like in other cases, is it intentional?

Well .. they aren't removed by the existing code either. And this is the launcher.
So far as I can tell if we error out of here (as I found when I made a typo in a method signature) the
VM exits very rapidly. So if I do anything here, it would be to remove DeleteLocalRef since it really doesn't matter to clean up local refs when you are either bailing from native .. or the entire process .. cleaning up when you are continuing on (as the code does) is perhaps more important since you might need more local refs before you are done.
Or file a separate bug against the launcher and JNI clean up after error handling.
java.base/share/native/libjli/java.c is a good example of where the same pattern exists.


PR: https://git.openjdk.java.net/jdk/pull/5724

More information about the core-libs-dev mailing list