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

Improve specification of Array.newInstance

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • None
    • core-libs
    • None
    • behavioral
    • minimal
    • Difference specification of the same semantics.
    • Java API
    • SE

      Summary

      Change one overload of java.lang.reflect.Array.newInstance to have an @implSpec of calling the other method.

      Problem

      Pre-@implSpec use of the notion of @implSpec.

      Solution

      Use @implSpec.

      Specification

      diff --git a/src/java.base/share/classes/java/lang/reflect/Array.java b/src/java.base/share/classes/java/lang/reflect/Array.java
      index 16f5477af25..61dca04fca5 100644
      --- a/src/java.base/share/classes/java/lang/reflect/Array.java
      +++ b/src/java.base/share/classes/java/lang/reflect/Array.java
      @@ -49,13 +49,11 @@ class Array {
           /**
            * Creates a new array with the specified component type and
            * length.
      +     * @implSpec
            * Invoking this method is equivalent to creating an array
            * as follows:
            * <blockquote>
      -     * <pre>
      -     * int[] x = {length};
      -     * Array.newInstance(componentType, x);
      -     * </pre>
      +     * {@code Array.newInstance(componentType, new int[]{length});}
            * </blockquote>
            *
            * <p>The number of dimensions of the new array must not

            darcy Joe Darcy
            darcy Joe Darcy
            Brian Burkhalter, Mandy Chung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: