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

Class.getReflectionFactory() is not thread-safe

    XMLWordPrintable

    Details

      Description

      A DESCRIPTION OF THE PROBLEM :
      The private method `java.lang.Class.getReflectionFactory()` appears to not be thread-safe.
      It lazily initializes the `reflectionFactory` field but there is no happens-before relationship. Therefore it is allowed by the Java Memory Model that the first read of the `reflectionFactory` reads a non-null value and the second read (as part of the `return`) statement returns null, causing a NullPointerException for the caller.

      See also https://shipilev.net/blog/2016/close-encounters-of-jmm-kind/#wishful-benign-is-resilient


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              darcy Joe Darcy
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: