Hi Alan,

On 6/6/2021 11:01 PM, Alan Bateman wrote:
On Mon, 7 Jun 2021 00:22:41 GMT, Joe Darcy <[email protected]> wrote:

Make explicit illegal argument cases of Class.arrayType.

Please also review the corresponding CSR: 
https://bugs.openjdk.java.net/browse/JDK-8268300
Joe Darcy has updated the pull request incrementally with one additional commit 
since the last revision:

   Add missing ending newline.
src/java.base/share/classes/java/lang/Class.java line 4440:

4438:      * @throws IllegalArgumentException if this component type is 
{@linkplain
4439:      *         Void#TYPE void} or if the number of dimensions of the 
resulting array
4440:      *         type would exceed 255.
This is a no-arg method so I'm not sure that IAE is the right exception. The 
method was added in Java 12 so there probably isn't a huge body of code that 
expects it to throw IAE, meaning it may be possible to change it with little/no 
impact.

Pedantically, "this" is an argument of sorts, but admittedly that line of reasoning doesn't usually yield a very satisfying user-experience  for a method.

I wanted to avoid introducing any exception adaptation code to the one-line call to Array.newInstance.

A less direct way to address the lack of exception specification there would be "@implSpec Code equivalent to return Array.newInstance(this, 0).getClass();", which would pull in the throws clauses from that method.

I'll also note I only proposed changing the spec for Class.arrayType rather than the arrayType method in the superinterface or other implementations. The Class.arrayType method has the strongest ties to the particular 255 limit.

Thanks,

-Joe

Reply via email to