RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v2]

Chen Liang liach at openjdk.org
Fri May 31 16:21:36 UTC 2024


On Fri, 31 May 2024 16:18:01 GMT, jengebr <duke at openjdk.org> wrote:

>> Improve `java/lang/reflect/Method.java`  by eliminating needless cloning of Class[0] instances.  This cloning is intended to prevent callers from changing array contents, but smany Methods have zero exceptions or zero parameters, and returning the original `Class[0]` is sufficient.
>
> jengebr has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Adding JMH benchmark

test/micro/org/openjdk/bench/java/lang/reflect/ExecutableParameterAndExceptionTypesBenchmark.java line 69:

> 67: 
> 68:     @Benchmark
> 69:     public void constructorParametersWithNoExceptions(Blackhole bh) throws Exception {

Wrong name. Maybe rename this to `constructorParametersEmpty` and the exception ones to `constructorExceptionsEmpty`?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19327#discussion_r1622668928


More information about the core-libs-dev mailing list