RFR: 8357178: Simplify Class::componentType

Joe Darcy darcy at openjdk.org
Sun May 18 18:20:51 UTC 2025


On Sat, 17 May 2025 02:15:42 GMT, Chen Liang <liach at openjdk.org> wrote:

> `isArray` and null return is now redundant when `componentType` is changed to an explicit field.

src/java.base/share/classes/java/lang/Class.java line 3985:

> 3983:     @Override
> 3984:     public Class<?> componentType() {
> 3985:         return componentType;

Did you consider calling getComponentType(), which already returns the field?

Are there regression tests for Class::componentType()/Class::getComponentType() somewhere? I didn't see them in the obvious test/jdk/java/lang/Class directory.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25280#discussion_r2094593495


More information about the core-libs-dev mailing list