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

Clarify special case handling of Types.getArrayType

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 24
    • core-libs
    • None
    • behavioral
    • low
    • Hide
      Changing behavior in some corner cases, in particular a NONE type and the NULL type. Per JLS 10.1
      "An array type is written as the name of an element type followed by some number of empty pairs of square brackets []"
      Therefore, since the null type is not denotable, in other words from JLS 4.1
      "Because the null type has no name, it is impossible to declare a variable of the null type or to cast to the null type. "
      it is not possible to declared an array of null type.
      Show
      Changing behavior in some corner cases, in particular a NONE type and the NULL type. Per JLS 10.1 "An array type is written as the name of an element type followed by some number of empty pairs of square brackets []" Therefore, since the null type is not denotable, in other words from JLS 4.1 "Because the null type has no name, it is impossible to declare a variable of the null type or to cast to the null type. " it is not possible to declared an array of null type.
    • Java API
    • SE

      Summary

      Specify more explicitly the inputs to Types.getArrayType which cause an IllegalArgumentException to be thrown.

      Problem

      The full extent of the set of input which cause IllegalArgumentException is unclear.

      Solution

      Augment the @throws clause to contain more information.

      Specification

      diff --git a/src/java.compiler/share/classes/javax/lang/model/util/Types.java b/src/java.compiler/share/classes/javax/lang/model/util/Types.java
      index ce83cda405862..bee52a5614c4a 100644
      --- a/src/java.compiler/share/classes/javax/lang/model/util/Types.java
      +++ b/src/java.compiler/share/classes/javax/lang/model/util/Types.java
      @@ -263,7 +263,9 @@ public interface Types {
            *
            * @param componentType  the component type
            * @throws IllegalArgumentException if the component type is not valid for
      -     *          an array, including executable, package, module, and wildcard types
      +     *          an array. All valid types are {@linkplain ReferenceType
      +     *          reference types} or {@linkplain PrimitiveType primitive types}.
      +     *          Invalid types include null, executable, package, module, and wildcard types.
            * @jls 10.1 Array Types
            */
           ArrayType getArrayType(TypeMirror componentType);

            darcy Joe Darcy
            darcy Joe Darcy
            Chen Liang, Pavel Rappo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: