JDK 8 RFR for JDK-7185456 : (ann) Optimize Annotation handling in java/sun.reflect.* code for small number of annotationsC

Peter Levart peter.levart at gmail.com
Wed Mar 27 14:00:05 UTC 2013


On 03/27/2013 02:00 PM, Joel Borggrén-Franck wrote:
> Hi Peter,
>
> On 03/27/2013 01:31 PM, Peter Levart wrote:
>
>> I also don't know
>> whether having LinkedHashMap instead of plain HashMap is necessary, 
>> since it
>> is initialized with defaults from plain HashMap (which is hashCode %
>> capacity ordered) and only some of defaults are overridden in parsing 
>> loop
>> in general. For example, having this annotation:
>>
>> @interface Ann {
>>      String one();
>>      String two() default "2";
>> }
>>
>> and usage:
>>
>> @Ann(one = "1")
>>
>> ...toString will print: @Ann(two = "2", one = "1")
>>
>
> While there perhaps is no natural ordering between the sets of default 
> elements and non-default elements you probably want an order following 
> source as closely as possible among the non-default elements.

What is the order of elements in java class file (the bytes that the 
parser interprets)? Is it taken from the declaration of annotation (the 
order of methods in annotation interface) or from the use-site of the 
annotation? Is this specified?

Regards, Peter

>
> cheers
> /Joel




More information about the core-libs-dev mailing list