From: aclement Date: Fri, 13 Nov 2009 18:28:15 +0000 (+0000) Subject: superinterface cache X-Git-Tag: V1_6_7~81 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=abba8bcc903e8051635bde91e7ad29b531a6773c;p=aspectj.git superinterface cache --- diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java index 9bb4cb266..60a1a5449 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java @@ -110,6 +110,7 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate { // above! private WeakReference superTypeReference = new WeakReference(null); + private WeakReference superInterfaceReferences = new WeakReference(null); private int bitflag = 0x0000; @@ -134,7 +135,6 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate { * that's a bigger piece of work. XXX */ - // ------------------ construction and initialization BcelObjectType(ReferenceType resolvedTypeX, JavaClass javaClass, boolean exposedToWeaver) { super(resolvedTypeX, exposedToWeaver); this.javaClass = javaClass; @@ -169,6 +169,11 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate { initializeFromJavaclass(); } + @Override + public boolean isCacheable() { + return true; + } + private void initializeFromJavaclass() { isInterface = javaClass.isInterface(); isEnum = javaClass.isEnum(); @@ -240,29 +245,35 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate { * is used to work out the types - this gets around the results of erasure when the class was originally compiled. */ public ResolvedType[] getDeclaredInterfaces() { - ensureGenericSignatureUnpacked(); - ResolvedType[] interfaceTypes = null; - if (interfaceSignatures == null) { - String[] names = javaClass.getInterfaceNames(); - if (names.length == 0) { - interfaceSignatures = NO_INTERFACE_SIGS; - interfaceTypes = ResolvedType.NONE; + + ResolvedType[] cachedInterfaceTypes = superInterfaceReferences.get(); + if (cachedInterfaceTypes == null) { + ensureGenericSignatureUnpacked(); + ResolvedType[] interfaceTypes = null; + if (interfaceSignatures == null) { + String[] names = javaClass.getInterfaceNames(); + if (names.length == 0) { + interfaceSignatures = NO_INTERFACE_SIGS; + interfaceTypes = ResolvedType.NONE; + } else { + interfaceSignatures = new String[names.length]; + interfaceTypes = new ResolvedType[names.length]; + for (int i = 0, len = names.length; i < len; i++) { + interfaceTypes[i] = getResolvedTypeX().getWorld().resolve(UnresolvedType.forName(names[i])); + interfaceSignatures[i] = interfaceTypes[i].getSignature(); + } + } } else { - interfaceSignatures = new String[names.length]; - interfaceTypes = new ResolvedType[names.length]; - for (int i = 0, len = names.length; i < len; i++) { - interfaceTypes[i] = getResolvedTypeX().getWorld().resolve(UnresolvedType.forName(names[i])); - interfaceSignatures[i] = interfaceTypes[i].getSignature(); + interfaceTypes = new ResolvedType[interfaceSignatures.length]; + for (int i = 0, len = interfaceSignatures.length; i < len; i++) { + interfaceTypes[i] = getResolvedTypeX().getWorld().resolve(UnresolvedType.forSignature(interfaceSignatures[i])); } } + superInterfaceReferences = new WeakReference(interfaceTypes); + return interfaceTypes; } else { - interfaceTypes = new ResolvedType[interfaceSignatures.length]; - for (int i = 0, len = interfaceSignatures.length; i < len; i++) { - interfaceTypes[i] = getResolvedTypeX().getWorld().resolve(UnresolvedType.forSignature(interfaceSignatures[i])); - } + return cachedInterfaceTypes; } - - return interfaceTypes; } public ResolvedMember[] getDeclaredMethods() {