RFR: JDK-8054987: (reflect) Add sharing of annotations between instances of Executable

Joel Borggren-Franck joel.franck at oracle.com
Wed Aug 13 12:23:06 UTC 2014

Hi all,

Cleaning out the patch queue, I found this small patch that adds sharing
of conceptually immutable annotation maps between instances of
Executable representing the same executable.

In short, Method/Constructor contain one bit of mutable state, if they
have been set accessible or not. Core Reflection keeps a 'root' instance
of an executable and copies it whenever you call
get(Declared){Method|Constructor}. When using an Executable to look at annotations each copy
you query for annotations, for exampel m1.getAnnotations(), gets its own
LinkedHashMap containing the annotations. The map is then flattned and
handed out to the client as a newly allocated array. This patch queries
the root method for its map thus sharing annotation instances. It still
hands out a unique array for each invocation but the Map and the
instances are shared.

Webrev: http://cr.openjdk.java.net/~jfranck/8054987/webrev.00/
Bug: https://bugs.openjdk.java.net/browse/JDK-8054987


More information about the core-libs-dev mailing list