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

Passing 'null' value to lookup param of ConstantBootstraps.invoke does not throw NullPointerException

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P2
    • Resolution: Approved
    • Fix Version/s: 11
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      The specification of j.l.invoke.ConstantBootstraps.invoke should declare that the lookup parameter is unused, and therefore no NullPointerException will occur if called explicitly with such a null lookup argument.

      Specification

      diff -r b75c9e2e3b1f src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java
      --- a/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java  Tue Feb 20 21:47:54 2018 +0100
      +++ b/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java  Tue Feb 20 14:38:56 2018 -0800
      @@ -209,8 +209,7 @@
            * Returns the result of invoking a method handle with the provided
            * arguments.
            *
      -     * @param lookup the lookup context describing the class performing the
      -     * operation (normally stacked by the JVM)
      +     * @param lookup unused
            * @param name unused
            * @param type the type of the value to be returned, which must be
            * compatible with the return type of the method handle
      
      
      /**
       * Returns the result of invoking a method handle with the provided
       * arguments.
       *
       * @param lookup unused
       * @param name unused
       * @param type the type of the value to be returned, which must be
       * compatible with the return type of the method handle
       * @param handle the method handle to be invoked
       * @param args the arguments to pass to the method handle, as if with
       * {@link MethodHandle#invokeWithArguments}.  Each argument may be
       * {@code null}.
       * @return the result of invoking the method handle
       * @throws WrongMethodTypeException if the handle's return type cannot be
       * adjusted to the desired type
       * @throws ClassCastException if an argument cannot be converted by
       * reference casting
       * @throws Throwable anything thrown by the method handle invocation
       */
      public static Object invoke(MethodHandles.Lookup lookup, String name, Class<?> type,
                                  MethodHandle handle, Object... args) throws Throwable {

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psandoz Paul Sandoz (Inactive)
                Reporter:
                pgundarlahal Prashanthram Gundarlahally
                Reviewed By:
                Mandy Chung
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: