On Wed, 2 Mar 2022 20:28:45 GMT, Joe Darcy <da...@openjdk.org> wrote:

> Refactoring of Method and Constructor to share a single empty array for 
> parameters and exceptions as well as type variables.
> 
> Existing core reflection regression tests pass with the change.

This is also only a partial solution, since the initial array is created and 
injected by the VM on a "root" Constructor/Method, see for example the code for 
new method: 
https://github.com/openjdk/jdk/blob/5c187e34a58769a129a0aae9e4937907c9060202/src/hotspot/share/runtime/reflection.cpp#L778

Depending on usage pattern most of the Constructor/Method objects created are 
such root objects (often created in bulk), and only those exposed to user code 
via a copy will benefit from this particular enhancement. Which might be a good 
optimization when getting the same Constructor/Method from the same class over 
and over.

- Can we skip the `.clone()` when propagating these from a root object to one 
we'll expose? We have internal `getShared...` methods for that purpose.
- If we update the JVM code to inject a reference to `Class.EMPTY_CLASS_ARRAY` 
and we can skip the `.clone()`ing as per above we should see a decent benefit 
overall.

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

Changes requested by redestad (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/7667

Reply via email to