]> source.dussan.org Git - aspectj.git/commitdiff
237419: testcode and fix: use erased signature of member and dont tag all types with...
authoraclement <aclement>
Tue, 17 Jun 2008 18:13:23 +0000 (18:13 +0000)
committeraclement <aclement>
Tue, 17 Jun 2008 18:13:23 +0000 (18:13 +0000)
weaver/src/org/aspectj/weaver/JoinPointSignature.java
weaver/src/org/aspectj/weaver/ResolvedMember.java
weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java

index 15c6c05e1c00bff4a1536649cf42076e897e8f47..6b0a368b667f04a252351f289947d0e11cad627d 100644 (file)
@@ -391,4 +391,12 @@ public class JoinPointSignature implements ResolvedMember {
        public String getAnnotationDefaultValue() {
                return realMember.getAnnotationDefaultValue();
        }
+
+       public String getParameterSignatureErased() {
+               return realMember.getParameterSignatureErased();
+       }
+
+       public String getSignatureErased() {
+               return realMember.getSignatureErased();
+       }
 }
index c61d3666e5231a43aeaffb2c13f3204e9d364a81..d987dad01c9bdd275f156c428a82caa12097f90f 100644 (file)
@@ -66,6 +66,8 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe
        public AnnotationX[][] getParameterAnnotations();
        public ResolvedType[][] getParameterAnnotationTypes();
        public String getAnnotationDefaultValue();
+       public String getParameterSignatureErased();
+       public String getSignatureErased();
        
        public String[] getParameterNames(World world);
 
index 473f11f6667c51bcfc6a8da52ef2619cb3985c8e..995bc8817511db50e92c48cbe2d37b46451a6aee 100644 (file)
@@ -885,8 +885,8 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                        return true;
                } else {
                        // try erasure
-                       myParameterSignature = getParameterSigErasure();
-                       candidateParameterSignature = candidateMatchImpl.getParameterSigErasure();
+                       myParameterSignature = getParameterSignatureErased();
+                       candidateParameterSignature = candidateMatchImpl.getParameterSignatureErased();
                        return myParameterSignature.equals(candidateParameterSignature);
                }
        }
@@ -913,7 +913,11 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                return myParameterSignatureWithBoundsRemoved;
        }
        
-       private String getParameterSigErasure() {
+       /**
+        * Return the erased form of the signature with bounds collapsed for type variables, etc.
+     * Does not include the return type, @see getParam
+        */
+       public String getParameterSignatureErased() {
                if (myParameterSignatureErasure != null) return myParameterSignatureErasure;
                StringBuffer sig = new StringBuffer();
                UnresolvedType[] myParameterTypes = getParameterTypes();
@@ -923,13 +927,22 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
                 TypeVariableReferenceType typeVariableRT = (TypeVariableReferenceType) thisParameter;
                 sig.append(typeVariableRT.getUpperBound().getSignature());
                        } else {
-                               sig.append(thisParameter.getSignature());
+                               sig.append(thisParameter.getErasureSignature()); 
                        }
                }
                myParameterSignatureErasure = sig.toString();
                return myParameterSignatureErasure;             
        }
        
+       public String getSignatureErased() {
+               StringBuffer sb = new StringBuffer();
+               sb.append("(");
+               sb.append(getParameterSignatureErased());
+               sb.append(")");
+               sb.append(getReturnType().getErasureSignature());
+               return sb.toString();
+       }
+       
        // does NOT produce a meaningful java signature, but does give a unique string suitable for
        // comparison.
        public static void appendSigWithTypeVarBoundsRemoved(UnresolvedType aType, StringBuffer toBuffer, Set alreadyUsedTypeVars) {
index a4f49a7d6716cbda24e66432fcb5f8cfa518b156..a2be79c82232db816608c9d17859f46ed898a1b0 100644 (file)
@@ -714,9 +714,9 @@ class BcelClassWeaver implements IClassWeaver {
                        UnresolvedType[] bm = BcelWorld.fromBcel(bridgeToCandidate.getArgumentTypes());
                        ResolvedMember overriddenMethod = checkForOverride(theSuperclass,name,psig,rsig,bridgeToCandidate.getAccessFlags(),pkgName,bm);
                        if (overriddenMethod!=null) { 
-                               String key = new StringBuffer().append(overriddenMethod.getName()).append(overriddenMethod.getSignature()).toString();
+                               String key = new StringBuffer().append(overriddenMethod.getName()).append(overriddenMethod.getSignatureErased()).toString(); // pr 237419
                                boolean alreadyHaveABridgeMethod = methodsSet.contains(key);
-                               if (!alreadyHaveABridgeMethod) {
+                               if (!alreadyHaveABridgeMethod) { 
                                        if (world.forDEBUG_bridgingCode) System.err.println("Bridging:bridging to '"+overriddenMethod+"'");
                                        createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
                                        methodsSet.add(key);
@@ -732,7 +732,7 @@ class BcelClassWeaver implements IClassWeaver {
                                ResolvedType interfaceType = world.resolve(interfaces[j]);
                                overriddenMethod = checkForOverride(interfaceType,name,psig,rsig,bridgeToCandidate.getAccessFlags(),clazz.getPackageName(),bm);
                                if (overriddenMethod!=null) { 
-                                       String key = new StringBuffer().append(overriddenMethod.getName()).append(overriddenMethod.getSignature()).toString();
+                                       String key = new StringBuffer().append(overriddenMethod.getName()).append(overriddenMethod.getSignatureErased()).toString(); // pr 237419
                                        boolean alreadyHaveABridgeMethod = methodsSet.contains(key);
                                        if (!alreadyHaveABridgeMethod) {
                                                createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
index 6d8f6447b907dc6a0f7543ef22c73733f7a7bcd0..9cae87b14759f8e7e7541e991099042873717183 100644 (file)
@@ -137,10 +137,12 @@ public class BcelPerClauseAspectAdder extends BcelTypeMunger {
     }
 
     public boolean matches(ResolvedType onType) {
-        //we cannot return onType.equals(aspectType)
-        //since we need to eagerly create the nested ajcMighHaveAspect interface on LTW
-        return true;
-        //return aspectType.equals(onType);
+       // cannot always do the right thing because may need to eagerly generate ajcMightHaveAspect interface for LTW (says Alex)
+       if (hasGeneratedInner) { // pr237419 - not always going to generate the marker interface
+               return aspectType.equals(onType);
+       } else {
+               return true;
+       }
     }
 
     private boolean hasPerClauseMembersAlready(LazyClassGen classGen) {