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

ObjectMethods::bootstrap throws NPE when lookup is null

XMLWordPrintable

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

      Summary

      The specification for method java.lang.runtime.ObjectMethods::bootstrap should be updated regarding the cases for which NPE is thrown.

      Problem

      NPE is thrown by method java.lang.runtime.ObjectMethods::bootstrap if argument lookup is null but the specification says otherwise

      Solution

      Update the method specification for method java.lang.runtime.ObjectMethods::bootstrap specifying that NPE is thrown if any argument is null

      Specification

      diff --git a/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java b/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java
      index 5d092328f75..133d75b1f7f 100644
      --- a/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java
      +++ b/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java
      @@ -396,15 +396,15 @@ private static MethodHandle makeToString(MethodHandles.Lookup lookup,
            *                     if invoked by a condy
            * @throws IllegalArgumentException if the bootstrap arguments are invalid
            *                                  or inconsistent
      -     * @throws NullPointerException if any argument but {@code lookup} is {@code null},
      -     *                              in the case of the {@code getters} argument, its
      -     *                              contents cannot be {@code null} either
      +     * @throws NullPointerException if any argument is {@code null} or if any element
      +     *                              in the {@code getters} array is {@code null}
            * @throws Throwable if any exception is thrown during call site construction
            */
           public static Object bootstrap(MethodHandles.Lookup lookup, String methodName, TypeDescriptor type,
                                          Class<?> recordClass,
                                          String names,
                                          MethodHandle... getters) throws Throwable {

            vromero Vicente Arturo Romero Zaldivar
            kganapureddy Krushnareddy Ganapureddy
            Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: