RFR: 8332084: Ensure JdkConsoleImpl.restoreEcho visibility in a shutdown hook [v4]
Naoto Sato
naoto at openjdk.org
Tue May 14 16:26:06 UTC 2024
On Mon, 13 May 2024 21:32:18 GMT, Naoto Sato <naoto at openjdk.org> wrote:
>> Making sure `restoreEcho` correctly reflects the state in the shutdown thread, which differs from the application's thread that issues the `readPassword()` method.
>
> Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
>
> Addresses a review comment
OK, I realized removing checking `restoreEcho` does not work, here is why.
> It should be possible to provide something adequate based on atomic primitives. However, it would complicate code. So, let's first clarify the problem that `restoreEcho` is trying to solve: why is it important to restore the echo state upon JVM exit? What would happen if we fail to do that? Can it be demonstrated?
`restoreEcho`, as I understand it, does what it stands, ie., restore the platform console's echo status. Since `java.base`'s Console implementation relies on the platform's echo function, JVM needs to restore the original echo state after JVM quits. So in an unlike situation where the echo is off when the JVM starts, my proposal won't work. We'll still have restoreEcho check in the shutdown thread.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19184#issuecomment-2110644430
More information about the core-libs-dev
mailing list