From: aclement Date: Tue, 17 Jun 2008 18:13:23 +0000 (+0000) Subject: 237419: testcode and fix: use erased signature of member and dont tag all types with... X-Git-Tag: V1_6_1rc1~39 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5e1f1922691c9932dd32e693379dddd1cb79c1c9;p=aspectj.git 237419: testcode and fix: use erased signature of member and dont tag all types with a type munger for atAspect --- diff --git a/weaver/src/org/aspectj/weaver/JoinPointSignature.java b/weaver/src/org/aspectj/weaver/JoinPointSignature.java index 15c6c05e1..6b0a368b6 100644 --- a/weaver/src/org/aspectj/weaver/JoinPointSignature.java +++ b/weaver/src/org/aspectj/weaver/JoinPointSignature.java @@ -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(); + } } diff --git a/weaver/src/org/aspectj/weaver/ResolvedMember.java b/weaver/src/org/aspectj/weaver/ResolvedMember.java index c61d3666e..d987dad01 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedMember.java +++ b/weaver/src/org/aspectj/weaver/ResolvedMember.java @@ -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); diff --git a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java index 473f11f66..995bc8817 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java +++ b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java @@ -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) { diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java index a4f49a7d6..a2be79c82 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -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); diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java b/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java index 6d8f6447b..9cae87b14 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java @@ -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) {