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

ObjectMethods::bootstrap should specify NPE if any argument except lookup is null

    XMLWordPrintable

    Details

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

      Description

      Summary

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

      Problem

      NPE is thrown by method java.lang.runtime.ObjectMethods::bootstrap but its specification doesn't mention it.

      Solution

      Update the method specification for method java.lang.runtime.ObjectMethods::bootstrap covering the cases for which NPE is thrown

      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
      --- a/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java
      +++ b/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java
      @@ -317,19 +319,28 @@ private static MethodHandle makeToString(Class<?> receiverClass,
            * @param recordClass  the record class hosting the record components
            * @param names        the list of component names, joined into a string
            *                     separated by ";", or the empty string if there are no
      -     *                     components. Maybe be null, if the {@code methodName}
      -     *                     is {@code "equals"} or {@code "hashCode"}.
      +     *                     components. This parameter is ignored if the {@code methodName}
      +     *                     parameter is {@code "equals"} or {@code "hashCode"}
            * @param getters      method handles for the accessor methods for the components
            * @return             a call site if invoked by indy, or a method handle
            *                     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 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:
              mchung Mandy Chung
              Reviewed By:
              Chris Hegarty, Mandy Chung
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: