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

Incorrect double-checked locking in sun.java2d.CRenderer

XMLWordPrintable

    • 2d

      SonarCloud reports multiple incorrect double-checked locking cases in sun.java2d.CRenderer. For example:

        Arc2D arcToShape;

        ...
                  if (arcToShape == null) {
                      synchronized (this) {
                          if (arcToShape == null) {
                              arcToShape = new Arc2D.Float();
                          }
                      }
                  }

      Arc2D contains fields that are not final. arcToShape is not volatile. This makes it an incorrect DCL.
      This code is used by Mac OS, do it would probably blow up some time later on M1.

      But maybe there is no need to do any of this, because the setter methods overwrite the contents of all these objects under their own sync.
      So, maybe we can just allocate those objects without DCL-backed caching and pass them in?

            serb Sergey Bylokhov
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: