Summary
Add explicit discussion of exceptional conditions to Class.arrayType
.
Problem
The Class.arrayType
method does not state how it handles exceptional conditions, such as exceeding the maximum supported array dimensions.
Solution
Add the needed @throws
tag. The previous implementation threw llegalArgumentException
, propagated from elsewhere; this change instead threads UnsupportedOperationException
since the state of this
isn't usually the basis for an llegalArgumentException
.
Specification
diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java
index b8bf7de250e..137756c9176 100644
--- a/src/java.base/share/classes/java/lang/Class.java
+++ b/src/java.base/share/classes/java/lang/Class.java
@@ -4435,7 +4435,12 @@ public final class Class<T> implements java.io.Serializable,
* Returns a {@code Class} for an array type whose component type
* is described by this {@linkplain Class}.
*
+ * @throws UnsupportedOperationException if this component type is {@linkplain
+ * Void#TYPE void} or if the number of dimensions of the resulting array
+ * type would exceed 255.
* @return a {@code Class} describing the array type
+ * @jvms 4.3.2 Field Descriptors
+ * @jvms 4.4.1 The {@code CONSTANT_Class_info} Structure
* @since 12
*/
- csr of
-
JDK-8268250 Class.arrayType() for a 255-d array throws undocumented IllegalArgumentException
-
- Resolved
-