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

Consider Lookup::ensureInitialized(Class target, MethodHandle mh)

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • None

      See https://mail.openjdk.java.net/pipermail/core-libs-dev/2020-June/066991.html and
      https://mail.openjdk.java.net/pipermail/core-libs-dev/2020-June/066994.html

      /**
       * To the given method handle, prepend an action, if necessary, to trigger
       * initialization of the given class the first time the method handle is called.
       * If it would be illegal to call ensureInitialized on the given class from this lookup,
       * immediately report an error. Otherwise, if the class is already fully initialized
       * return the method handle unchanged. Otherwise, return a new method handle
       * (of the same type) which incorporates the necessary initialization action,
       * as if by a call to ensureInitialized.
       */
      MethodHandle ensureInitialized(Class target, MethodHandle mh) {
        checkAccess(target);
        if (isFullyInitialized(target)) return mh;
        // we need to tack a “before action” onto mh to trigger inits:
       MethodHandle before = MH_ensureInit.bindTo(target);
       return collectArguments(mh, 0, before);
      }

            Unassigned Unassigned
            mchung Mandy Chung (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: