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

Chen Liang liach at openjdk.org
Thu May 30 19:30:12 UTC 2024


On Tue, 21 May 2024 13:49:18 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.

I think we should probably create a utility method dedicated to clone only mutable Class arrays. This utility can be used for the other methods in other reflection classes.

Can you update the ending copyright years from 2023 to 2024 on the 2nd line of the 2 modified files?

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

PR Comment: https://git.openjdk.org/jdk/pull/19327#issuecomment-2122710633
PR Comment: https://git.openjdk.org/jdk/pull/19327#issuecomment-2130420945


More information about the core-libs-dev mailing list