Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7117936

java.util.Locale getDefault() initialization is broken

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 7
    • core-libs

      FULL PRODUCT VERSION :
      Java source code, both 1.6 and 1.7

      A DESCRIPTION OF THE PROBLEM :
      java.util.Locale.getDefault() has following flaw: As nothing in the source code seems to impose any multithread visibility constraints (happen-before relationships) it is possible for field defaultLocale to have non-null value before the default-locale-instance is fully initialized. Same problem exists in java.lang.Math.random().




      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Both can be fixed by making variable in question volatile.

            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: