ObjectMethods.bootstrap may throw IllegalAccessException for underprivileged Lookup

XMLWordPrintable

    • Type: CSR
    • Resolution: Unresolved
    • Priority: P4
    • 26
    • Component/s: core-libs
    • None
    • behavioral
    • low
    • Hide
      Low risk, most of the Lookup instances are stacked by the JVM from an invokedynamic instruction in record classes; such instances already have full-privilege access.

      The behavioral change has been unnoticed since the patch, so there's likely tiny impact.
      Show
      Low risk, most of the Lookup instances are stacked by the JVM from an invokedynamic instruction in record classes; such instances already have full-privilege access. The behavioral change has been unnoticed since the patch, so there's likely tiny impact.
    • Java API
    • Implementation

      Summary

      After JDK-8366424, a call to ObjectMethods.bootstrap may throw IllegalAccessException in some cases when the argument lookup does not have full privilege access.

      Problem

      ObjectMethods.bootstrap claims it ignores the lookup argument.

      However, the reference implementation of bootstrap may need the lookup to construct hidden classes to address performance issues with the returned Method Handles or Call Sites.

      Solution

      If the lookup is used to construct hidden classes, bootstrap requires full privilege access for the lookup and throws an IllegalAccessException otherwise.

      The lookup is not guaranteed to be used by bootstrap. In that case, no exception is thrown.

      Specification

      No change.

      Note that bootstrap has param clause as follows:

           * @param lookup       Every bootstrap method is expected to have a {@code lookup}
           *                     which usually represents a lookup context with the
           *                     accessibility privileges of the caller. This is because
           *                     {@code invokedynamic} call sites always provide a {@code lookup}
           *                     to the corresponding bootstrap method, but this method just
           *                     ignores the {@code lookup} parameter
      

      which is violated by this behavioral change.

      However, the throws clause may be more permissive:

      @throws Throwable if any exception is thrown during call site construction
      

      Currently this inconsistency is planned to be addressed in release 27.

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

              Created:
              Updated: