RFR: 8302496: Runtime.exit incorrectly says it never throws an exception
Stuart Marks
smarks at openjdk.org
Fri Apr 28 21:49:54 UTC 2023
On Fri, 28 Apr 2023 06:40:16 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Textual specification clarifications.
>
> src/java.base/share/classes/java/lang/Runtime.java line 146:
>
>> 144: * If a security manager is present and its {@link SecurityManager#checkExit checkExit}
>> 145: * method disallows exiting with the specified status, throws {@link SecurityException}.
>> 146: * Otherwise, this method blocks indefinitely; it neither returns nor throws an exception
>
> The SM is not long for this world. So I'm in two minds about it making a farewell appearance in the first paragraph of the method description when we know we will have to remove this text very soon. If we really need to change this now then maybe it could be reduced to "When a security manager is not set, this method never returns ..." so that the distraction of checkExit is not in the first paragraph.
Yeah I had some misgivings mentioning the SM first, but if it's not mentioned, then the assertions in the rest of the text become hedged and uncertain. The SM, checkExit, and whether the exit value is allowed all have to be mentioned somewhere anyway. It would be awkward to try to wedge all of this into a subordinate or parenthetical clause of some other sentence.
Even though we know the SM is on the way out, it's still part of Java SE 21, and it ought to be specified correctly. When the SM is actually removed, we'll have to revisit these specs anyway. Choosing different wording now won't make the future change any easier or harder.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13706#discussion_r1180839803
More information about the core-libs-dev
mailing list