Release Note: ObjectMethods.bootstrap May Throw Exceptions for Underprivileged Lookup Argument

XMLWordPrintable

      The specification of [java.lang.runtime.ObjectMethods.bootstrap][ObjectMethods.bootstrap] method incorrectly claims its `MethodHandles.Lookup` argument is unused; it may cause an exception if the `lookup` does not have full privilege access.

      Since JDK 18, it consistently throws a `RuntimeException` caused by `StringConcatException` if the `lookup` does not have full privilege access. The `methodName` is `"toString"`, and all other arguments are valid. Beginning in JDK 26, it may throw an `IllegalAccessException` or return normally if the `lookup` does not have full privilege access, the `methodName` is `"hashCode"` or `"equals"`, and all other arguments are valid.

      The overwhelming majority of uses of `ObjectMethods.bootstrap` are through bootstrap methods. These provide a full-privilege lookup and are therefore not affected. This inconsistent behavior will be addressed by JDK-8378796 in JDK 27.

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

              Created:
              Updated: