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

calling MethodHandles.lookup on itself leads to errors

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 18
    • 9
    • core-libs
    • None

      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.

            mchung Mandy Chung (Inactive)
            jrose John Rose
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: