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

Lookup argument for StringConcatFactory.makeConcat & makeConcatWithConstants cannot have privileges less than PRIVATE

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P2 P2
    • 10
    • core-libs
    • None
    • behavioral
    • minimal
    • Existing implicit behaviour is now explicitly specified
    • Java API
    • SE

      Summary

      Specify that the lookup context parameter passed to the bootstrap methods of LambdaMetaFactory and StringConcatFactory is required to have private access privileges.

      Specification

      diff -r 5bb3d34ffeb1 src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java
      --- a/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java   Mon Nov 27 15:47:27 2017 -0800
      +++ b/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java   Tue Nov 28 12:55:47 2017 -0800
      @@ -263,8 +263,12 @@
            * methods from {@code Object}.
            *
            * @param caller Represents a lookup context with the accessibility
      -     *               privileges of the caller.  When used with {@code invokedynamic},
      -     *               this is stacked automatically by the VM.
      +     *               privileges of the caller.  Specifically, the lookup context
      +     *               must have
      +     *               <a href="MethodHandles.Lookup.html#privacc">private access</a>
      +     *               privileges.
      +     *               When used with {@code invokedynamic}, this is stacked
      +     *               automatically by the VM.
            * @param invokedName The name of the method to implement.  When used with
            *                    {@code invokedynamic}, this is provided by the
            *                    {@code NameAndType} of the {@code InvokeDynamic}
      @@ -294,7 +298,8 @@
            *         instances of the interface named by {@code invokedType}
            * @throws LambdaConversionException If any of the linkage invariants
            *                                   described {@link LambdaMetafactory above}
      -     *                                   are violated
      +     *                                   are violated, or the lookup context
      +     *                                   does not have private access privileges.
            */
           public static CallSite metafactory(MethodHandles.Lookup caller,
                                              String invokedName,
      @@ -404,8 +409,12 @@
            * </ul>
            *
            * @param caller Represents a lookup context with the accessibility
      -     *               privileges of the caller.  When used with {@code invokedynamic},
      -     *               this is stacked automatically by the VM.
      +     *               privileges of the caller.  Specifically, the lookup context
      +     *               must have
      +     *               <a href="MethodHandles.Lookup.html#privacc">private access</a>
      +     *               privileges.
      +     *               When used with {@code invokedynamic}, this is stacked
      +     *               automatically by the VM.
            * @param invokedName The name of the method to implement.  When used with
            *                    {@code invokedynamic}, this is provided by the
            *                    {@code NameAndType} of the {@code InvokeDynamic}
      @@ -429,7 +438,8 @@
            *         instances of the interface named by {@code invokedType}
            * @throws LambdaConversionException If any of the linkage invariants
            *                                   described {@link LambdaMetafactory above}
      -     *                                   are violated
      +     *                                   are violated, or the lookup context
      +     *                                   does not have private access privileges.
            */
           public static CallSite altMetafactory(MethodHandles.Lookup caller,
                                                 String invokedName,
      diff -r 5bb3d34ffeb1 src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
      --- a/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java Mon Nov 27 15:47:27 2017 -0800
      +++ b/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java Tue Nov 28 12:55:47 2017 -0800
      @@ -404,8 +411,12 @@
            * </ul>
            *
            * @param lookup   Represents a lookup context with the accessibility
      -     *                 privileges of the caller.  When used with {@code
      -     *                 invokedynamic}, this is stacked automatically by the VM.
      +     *                 privileges of the caller. Specifically, the lookup
      +     *                 context must have
      +     *                 <a href="MethodHandles.Lookup.html#privacc">private access</a>
      +     *                 privileges.
      +     *                 When used with {@code invokedynamic}, this is stacked
      +     *                 automatically by the VM.
            * @param name     The name of the method to implement. This name is
            *                 arbitrary, and has no meaning for this linkage method.
            *                 When used with {@code invokedynamic}, this is provided by
      @@ -422,7 +433,8 @@
            * concatenation, with dynamic concatenation arguments described by the given
            * {@code concatType}.
            * @throws StringConcatException If any of the linkage invariants described
      -     *                               here are violated.
      +     *                               here are violated, or the lookup context
      +     *                               does not have private access privileges.
            * @throws NullPointerException If any of the incoming arguments is null.
            *                              This will never happen when a bootstrap method
            *                              is called with invokedynamic.
      @@ -502,9 +521,12 @@
            * </ul>
            *
            * @param lookup    Represents a lookup context with the accessibility
      -     *                  privileges of the caller. When used with {@code
      -     *                  invokedynamic}, this is stacked automatically by the
      -     *                  VM.
      +     *                  privileges of the caller. Specifically, the lookup
      +     *                  context must have
      +     *                  <a href="MethodHandles.Lookup.html#privacc">private access</a>
      +     *                  privileges.
      +     *                  When used with {@code invokedynamic}, this is stacked
      +     *                  automatically by the VM.
            * @param name      The name of the method to implement. This name is
            *                  arbitrary, and has no meaning for this linkage method.
            *                  When used with {@code invokedynamic}, this is provided
      @@ -524,7 +546,8 @@
            * concatenation, with dynamic concatenation arguments described by the given
            * {@code concatType}.
            * @throws StringConcatException If any of the linkage invariants described
      -     *                               here are violated.
      +     *                               here are violated, or the lookup context
      +     *                               does not have private access privileges.
            * @throws NullPointerException If any of the incoming arguments is null, or
            *                              any constant in {@code recipe} is null.
            *                              This will never happen when a bootstrap method

            psandoz Paul Sandoz
            pgundarlahal Prashanthram Gundarlahally
            Mandy Chung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: