RFR: 8162563: Fix double checked locking in System.console()

David Holmes david.holmes at oracle.com
Thu Jul 28 01:43:10 UTC 2016


On 27/07/2016 11:39 PM, Martin Buchholz wrote:
>
>
> On Tue, Jul 26, 2016 at 11:13 PM, David Holmes <david.holmes at oracle.com
> <mailto: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.

Ah! Right - my mistake, sorry.

David


More information about the core-libs-dev mailing list