diff options
author | Elliott Hughes <enh@google.com> | 2013-08-16 23:28:02 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-08-16 23:28:02 +0000 |
commit | a4d8429f8b1062fee0b1ded9b653bd06f66f23ec (patch) | |
tree | 221220fa5245f6bae1c401841ab9d66802deffa3 /libdvm/src/main/java | |
parent | 3daf196c1be9ac55fc9ada3847c53fecf2bc51a2 (diff) | |
parent | 75a06e56a4cc4599946e21422513e4bafa759509 (diff) | |
download | libcore-a4d8429f8b1062fee0b1ded9b653bd06f66f23ec.zip libcore-a4d8429f8b1062fee0b1ded9b653bd06f66f23ec.tar.gz libcore-a4d8429f8b1062fee0b1ded9b653bd06f66f23ec.tar.bz2 |
Merge "Synced java.util.concurrent library up to 2013.07.01."
Diffstat (limited to 'libdvm/src/main/java')
-rw-r--r-- | libdvm/src/main/java/java/lang/Class.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/libdvm/src/main/java/java/lang/Class.java b/libdvm/src/main/java/java/lang/Class.java index 2f26688..c8064cb 100644 --- a/libdvm/src/main/java/java/lang/Class.java +++ b/libdvm/src/main/java/java/lang/Class.java @@ -54,13 +54,14 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.List; +import java.util.Map; import libcore.util.CollectionUtils; import libcore.util.EmptyArray; import org.apache.harmony.kernel.vm.StringUtils; import libcore.reflect.AnnotationAccess; import libcore.reflect.GenericSignatureParser; import libcore.reflect.Types; - +import libcore.util.BasicLruCache; /** * The in-memory representation of a Java class. This representation serves as * the starting point for querying class-related information, a process usually @@ -779,9 +780,17 @@ public final class Class<T> implements Serializable, AnnotatedElement, GenericDe * void} then an empty array is returned. */ public Type[] getGenericInterfaces() { - GenericSignatureParser parser = new GenericSignatureParser(getClassLoader()); - parser.parseForClass(this, getSignatureAttribute()); - return Types.getClonedTypeArray(parser.interfaceTypes); + Type[] result; + synchronized (Caches.genericInterfaces) { + result = Caches.genericInterfaces.get(this); + if (result == null) { + GenericSignatureParser parser = new GenericSignatureParser(getClassLoader()); + parser.parseForClass(this, getSignatureAttribute()); + result = Types.getClonedTypeArray(parser.interfaceTypes); + Caches.genericInterfaces.put(this, result); + } + } + return result; } /** @@ -1262,4 +1271,9 @@ public final class Class<T> implements Serializable, AnnotatedElement, GenericDe return AnnotationAccess.typeIndexToAnnotationDirectoryOffset(getDex(), getTypeIndex()); } + private static class Caches { + private static final BasicLruCache<Class, Type[]> genericInterfaces + = new BasicLruCache<Class, Type[]>(50); + } + } |