JDK-8262003: Class.arrayType should not throw IllegalArgumentException

Johannes Kuhn info at j-kuhn.de
Tue Feb 23 14:38:49 UTC 2021


I want to learn about writing a CSR, and need a sponsor teaching me the 
ropes.

----

Bug: https://bugs.openjdk.java.net/browse/JDK-8262003

Currently, Class.arrayType() will throw an IllegalArgumentException if 
the maximum number of dimensions will be exceeded.

Throwing an IllegalArgumentException from a method that doesn't take an 
argument is, at least, strange.

Therefore I would like to update the specification to allow this method 
to throw an IllegalStateException, similar to what ClassDesc.arrayType() 
does.

----

The current plan is:

* Create a CSR detailing the spec changes: 
https://bugs.openjdk.java.net/browse/JDK-8262211
* Surround the code with a try-catch block. Checking for the error case 
is hard, and somewhat rare, so I think this is appropriate.
* Copy the @throws javadoc line from ClassDesc.arrayType to Class.arrayType

But there are a few questions I would love to get the answer on:

* Both Class.arrayType() and ClassDesc.arrayType() are specified by 
TypeDescriptor.OfField. Should the specification of 
TypeDescriptor.OfField.arrayType() changed as well?
* Is the draft of my CSR fine? Should I add some details, or omit 
things? Rephrase things?

In advance, thanks for any support and feedback on this.

- Johannes


More information about the core-libs-dev mailing list