IndirectVarHandle.isAccessModeSupported throws NPE

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 22
    • Affects Version/s: 20, 21
    • Component/s: core-libs

        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
        ```

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

                Created:
                Updated:
                Resolved: