RFR: 8162563: Fix double checked locking in System.console()
Martin Buchholz
martinrb at google.com
Wed Jul 27 13:39:44 UTC 2016
On Tue, Jul 26, 2016 at 11:13 PM, David Holmes <david.holmes at oracle.com>
wrote:
> On 27/07/2016 3:45 PM, Martin Buchholz wrote:
>
>> Hi David,
>>
>> I didn't even look at Console.java! I just fixed the double-checked
>> locking in System.java.
>>
>> Looking now at Console.cons, that is NOT safely statically initialized:
>>
>> SharedSecrets.setJavaIOAccess(new JavaIOAccess() {
>> public Console console() {
>> if (istty()) {
>> if (cons == null)
>> cons = new Console();
>> return cons;
>> }
>> return null;
>> }
>>
>> (but it's currently safe because only System.java accesses it)
>>
>
> The above code is in a static initialization block.
>
Sure, but the code isn't run (yet), just made available to be run later via
JavaIOAccess when System.console() is called.
More information about the core-libs-dev
mailing list