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

Refactored reflection throws null pointer when setting unassignable type on static field

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • This happens in all environments. Introduced in build 18-ea+24-1608.

      The jdk.internal.reflect.MethodHandleObjectFieldAccessorImpl::set(Object, Object) method handles a class cast exception via:

          catch (ClassCastException e) {
            throw newSetIllegalArgumentException(obj.getClass());
          }

      The target, obj can however be null if targeting a static field. In this case, a NullPointerException is thrown instead of the expected IllegalArgumentException.

            Unassigned Unassigned
            winterhalter Rafael Winterhalter
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: