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

calling MethodHandles.lookup on itself leads to errors

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
      None

      Description

      Use MHs.lookup to look itself up. The resulting MH is broken. See attached test case, or the following snippet:

       Lookup lookup = lookup();
       lookup.findStatic(lookup.lookupClass(), "say", methodType(void.class, String.class)).invokeExact("hello, world");
       MethodHandle MH_lookup2 = lookup.findStatic(MethodHandles.class, "lookup", methodType(Lookup.class));
       // Next line gets IAE: illegal lookupClass: class java.lang.invoke.MethodHandleImpl$BindCaller$T/471910020
       Lookup lookup2 = (Lookup) MH_lookup2.invokeExact();

      Suggested fix: Special-case the caller binding logic for lookup.

      Consider doing this for any other hyper-sensitive @CallerSensitive method which looks at more than its caller class loader.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mchung Mandy Chung
              Reporter:
              jrose John Rose
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: