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

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

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P2 P2
    • 11
    • core-libs
    • None
    • behavioral
    • minimal
    • Java API
    • SE

      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 {

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

              Created:
              Updated:
              Resolved: