Hi all,

This might not be much of an improvement, but it is very easy to do:

--- a/src/share/classes/sun/reflect/annotation/AnnotationParser.java Thu Nov 15 15:40:03 2012 -0800 +++ b/src/share/classes/sun/reflect/annotation/AnnotationParser.java Tue Nov 27 08:39:58 2012 +0100
@@ -227,7 +227,7 @@

         Map<String, Class<?>> memberTypes = type.memberTypes();
         Map<String, Object> memberValues =
-            new LinkedHashMap<String, Object>(type.memberDefaults());
+            new HashMap<String, Object>(type.memberDefaults());

         int numMembers = buf.getShort() & 0xFFFF;
         for (int i = 0; i < numMembers; i++) {


It saves 1 OOP and 1 boolean for each Annotation instance + 2 OOPs for each Annotation member value.

It changes the serialization format of Annotation instances, but in a way that is backwards and forwards compatible.

Semantically it does not present any difference, since the only place that the Map is used is to Map.get(member) in the AnnotationInvocationHandler - it is never iterated.


Regards, Peter

Reply via email to