]> source.dussan.org Git - aspectj.git/commitdiff
answer correct superclass and superinterfaces taking into account generic signature
authoracolyer <acolyer>
Mon, 11 Jul 2005 09:36:49 +0000 (09:36 +0000)
committeracolyer <acolyer>
Mon, 11 Jul 2005 09:36:49 +0000 (09:36 +0000)
weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java

index f201b66bdfe57e6167b993984a101ed07a5d4697..6acb4bd9b25f16da1f2b13e5a18f1b88eea0a526 100644 (file)
@@ -154,15 +154,23 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate {
         return javaClass.getAccessFlags();
     }
 
+    /**
+     * Must take into account generic signature
+     */
     public ResolvedTypeX getSuperclass() {
         if (isObject) return null;
+       unpackGenericSignature();
         if (superClass == null) {
             superClass = getResolvedTypeX().getWorld().resolve(TypeX.forName(javaClass.getSuperclassName()));
         }
         return superClass;
     }
         
+    /** 
+     * Must take into account generic signature
+     */
     public ResolvedTypeX[] getDeclaredInterfaces() {
+       unpackGenericSignature();
         if (interfaces == null) {
             String[] ifaceNames = javaClass.getInterfaceNames();
             interfaces = new ResolvedTypeX[ifaceNames.length];
@@ -497,6 +505,27 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate {
        Signature.ClassSignature getGenericClassTypeSignature() {
                return javaClass.getGenericClassTypeSignature();
        }
+       
+       private boolean genericSignatureUnpacked = false;
+       private void unpackGenericSignature() {
+               if (genericSignatureUnpacked) return;
+               genericSignatureUnpacked = true;
+               Signature.ClassSignature cSig = getGenericClassTypeSignature();
+               if (cSig != null) {
+                       Signature.ClassTypeSignature superSig = cSig.superclassSignature;
+                       this.superClass = 
+                               BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
+                                               superSig, cSig.formalTypeParameters, getResolvedTypeX().getWorld());
+                       this.interfaces = new ResolvedTypeX[cSig.superInterfaceSignatures.length];
+                       for (int i = 0; i < cSig.superInterfaceSignatures.length; i++) {
+                               this.interfaces[i] = 
+                                       BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
+                                                       cSig.superInterfaceSignatures[i],
+                                                       cSig.formalTypeParameters, 
+                                                       getResolvedTypeX().getWorld());
+                       }
+               }
+       }
 }