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

ObjectMethods::bootstrap throws NPE when lookup is null

    XMLWordPrintable

    Details

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

      Description

      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 {

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: