JDK-8341511 : Clarify special case handling of Types.getArrayType
  • Type: CSR
  • Component: core-libs
  • Sub-Component: javax.lang.model
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 24
  • Submitted: 2024-10-04
  • Updated: 2024-10-04
  • Resolved: 2024-10-04
Related Reports
CSR :  
Description
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);
Comments
Moving to Approved.
04-10-2024