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

IndirectVarHandle.isAccessModeSupported throws NPE

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 22
    • 20, 21
    • core-libs

    Backports

      Description

        IndirectVarHandle, added by foreign API to support coordinate mapping, value filtering, etc. does not properly implement VarHandle.isAccessModeSupported. It throws an NPE upon invocation, which is most likely undesired.

        Example code in JShell (run with --enable-preview):
        ```java
        var lookup = MethodHandles.lookup();
        var arrayVh = MethodHandles.arrayElementVarHandle(int[].class);
        var addOne = lookup.bind((IntUnaryOperator) a -> a + 1, "applyAsInt", MethodType.methodType(int.class, int.class));
        var patchedArrayVh = MethodHandles.filterCoordinates(arrayVh, 1, addOne);
        patchedArrayVh.isAccessModeSupported(VarHandle.AccessMode.GET); // NPE
        ```

        Attachments

          Issue Links

            Activity

              People

                liach Chen Liang
                liach Chen Liang
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: