-
CSR
-
Resolution: Unresolved
-
P4
-
None
-
None
-
behavioral
-
low
-
Consumers of `Class.arrayType()` that expect an (unspecified) `IllegalArgumentExeption` to be thrown if the array rank exceeds 255 would break.
-
Java API
-
SE
Summary
Change the specification of java.lang.Class::arrayType()
and java.lang.invoke.TypeDescriptor.OfField::arrayType()
to throw an IllegalStateException
if the array rank would exceed 255.
Problem
Currently Class::arrayType()
throws an unspecified IllegalArgumentException
, which is not appropriate for methods that don't take an argument.
This should also be reflected in the documentation of TypeDescriptor.OfField::arrayType()
.
Solution
Change the specification of java.lang.Class::arrayType()
and java.lang.invoke.TypeDescriptor.OfField::arrayType()
to throw an IllegalStateException
if the array rank would exceed 255.
This matches the other implementation of java.lang.invoke.TypeDescriptor.OfField
: java.lang.constant.ClassDesc
.
The behavior of Class::arrayType()
changes, as it will now throw a different Exception in the error case.
Specification
java.lang.Class::arrayType()
:
/**
* Returns a {@code Class} for an array type whose component type
* is described by this {@linkplain Class}.
*
* @return a {@code Class} describing the array type
+ * @throws IllegalStateException if the resulting {@code Class} would have an array rank of greater than 255
* @since 12
*/
java.lang.invoke.TypeDescriptor.OfField::arrayType()
:
/**
* Return a descriptor for the array type whose component type is described by this
* descriptor
+ * @throws IllegalStateException if the resulting {@code TypeDescriptor.OfField} would have an array rank of greater than 255
* @return the descriptor for the array type
*/
- csr of
-
JDK-8262003 Class.arrayType should not throw IllegalArgumentException
-
- Closed
-