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

NPE in ReflectionFactory.newMethodAccessor when langReflectAccess not initialized

XMLWordPrintable

      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

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

              Created:
              Updated:
              Resolved: