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

NPE in ReflectionFactory.newMethodAccessor when langReflectAccess not initialized

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 11, 12, 13
    • Fix Version/s: 13
    • Component/s: core-libs

      Description

      ReflectionFactory access to instance variable langReflectAccess can NullPointerException if it has not been initialized correctly. During testing with OpenJDK for OpenJ9 this was discovered:
      Caused by: java.lang.NullPointerException
      at java.base/jdk.internal.reflect.ReflectionFactory.newMethodAccessor(ReflectionFactory.java:200)
      at java.base/java.lang.reflect.Method.acquireMethodAccessor(Method.java:632)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)

      This is due to the field jdk.internal.reflect.ReflectionFactory.langReflectAccess hasn't been initialized yet.
      The code snippet in question Method root = langReflectAccess.getRoot(method); should be Method root = langReflectAccess().getRoot(method); like elsewhere in the class.

      3 occurrences have this problem in ReflectionFactory.java, lines 178, 200, 236

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              aleonard Andrew Leonard
              Reporter:
              aleonard Andrew Leonard
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: