RFR: JDK-8202105: jshell tool: on exiting, terminal echo is disabled

Xueming Shen xueming.shen at oracle.com
Thu Apr 26 18:09:34 UTC 2018


On 4/26/18, 3:23 AM, Jan Lahoda wrote:
> On 25.4.2018 22:59, Xueming Shen wrote:
>> On 04/25/2018 01:39 PM, Jan Lahoda wrote:
>>> So, if I understand correctly, it would be:
>>> boolean flipEcho;
>>> and the readPassword would do something like:
>>> if (echo0() != false) {
>>
>> if (echo0()) { ...
>>
>>>     flipEcho = true;
>>>     echo(false);
>>> }
>>> ....
>>> if (flipEcho) { //this would also be in the shutdown hook
>>>      echo(!echo0());
>>> }
>>
>> if (flipEcho) {
>>      echo(true);
>>      flipEcho = false;
>> }
>> ?
>
> Hmm, right. It start to look a lot like the original code, with the 
> exception that the flag is also checked inside readPassword:
> http://cr.openjdk.java.net/~jlahoda/8202105/webrev.01/
>
> (This also makes the shutdown hook registration lazy.)
>
> Jan
shouldn't we move the installShutonwHookIfNeeded() into synced block? and
simply name it "installShutdownHook()" ?

the rest looks fine.

-sherman


More information about the core-libs-dev mailing list