On Fri, 31 May 2024 16:21:36 GMT, jengebr <d...@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
Let's bikeshed about the benchmark a little :) test/micro/org/openjdk/bench/java/lang/reflect/ExecutableParameterAndExceptionTypesBenchmark.java line 49: > 47: @Warmup(iterations = 3, time = 2, timeUnit = TimeUnit.SECONDS) > 48: @Measurement(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS) > 49: public class ExecutableParameterAndExceptionTypesBenchmark { I think we want to have two benchmark classes, like we already have `Clazz` as sibling. Something like: MethodBenchmark.getExceptionTypes MethodBenchmark.getExceptionTypesEmpty MethodBenchmark.getParameterTypes MethodBenchmark.getParameterTypesEmtpy ConstructorBenchmark.getExceptionTypes ConstructorBenchmark.getExceptionTypesEmpty ConstructorBenchmark.getParameterTypes ConstructorBenchmark.getParameterTypesEmtpy test/micro/org/openjdk/bench/java/lang/reflect/ExecutableParameterAndExceptionTypesBenchmark.java line 66: > 64: public void constructorExceptionsWithNoExceptions(Blackhole bh) > throws Exception { > 65: bh.consume(objectConstructor.getExceptionTypes()); > 66: } Here and later, the common shape for these is: @Benchmark public Object[] constructorExceptionsWithNoExceptions() { return objectConstructor.getExceptionTypes(); } ------------- PR Review: https://git.openjdk.org/jdk/pull/19327#pullrequestreview-2091270415 PR Review Comment: https://git.openjdk.org/jdk/pull/19327#discussion_r1622686626 PR Review Comment: https://git.openjdk.org/jdk/pull/19327#discussion_r1622682560