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

Peter Levart peter.levart at gmail.com
Thu Aug 14 16:54:17 UTC 2014


On 08/14/2014 08:47 AM, Joel Borggren-Franck wrote:
> On 2014-08-13, Joe Darcy wrote:
>> Hi Joel,
>>
>> Does your changeset alter the support (or non-support) of redefining
>> an annotation?
>>
> Hi Joe,
>
> It does not interact with the current non-support and I am convinced it
> wont hinder us in improving the situation.
>
> cheers
> /Joel
Hi Joel,

Good to see this patch. It improves the efficiency of annotations 
caching on methods/constructors. What about fields? They too are 
AccessibleObject(s), contain annotations and are copied from root 
instances when handed over to the user...

The difference of behaviour in the presence of class redefinition could 
be observed though, but I think this is not a problem. For example:

Class c = ...;

Method m1 = c.getDeclaredMethod("m");
Method m2 = c.getDeclaredMethod("m");

assert m1 != m2; // but they share the same root;

Annotation[] anns1 = m1.getDeclaredAnnotations();

// now class 'c' is redefined and annotations changes on method m()...

Annotation[] anns2 = m2.getDeclaredAnnotations();

// previously anns1 / anns2 would countain annotations pre / post class 
redefinition, but with this patch, they would both contain the pre class 
redefinition annotations.


But as I see it this is not a big problem to hold the patch back.


Regards, Peter




More information about the core-libs-dev mailing list