AnnotationParser optimization - JEP-149
Peter Levart
peter.levart at gmail.com
Tue Nov 27 07:52:50 UTC 2012
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
More information about the core-libs-dev
mailing list