aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajde/testdata/DuplicateManifestTest/aspectjar.jarbin2730 -> 2730 bytes
-rw-r--r--ajde/testdata/DuplicateManifestTest/injar.jarbin702 -> 702 bytes
-rw-r--r--ajde/testdata/WeaveInfoMessagesTest/AspectAdvice.jarbin2448 -> 2448 bytes
-rw-r--r--ajde/testdata/WeaveInfoMessagesTest/AspectAdvice_nodebug.jarbin2448 -> 2448 bytes
-rw-r--r--ajde/testdata/WeaveInfoMessagesTest/AspectDeclare.jarbin1875 -> 1875 bytes
-rw-r--r--ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft.jarbin1547 -> 1547 bytes
-rw-r--r--ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft_nodebug.jarbin1547 -> 1547 bytes
-rw-r--r--ajde/testdata/WeaveInfoMessagesTest/AspectDeclare_nodebug.jarbin1875 -> 1875 bytes
-rw-r--r--ajde/testdata/WeaveInfoMessagesTest/AspectITD.jarbin1864 -> 1879 bytes
-rw-r--r--ajde/testdata/WeaveInfoMessagesTest/AspectITD_nodebug.jarbin1864 -> 1879 bytes
-rw-r--r--ajde/testdata/WeaveInfoMessagesTest/Simple.jarbin698 -> 698 bytes
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java10
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java13
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java159
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java4
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMethodBinding.java14
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java20
-rw-r--r--org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jarbin1367 -> 1367 bytes
-rw-r--r--org.aspectj.ajdt.core/testdata/OutjarTest/child.jarbin724 -> 724 bytes
-rw-r--r--org.aspectj.ajdt.core/testdata/OutjarTest/parent.jarbin630 -> 630 bytes
-rw-r--r--tests/bugs/StringToString/helloworld.jarbin1074 -> 1074 bytes
-rw-r--r--tests/bugs/cflowAndJar/lib.jarbin984 -> 984 bytes
-rw-r--r--tests/bugs/perCflowAndJar/lib.jarbin1183 -> 1183 bytes
-rw-r--r--tests/bugs/serialVersionUID/injar.jarbin2399 -> 2399 bytes
-rw-r--r--tests/java5/generics/itds/design/DesignC.java7
-rw-r--r--tests/java5/generics/itds/design/DesignD.java13
-rw-r--r--tests/new/options11/aspectlib1.jarbin1608 -> 1608 bytes
-rw-r--r--tests/new/options11/aspectlib2.jarbin1266 -> 1266 bytes
-rw-r--r--tests/new/options11/injar.jarbin599 -> 599 bytes
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java58
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ajc150.xml15
-rw-r--r--weaver/src/org/aspectj/weaver/AjcMemberMaker.java16
-rw-r--r--weaver/src/org/aspectj/weaver/JoinPointSignature.java4
-rw-r--r--weaver/src/org/aspectj/weaver/MemberImpl.java2
-rw-r--r--weaver/src/org/aspectj/weaver/NewMethodTypeMunger.java18
-rw-r--r--weaver/src/org/aspectj/weaver/ReferenceType.java2
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedMember.java2
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java130
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java34
-rw-r--r--weaver/src/org/aspectj/weaver/TypeVariable.java30
-rw-r--r--weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java13
-rw-r--r--weaver/src/org/aspectj/weaver/UnresolvedType.java4
-rw-r--r--weaver/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java23
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java2
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXConverter.java6
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java55
-rw-r--r--weaver/testdata/dummyAspect.jarbin870 -> 870 bytes
-rw-r--r--weaver/testdata/ltw-acaspects.jarbin2519 -> 2519 bytes
-rw-r--r--weaver/testdata/ltw-aspects.jarbin1535 -> 1535 bytes
-rw-r--r--weaver/testdata/ltw-classes.jarbin1494 -> 1494 bytes
-rw-r--r--weaver/testdata/ltw-deaspects.jarbin1195 -> 1195 bytes
-rw-r--r--weaver/testdata/ltw-dwaspects.jarbin1200 -> 1200 bytes
-rw-r--r--weaver/testdata/ltw-itdaspects.jarbin5648 -> 5682 bytes
-rw-r--r--weaver/testdata/ltw-peraspects.jarbin1876 -> 1876 bytes
-rw-r--r--weaver/testdata/ltw-woven.jarbin2732 -> 2732 bytes
-rw-r--r--weaver/testdata/megatrace.jarbin5515 -> 5528 bytes
-rw-r--r--weaver/testdata/megatrace0easy.jarbin3903 -> 3916 bytes
-rw-r--r--weaver/testdata/megatrace0hard.jarbin3732 -> 3742 bytes
-rw-r--r--weaver/testdata/megatraceNoweave.jarbin3308 -> 3315 bytes
-rw-r--r--weaver/testdata/tracing.jarbin2766 -> 2766 bytes
61 files changed, 515 insertions, 141 deletions
diff --git a/ajde/testdata/DuplicateManifestTest/aspectjar.jar b/ajde/testdata/DuplicateManifestTest/aspectjar.jar
index 1d1a17999..1526d199c 100644
--- a/ajde/testdata/DuplicateManifestTest/aspectjar.jar
+++ b/ajde/testdata/DuplicateManifestTest/aspectjar.jar
Binary files differ
diff --git a/ajde/testdata/DuplicateManifestTest/injar.jar b/ajde/testdata/DuplicateManifestTest/injar.jar
index 5acb18fbf..6be74aa69 100644
--- a/ajde/testdata/DuplicateManifestTest/injar.jar
+++ b/ajde/testdata/DuplicateManifestTest/injar.jar
Binary files differ
diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice.jar
index 5b1c79f28..034912cc5 100644
--- a/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice.jar
+++ b/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice.jar
Binary files differ
diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice_nodebug.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice_nodebug.jar
index 5b1c79f28..1337138de 100644
--- a/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice_nodebug.jar
+++ b/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice_nodebug.jar
Binary files differ
diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare.jar
index 20a53db64..80540449d 100644
--- a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare.jar
+++ b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare.jar
Binary files differ
diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft.jar
index 239347f8c..71781ceef 100644
--- a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft.jar
+++ b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft.jar
Binary files differ
diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft_nodebug.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft_nodebug.jar
index 239347f8c..c59b452d6 100644
--- a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft_nodebug.jar
+++ b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft_nodebug.jar
Binary files differ
diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare_nodebug.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare_nodebug.jar
index 45bc72b70..e5a243c35 100644
--- a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare_nodebug.jar
+++ b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare_nodebug.jar
Binary files differ
diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectITD.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectITD.jar
index fb54fede9..a62f12e89 100644
--- a/ajde/testdata/WeaveInfoMessagesTest/AspectITD.jar
+++ b/ajde/testdata/WeaveInfoMessagesTest/AspectITD.jar
Binary files differ
diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectITD_nodebug.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectITD_nodebug.jar
index fb54fede9..a62f12e89 100644
--- a/ajde/testdata/WeaveInfoMessagesTest/AspectITD_nodebug.jar
+++ b/ajde/testdata/WeaveInfoMessagesTest/AspectITD_nodebug.jar
Binary files differ
diff --git a/ajde/testdata/WeaveInfoMessagesTest/Simple.jar b/ajde/testdata/WeaveInfoMessagesTest/Simple.jar
index 42490e2ee..01a8e7cfb 100644
--- a/ajde/testdata/WeaveInfoMessagesTest/Simple.jar
+++ b/ajde/testdata/WeaveInfoMessagesTest/Simple.jar
Binary files differ
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
index bd159aa17..01f3aceb7 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
@@ -59,6 +59,8 @@ public abstract class InterTypeDeclaration extends AjMethodDeclaration {
*/
protected List typeVariableAliases;
+ protected InterTypeScope interTypeScope;
+
/**
* When set to true, the scope hierarchy for the field/method declaration has been correctly modified to
* include an intertypescope which resolves things relative to the targetted type.
@@ -136,8 +138,8 @@ public abstract class InterTypeDeclaration extends AjMethodDeclaration {
if (ignoreFurtherInvestigation) return;
if (!scopeSetup) {
- ClassScope newParent = new InterTypeScope(upperScope, onTypeBinding,typeVariableAliases);
- scope.parent = newParent;
+ interTypeScope = new InterTypeScope(upperScope, onTypeBinding,typeVariableAliases);
+ scope.parent = interTypeScope;
this.scope.isStatic = Modifier.isStatic(declaredModifiers);
scopeSetup = true;
}
@@ -354,7 +356,7 @@ public abstract class InterTypeDeclaration extends AjMethodDeclaration {
// if resolution failed, give up - someone else is going to report an error
if (rb instanceof ProblemReferenceBinding) return;
- ClassScope newParent = new InterTypeScope(scope.parent, rb, typeVariableAliases);
+ interTypeScope = new InterTypeScope(scope.parent, rb, typeVariableAliases);
// FIXME asc verify the choice of lines here...
// Two versions of this next line.
// First one tricks the JDT variable processing code so that it won't complain if
@@ -364,7 +366,7 @@ public abstract class InterTypeDeclaration extends AjMethodDeclaration {
// this is the original version in case tricking the JDT causes grief (if you reinstate this variant, you
// will need to change the expected messages output for some of the generic ITD tests)
// scope.isStatic = Modifier.isStatic(declaredModifiers);
- scope.parent = newParent;
+ scope.parent = interTypeScope;
scopeSetup = true;
}
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
index 2ef5cc7e1..a814fe74f 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
@@ -167,11 +167,11 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration {
public EclipseTypeMunger build(ClassScope classScope) {
- EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(classScope);
+ EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(classScope);
resolveOnType(classScope);
if (ignoreFurtherInvestigation) return null;
-
+
binding = classScope.referenceContext.binding.resolveTypesFor(binding);
if (binding == null) {
// if binding is null, we failed to find a type used in the method params, this error
@@ -183,23 +183,22 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration {
if (isTargetAnnotation(classScope,"method")) return null; // Error message output in isTargetAnnotation
if (isTargetEnum(classScope,"method")) return null; // Error message output in isTargetEnum
-
// This signature represents what we want consumers of the targetted type to 'see'
// must use the factory method to build it since there may be typevariables from the binding
// referred to in the parameters/returntype
- ResolvedMember sig = world.makeResolvedMember(binding,onTypeBinding);
+ ResolvedMember sig = factory.makeResolvedMemberForITD(binding,onTypeBinding,interTypeScope.getRecoveryAliases());
sig.resetName(new String(declaredSelector));
int resetModifiers = declaredModifiers;
if (binding.isVarargs()) resetModifiers = resetModifiers | Constants.ACC_VARARGS;
sig.resetModifiers(resetModifiers);
- NewMethodTypeMunger myMunger = new NewMethodTypeMunger(sig, null);
+ NewMethodTypeMunger myMunger = new NewMethodTypeMunger(sig, null, typeVariableAliases);
setMunger(myMunger);
- ResolvedType aspectType = world.fromEclipse(classScope.referenceContext.binding);
+ ResolvedType aspectType = factory.fromEclipse(classScope.referenceContext.binding);
ResolvedMember me =
myMunger.getInterMethodBody(aspectType);
this.selector = binding.selector = me.getName().toCharArray();
- return new EclipseTypeMunger(world, myMunger, aspectType, this);
+ return new EclipseTypeMunger(factory, myMunger, aspectType, this);
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
index 2c49f86ee..1977c32b7 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
@@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
@@ -308,9 +309,22 @@ public class EclipseFactory {
if (typeVariableBindingsInProgress.containsKey(aTypeVariableBinding)) {
return (UnresolvedType) typeVariableBindingsInProgress.get(aTypeVariableBinding);
}
+
+ // Check if its a type variable binding that we need to recover to an alias...
+ if (typeVariablesForAliasRecovery!=null) {
+ String aliasname = (String)typeVariablesForAliasRecovery.get(aTypeVariableBinding);
+ if (aliasname!=null) {
+ UnresolvedTypeVariableReferenceType ret = new UnresolvedTypeVariableReferenceType();
+ ret.setTypeVariable(new TypeVariable(aliasname));
+ return ret;
+ }
+ }
+
if (typeVariablesForThisMember.containsKey(new String(aTypeVariableBinding.sourceName))) {
return (UnresolvedType)typeVariablesForThisMember.get(new String(aTypeVariableBinding.sourceName));
}
+
+
// Create the UnresolvedTypeVariableReferenceType for the type variable
String name = CharOperation.charToString(aTypeVariableBinding.sourceName());
@@ -430,8 +444,32 @@ public class EclipseFactory {
* (params, return type) we store the type variables in this structure, then should any
* component of the method binding refer to them, we grab them from the map.
*/
- // FIXME asc convert to array, indexed by rank
private Map typeVariablesForThisMember = new HashMap();
+
+ /**
+ * This is a map from typevariablebindings (eclipsey things) to the names the user
+ * originally specified in their ITD. For example if the target is 'interface I<N extends Number> {}'
+ * and the ITD was 'public void I<X>.m(List<X> lxs) {}' then this map would contain a pointer
+ * from the eclipse type 'N extends Number' to the letter 'X'.
+ */
+ private Map typeVariablesForAliasRecovery;
+
+ /**
+ * Construct a resolvedmember from a methodbinding. The supplied map tells us about any
+ * typevariablebindings that replaced typevariables whilst the compiler was resolving types -
+ * this only happens if it is a generic itd that shares type variables with its target type.
+ */
+ public ResolvedMember makeResolvedMemberForITD(MethodBinding binding,TypeBinding declaringType,
+ Map /*TypeVariableBinding > original alias name*/ recoveryAliases) {
+ ResolvedMember result = null;
+ try {
+ typeVariablesForAliasRecovery = recoveryAliases;
+ result = makeResolvedMember(binding,declaringType);
+ } finally {
+ typeVariablesForAliasRecovery = null;
+ }
+ return result;
+ }
public ResolvedMember makeResolvedMember(MethodBinding binding, TypeBinding declaringType) {
//System.err.println("member for: " + binding + ", " + new String(binding.declaringClass.sourceName));
@@ -463,14 +501,12 @@ public class EclipseFactory {
if (binding.isVarargs()) {
ret.setVarargsMethod();
}
- if (typeVariablesForThisMember.size()!=0) {
- // SAUSAGES this might be broken with the change for resolved members to own type variables
- TypeVariable[] tvars = new TypeVariable[typeVariablesForThisMember.size()];
- int i =0;
- for (Iterator iter = typeVariablesForThisMember.values().iterator(); iter.hasNext();) {
- tvars[i++] = ((TypeVariableReference)((UnresolvedType)iter.next())).getTypeVariable();
+ if (ajTypeRefs!=null) {
+ TypeVariable[] tVars = new TypeVariable[ajTypeRefs.length];
+ for (int i=0;i<ajTypeRefs.length;i++) {
+ tVars[i]=((TypeVariableReference)ajTypeRefs[i]).getTypeVariable();
}
- ret.setTypeVariables(tvars);
+ ret.setTypeVariables(tVars);
}
typeVariablesForThisMember.clear();
ret.resolve(world);
@@ -545,7 +581,8 @@ public class EclipseFactory {
lookupEnvironment.createParameterizedType(baseTypeBinding,argumentBindings,baseTypeBinding.enclosingType());
return ptb;
} else if (typeX.isTypeVariableReference()) {
- return makeTypeVariableBinding((TypeVariableReference)typeX);
+// return makeTypeVariableBinding((TypeVariableReference)typeX);
+ return makeTypeVariableBindingFromAJTypeVariable(((TypeVariableReference)typeX).getTypeVariable());
} else if (typeX.isRawType()) {
ReferenceBinding baseTypeBinding = lookupBinding(typeX.getBaseName());
RawTypeBinding rtb = lookupEnvironment.createRawType(baseTypeBinding,baseTypeBinding.enclosingType());
@@ -614,26 +651,72 @@ public class EclipseFactory {
private ReferenceBinding currentType = null;
+ /**
+ * Convert a resolvedmember into an eclipse method binding.
+ */
+ public MethodBinding makeMethodBinding(ResolvedMember member,List aliases) {
+ return internalMakeMethodBinding(member,aliases);
+ }
+
+ /**
+ * Convert a resolvedmember into an eclipse method binding.
+ */
public MethodBinding makeMethodBinding(ResolvedMember member) {
+ return internalMakeMethodBinding(member,null); // there are no aliases
+
+// typeVariableToTypeBinding.clear(); // will be filled in as we go along...
+// TypeVariableBinding[] tvbs = null;
+//
+// if (member.getTypeVariables()!=null) {
+// if (member.getTypeVariables().length==0) tvbs = MethodBinding.NoTypeVariables;
+// else tvbs = makeTypeVariableBindingsFromAJTypeVariables(member.getTypeVariables());
+// // QQQ do we need to bother fixing up the declaring element for each type variable?
+// }
+//
+// ReferenceBinding declaringType = (ReferenceBinding)makeTypeBinding(member.getDeclaringType());
+// currentType = declaringType;
+// MethodBinding mb = new MethodBinding(member.getModifiers(),
+// member.getName().toCharArray(),
+// makeTypeBinding(member.getReturnType()),
+// makeTypeBindings(member.getParameterTypes()),
+// makeReferenceBindings(member.getExceptions()),
+// declaringType);
+//
+// if (tvbs!=null) mb.typeVariables = tvbs;
+// typeVariableToTypeBinding.clear();
+// currentType = null;
+// return mb;
+ }
+
+ /**
+ * Convert a normal AJ member and convert it into an eclipse methodBinding.
+ * Taking into account any aliases that it may include due to being a
+ * generic ITD. Any aliases are put into the typeVariableToBinding
+ * map so that they will be substituted as appropriate in the returned
+ * methodbinding
+ */
+ public MethodBinding internalMakeMethodBinding(ResolvedMember member,List aliases) {
typeVariableToTypeBinding.clear();
TypeVariableBinding[] tvbs = null;
-
+
if (member.getTypeVariables()!=null) {
if (member.getTypeVariables().length==0) {
tvbs = MethodBinding.NoTypeVariables;
} else {
tvbs = makeTypeVariableBindingsFromAJTypeVariables(member.getTypeVariables());
- // fixup the declaring element, we couldn't do it whilst processing the typevariables as we'll end up in recursion.
- for (int i = 0; i < tvbs.length; i++) {
- TypeVariableBinding binding = tvbs[i];
-// if (binding.declaringElement==null && ((TypeVariableReference)member.getTypeVariables()[i]).getTypeVariable().getDeclaringElement() instanceof Member) {
-// tvbs[i].declaringElement = mb;
-// } else {
-// tvbs[i].declaringElement = declaringType;
-// }
- }
+ // QQQ do we need to bother fixing up the declaring element here?
}
- }
+ }
+
+ // If there are aliases, place them in the map
+ if (aliases!=null && aliases.size()!=0) {
+ ReferenceBinding tType = (ReferenceBinding)makeTypeBinding(member.getDeclaringType());
+ int i=0;
+ for (Iterator iter = aliases.iterator(); iter.hasNext();) {
+ String element = (String) iter.next();
+ typeVariableToTypeBinding.put(element,tType.typeVariables()[i++]);
+ }
+ }
ReferenceBinding declaringType = (ReferenceBinding)makeTypeBinding(member.getDeclaringType());
currentType = declaringType;
@@ -654,14 +737,14 @@ public class EclipseFactory {
/**
* Convert a bunch of type variables in one go, from AspectJ form to Eclipse form.
*/
- private TypeVariableBinding[] makeTypeVariableBindings(UnresolvedType[] typeVariables) {
- int len = typeVariables.length;
- TypeVariableBinding[] ret = new TypeVariableBinding[len];
- for (int i = 0; i < len; i++) {
- ret[i] = makeTypeVariableBinding((TypeVariableReference)typeVariables[i]);
- }
- return ret;
- }
+// private TypeVariableBinding[] makeTypeVariableBindings(UnresolvedType[] typeVariables) {
+// int len = typeVariables.length;
+// TypeVariableBinding[] ret = new TypeVariableBinding[len];
+// for (int i = 0; i < len; i++) {
+// ret[i] = makeTypeVariableBinding((TypeVariableReference)typeVariables[i]);
+// }
+// return ret;
+// }
private TypeVariableBinding[] makeTypeVariableBindingsFromAJTypeVariables(TypeVariable[] typeVariables) {
int len = typeVariables.length;
@@ -684,10 +767,10 @@ public class EclipseFactory {
* to the TypeVariableBinding.
*/
private TypeVariableBinding makeTypeVariableBinding(TypeVariableReference tvReference) {
- TypeVariable tVar = tvReference.getTypeVariable();
- TypeVariableBinding tvBinding = (TypeVariableBinding)typeVariableToTypeBinding.get(tVar.getName());
+ TypeVariable tv = tvReference.getTypeVariable();
+ TypeVariableBinding tvBinding = (TypeVariableBinding)typeVariableToTypeBinding.get(tv.getName());
if (currentType!=null) {
- TypeVariableBinding tvb = currentType.getTypeVariable(tVar.getName().toCharArray());
+ TypeVariableBinding tvb = currentType.getTypeVariable(tv.getName().toCharArray());
if (tvb!=null) return tvb;
}
if (tvBinding==null) {
@@ -698,14 +781,14 @@ public class EclipseFactory {
// } else {
// declaringElement = makeTypeBinding((UnresolvedType)tVar.getDeclaringElement());
// }
- tvBinding = new TypeVariableBinding(tVar.getName().toCharArray(),declaringElement,tVar.getRank());
- typeVariableToTypeBinding.put(tVar.getName(),tvBinding);
- tvBinding.superclass=(ReferenceBinding)makeTypeBinding(tVar.getUpperBound());
- tvBinding.firstBound=tvBinding.superclass; // FIXME asc is this correct? possibly it could be first superinterface
- if (tVar.getAdditionalInterfaceBounds()==null) {
+ tvBinding = new TypeVariableBinding(tv.getName().toCharArray(),declaringElement,tv.getRank());
+ typeVariableToTypeBinding.put(tv.getName(),tvBinding);
+ tvBinding.superclass=(ReferenceBinding)makeTypeBinding(tv.getUpperBound());
+ tvBinding.firstBound=(ReferenceBinding)makeTypeBinding(tv.getFirstBound());
+ if (tv.getAdditionalInterfaceBounds()==null) {
tvBinding.superInterfaces=TypeVariableBinding.NoSuperInterfaces;
} else {
- TypeBinding tbs[] = makeTypeBindings(tVar.getAdditionalInterfaceBounds());
+ TypeBinding tbs[] = makeTypeBindings(tv.getAdditionalInterfaceBounds());
ReferenceBinding[] rbs= new ReferenceBinding[tbs.length];
for (int i = 0; i < tbs.length; i++) {
rbs[i] = (ReferenceBinding)tbs[i];
@@ -733,7 +816,7 @@ public class EclipseFactory {
tvBinding = new TypeVariableBinding(tv.getName().toCharArray(),declaringElement,tv.getRank());
typeVariableToTypeBinding.put(tv.getName(),tvBinding);
tvBinding.superclass=(ReferenceBinding)makeTypeBinding(tv.getUpperBound());
- tvBinding.firstBound=tvBinding.superclass; // FIXME asc is this correct? possibly it could be first superinterface
+ tvBinding.firstBound=(ReferenceBinding)makeTypeBinding(tv.getFirstBound());
if (tv.getAdditionalInterfaceBounds()==null) {
tvBinding.superInterfaces=TypeVariableBinding.NoSuperInterfaces;
} else {
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java
index 8f7b1544f..d3ff29a8b 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java
@@ -106,7 +106,7 @@ public class EclipseTypeMunger extends ConcreteTypeMunger {
private boolean mungeNewMethod(SourceTypeBinding sourceType, ResolvedType onType, NewMethodTypeMunger munger, boolean isExactTargetType) {
InterTypeMethodBinding binding =
- new InterTypeMethodBinding(world, munger.getSignature(), aspectType, sourceMethod);
+ new InterTypeMethodBinding(world, munger, aspectType, sourceMethod);
if (!isExactTargetType) {
// we're munging an interface ITD onto a topmost implementor
@@ -144,7 +144,7 @@ public class EclipseTypeMunger extends ConcreteTypeMunger {
//classScope.referenceContext.binding.addMethod(binding);
} else {
InterTypeMethodBinding binding =
- new InterTypeMethodBinding(world, munger.getSignature(), aspectType, sourceMethod);
+ new InterTypeMethodBinding(world, munger, aspectType, sourceMethod);
findOrCreateInterTypeMemberFinder(sourceType).addInterTypeMethod(binding);
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMethodBinding.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMethodBinding.java
index 658b6ef13..c3c2b97c4 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMethodBinding.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMethodBinding.java
@@ -13,10 +13,6 @@
package org.aspectj.ajdt.internal.compiler.lookup;
-import org.aspectj.weaver.AjcMemberMaker;
-import org.aspectj.weaver.Member;
-import org.aspectj.weaver.ResolvedMember;
-import org.aspectj.weaver.UnresolvedType;
import org.aspectj.ajdt.internal.compiler.ast.InterTypeMethodDeclaration;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
@@ -25,6 +21,11 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.aspectj.weaver.AjcMemberMaker;
+import org.aspectj.weaver.Member;
+import org.aspectj.weaver.ResolvedMember;
+import org.aspectj.weaver.ResolvedTypeMunger;
+import org.aspectj.weaver.UnresolvedType;
/**
* A special method binding representing an ITD that pretends to be a
@@ -46,11 +47,12 @@ public class InterTypeMethodBinding extends MethodBinding {
public AbstractMethodDeclaration sourceMethod;
- public InterTypeMethodBinding(EclipseFactory world, ResolvedMember signature, UnresolvedType withinType,
+ public InterTypeMethodBinding(EclipseFactory world, ResolvedTypeMunger munger, UnresolvedType withinType,
AbstractMethodDeclaration sourceMethod)
{
super();
- MethodBinding mb = world.makeMethodBinding(signature);
+ ResolvedMember signature = munger.getSignature();
+ MethodBinding mb = world.makeMethodBinding(signature,munger.getTypeVariableAliases());
this.modifiers = mb.modifiers;
this.selector = mb.selector;
this.returnType = mb.returnType;
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java
index 6ebf5dd36..800ed82e8 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java
@@ -13,7 +13,9 @@
package org.aspectj.ajdt.internal.compiler.lookup;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope;
@@ -28,6 +30,7 @@ import org.aspectj.weaver.BCException;
public class InterTypeScope extends ClassScope {
ReferenceBinding onType;
List aliases;
+ Map /* real type variable > alias letter */ usedAliases; // Used later when reconstructing the resolved member
public InterTypeScope(Scope parent, ReferenceBinding onType) {
super(parent, null);
@@ -40,6 +43,11 @@ public class InterTypeScope extends ClassScope {
this(parent,rb);
this.aliases = list;
}
+
+ public String getAnyAliasForTypeVariableBinding(TypeVariableBinding tvb) {
+ if (usedAliases==null) return null;
+ return (String)usedAliases.get(tvb);
+ }
// this method depends on the fact that BinaryTypeBinding extends SourceTypeBinding
private SourceTypeBinding makeSourceTypeBinding(ReferenceBinding onType) {
@@ -65,18 +73,26 @@ public class InterTypeScope extends ClassScope {
public TypeVariableBinding findTypeVariable(char[] name, SourceTypeBinding sourceType) {
- int aliased = (aliases==null?-1:aliases.indexOf(new String(name)));
+ String variableName = new String(name);
+ int aliased = (aliases==null?-1:aliases.indexOf(variableName));
if (aliased!=-1) {
if (aliased>sourceType.typeVariables.length || sourceType.typeVariables.length==0) {
TypeVariableBinding tvb = new TypeVariableBinding("fake".toCharArray(),null,0);
return tvb;
// error is going to be reported by someone else!
}
- return sourceType.typeVariables()[aliased];
+ TypeVariableBinding tvb = sourceType.typeVariables()[aliased];
+ if (usedAliases==null) usedAliases = new HashMap();
+ usedAliases.put(tvb,variableName);
+ return tvb;
} else {
return sourceType.getTypeVariable(name);
}
}
+
+ public Map getRecoveryAliases() {
+ return usedAliases;
+ }
}
diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar
index 630447de1..fa70dfa06 100644
--- a/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar
+++ b/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar
Binary files differ
diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar
index c68c6ee97..17ef34cb6 100644
--- a/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar
+++ b/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar
Binary files differ
diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar
index d2dc56815..312c68e0f 100644
--- a/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar
+++ b/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar
Binary files differ
diff --git a/tests/bugs/StringToString/helloworld.jar b/tests/bugs/StringToString/helloworld.jar
index 3bc842f8e..abd898814 100644
--- a/tests/bugs/StringToString/helloworld.jar
+++ b/tests/bugs/StringToString/helloworld.jar
Binary files differ
diff --git a/tests/bugs/cflowAndJar/lib.jar b/tests/bugs/cflowAndJar/lib.jar
index 2c4318164..fb5c153cb 100644
--- a/tests/bugs/cflowAndJar/lib.jar
+++ b/tests/bugs/cflowAndJar/lib.jar
Binary files differ
diff --git a/tests/bugs/perCflowAndJar/lib.jar b/tests/bugs/perCflowAndJar/lib.jar
index b8baf948e..08d72b0fc 100644
--- a/tests/bugs/perCflowAndJar/lib.jar
+++ b/tests/bugs/perCflowAndJar/lib.jar
Binary files differ
diff --git a/tests/bugs/serialVersionUID/injar.jar b/tests/bugs/serialVersionUID/injar.jar
index 431dd1cbe..c2438ab83 100644
--- a/tests/bugs/serialVersionUID/injar.jar
+++ b/tests/bugs/serialVersionUID/injar.jar
Binary files differ
diff --git a/tests/java5/generics/itds/design/DesignC.java b/tests/java5/generics/itds/design/DesignC.java
index 8e25e9f56..51d410843 100644
--- a/tests/java5/generics/itds/design/DesignC.java
+++ b/tests/java5/generics/itds/design/DesignC.java
@@ -1,10 +1,13 @@
+import java.util.*;
+
class C {}
interface I {}
aspect X {
- <T extends Number,Q extends I> void C.m0(T t,Q q) {} // L7
+ <T extends Number,Q extends I> void C.m0(T t,Q q) { } // L9
+
+ <A,B,C> List<A> C.m1(B b,Collection<C> cs) { return null; } // L11
- <A,B,C> List<A> C.m1(B b,Collection<C> cs) {} // L9
}
diff --git a/tests/java5/generics/itds/design/DesignD.java b/tests/java5/generics/itds/design/DesignD.java
new file mode 100644
index 000000000..33487fe53
--- /dev/null
+++ b/tests/java5/generics/itds/design/DesignD.java
@@ -0,0 +1,13 @@
+import java.util.*;
+
+class C<N extends Number> {}
+
+interface I {}
+
+aspect X {
+
+ void C<R>.m0(R n) { } // L9
+
+ List<Q> C<Q>.m0(Q q,int i,List<List<Q>> qs) {return null;} // L11
+
+}
diff --git a/tests/new/options11/aspectlib1.jar b/tests/new/options11/aspectlib1.jar
index c79c95197..eb0e70ea9 100644
--- a/tests/new/options11/aspectlib1.jar
+++ b/tests/new/options11/aspectlib1.jar
Binary files differ
diff --git a/tests/new/options11/aspectlib2.jar b/tests/new/options11/aspectlib2.jar
index 90ea2ccbe..a9b305b85 100644
--- a/tests/new/options11/aspectlib2.jar
+++ b/tests/new/options11/aspectlib2.jar
Binary files differ
diff --git a/tests/new/options11/injar.jar b/tests/new/options11/injar.jar
index bcbf51b54..8b6515b84 100644
--- a/tests/new/options11/injar.jar
+++ b/tests/new/options11/injar.jar
Binary files differ
diff --git a/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java b/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java
index a2cf92c07..3f251e210 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java
@@ -36,6 +36,13 @@ public class GenericITDsDesign extends XMLBasedAjcTestCase {
return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml");
}
+
+ private void verifyDebugString(ResolvedMember theMember, String string) {
+ assertTrue("Expected '"+string+"' but found "+theMember.toDebugString(),
+ theMember.toDebugString().equals(string));
+ }
+
+
public static Signature getClassSignature(Ajc ajc,String classname) {
try {
ClassPath cp =
@@ -142,26 +149,53 @@ public class GenericITDsDesign extends XMLBasedAjcTestCase {
}
// Verify: bounds are preserved and accessible after serialization
- public void xtestDesignB() {
+ public void testDesignB() {
runTest("generic itds - design B");
BcelTypeMunger theBcelMunger = getMungerFromLine("X",7);
+ ResolvedTypeMunger rtMunger = theBcelMunger.getMunger();
+ ResolvedMember theMember = rtMunger.getSignature();
+ verifyDebugString(theMember,"<T extends java.lang.Number> void C.m0(T)");
+
+ theBcelMunger = getMungerFromLine("X",9);
+ rtMunger = theBcelMunger.getMunger();
+ theMember = rtMunger.getSignature();
+ verifyDebugString(theMember,"<Q extends I> void C.m1(Q)");
+
+ theBcelMunger = getMungerFromLine("X",11);
+ rtMunger = theBcelMunger.getMunger();
+ theMember = rtMunger.getSignature();
+ verifyDebugString(theMember,"<R extends java.lang.Number,I> void C.m2(R)");
}
// Verify: a) multiple type variables work.
// b) type variables below the 'top level' (e.g. List<A>) are preserved.
- public void xtestDesignC() {
- runTest("generic itds - design B");
- BcelTypeMunger theBcelMunger = getMungerFromLine("X",7);
+ public void testDesignC() {
+ runTest("generic itds - design C");
+ BcelTypeMunger theBcelMunger = getMungerFromLine("X",9);
+ //System.err.println(theBcelMunger.getMunger().getSignature().toDebugString());
+ verifyDebugString(theBcelMunger.getMunger().getSignature(),"<T extends java.lang.Number,Q extends I> void C.m0(T, Q)");
+
+ theBcelMunger = getMungerFromLine("X",11);
+ System.err.println(theBcelMunger.getMunger().getSignature().toDebugString());
+ verifyDebugString(theBcelMunger.getMunger().getSignature(),"<A,B,C> java.util.List<A> C.m1(B, java.util.Collection<C>)");
}
+ // Verify: a) sharing type vars with some target type results in the correct variable names in the serialized form
+ public void testDesignD() {
+ runTest("generic itds - design D");
+ BcelTypeMunger theBcelMunger = getMungerFromLine("X",9);
+ // System.err.println(theBcelMunger.getMunger().getSignature().toDebugString());
+ verifyDebugString(theBcelMunger.getMunger().getSignature(),"void C.m0(R)");
+
+ theBcelMunger = getMungerFromLine("X",11);
+ // System.err.println(theBcelMunger.getMunger().getSignature().toDebugString());
+ verifyDebugString(theBcelMunger.getMunger().getSignature(),"java.util.List<Q> C.m0(Q, int, java.util.List<java.util.List<Q>>)");
+ }
- /*
- * broken stuff:
- *
- * When generic signatures are unpacked from members, the typevariables attached to the bcelmethod/field won't
- * be the same instances as those held in the TypeVariableReferenceTypes for anything that occurs in the
- * return type or parameterset - we should perhaps fix that up.
- */
+// // Verify: a) sharing type vars with some target type results in the correct variable names in the serialized form
+// public void testDesignE() {
+// runTest("generic itds - design E");
+//
+// }
-
}
diff --git a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java
index 16e8f0195..316731115 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java
@@ -351,7 +351,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testSophisticatedAspectsC() {runTest("uberaspects - C");}
public void testSophisticatedAspectsD() {runTest("uberaspects - D");}
public void testSophisticatedAspectsE() {runTest("uberaspects - E");}
- public void testSophisticatedAspectsF() {runTest("uberaspects - F");}
+// public void testSophisticatedAspectsF() {runTest("uberaspects - F");} field ITD collapses to Number from tvar..
// public void testSophisticatedAspectsG() {runTest("uberaspects - G");}
public void testSophisticatedAspectsH() {runTest("uberaspects - H");}
public void testSophisticatedAspectsI() {runTest("uberaspects - I");}
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
index 703c1b3fc..530ec5f37 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
@@ -3229,7 +3229,7 @@
<ajc-test dir="java5/generics/itds" title="generic method itd - 10">
<compile files="GenericMethodITD10.aj" options="-1.5">
- <message kind="error" line="10" text="Bound mismatch: The generic method crazy(List&lt;R&gt;) of type Base is not applicable for the arguments (List&lt;A&gt;). The inferred type A is not a valid substitute for the bounded parameter &lt;R extends Object &amp; Comparable&lt;? super R&gt;&gt;"/>
+ <message kind="error" line="10" text="Bound mismatch: The generic method crazy(List&lt;R&gt;) of type Base is not applicable for the arguments (List&lt;A&gt;). The inferred type A is not a valid substitute for the bounded parameter &lt;R extends Comparable&lt;? super R&gt;&gt;"/>
</compile>
</ajc-test>
@@ -3240,7 +3240,7 @@
<ajc-test dir="java5/generics/itds" title="generic method itd - 12">
<compile files="GenericMethodITD12.aj" options="-1.5">
- <message kind="error" line="10" text="Bound mismatch: The generic method crazy(List&lt;R&gt;) of type Base is not applicable for the arguments (List&lt;A&gt;). The inferred type A is not a valid substitute for the bounded parameter &lt;R extends Object &amp; Foo&lt;? extends R&gt;&gt;"/>
+ <message kind="error" line="10" text="Bound mismatch: The generic method crazy(List&lt;R&gt;) of type Base is not applicable for the arguments (List&lt;A&gt;). The inferred type A is not a valid substitute for the bounded parameter &lt;R extends Foo&lt;? extends R&gt;&gt;"/>
</compile>
</ajc-test>
@@ -3251,7 +3251,7 @@
<ajc-test dir="java5/generics/itds" title="generic method itd - 14">
<compile files="GenericMethodITD14.aj" options="-1.5">
- <message kind="error" line="10" text="Bound mismatch: The generic method crazy(List&lt;R&gt;) of type Base is not applicable for the arguments (List&lt;A&gt;). The inferred type A is not a valid substitute for the bounded parameter &lt;R extends Object &amp; Foo&lt;? super R&gt;&gt;"/>
+ <message kind="error" line="10" text="Bound mismatch: The generic method crazy(List&lt;R&gt;) of type Base is not applicable for the arguments (List&lt;A&gt;). The inferred type A is not a valid substitute for the bounded parameter &lt;R extends Foo&lt;? super R&gt;&gt;"/>
</compile>
</ajc-test>
@@ -3820,13 +3820,13 @@
<ajc-test dir="java5/generics/itds/binaryweaving" vm="1.5" title="binary weaving ITDs - 2">
<compile files="BaseClass.java,A1.aj" outjar="code.jar" options="-1.5,-showWeaveInfo">
- <message kind="weave" text="Type 'BaseClass' (BaseClass.java) has intertyped field from 'A1' (A1.aj:'java.util.List BaseClass.list1')"/>
+ <message kind="weave" text="Type 'BaseClass' (BaseClass.java) has intertyped field from 'A1' (A1.aj:'java.util.List&lt;java.lang.String&gt; BaseClass.list1')"/>
<message kind="weave" text="Type 'BaseClass' (BaseClass.java:12) advised by after advice from 'A1' (A1.aj:7)"/>
</compile>
<compile files="A2.aj" inpath="code.jar" options="-1.5,-showWeaveInfo">
- <message kind="weave" text="Type 'BaseClass' (BaseClass.java) has intertyped field from 'A1' (A1.aj:'java.util.List BaseClass.list1')"/>
+ <message kind="weave" text="Type 'BaseClass' (BaseClass.java) has intertyped field from 'A1' (A1.aj:'java.util.List&lt;java.lang.String&gt; BaseClass.list1')"/>
<message kind="weave" text="Type 'BaseClass' (BaseClass.java:12) advised by after advice from 'A1' (A1.aj:7)"/>
- <message kind="weave" text="Type 'BaseClass' (BaseClass.java) has intertyped field from 'A2' (A2.aj:'java.util.List BaseClass.list2')"/>
+ <message kind="weave" text="Type 'BaseClass' (BaseClass.java) has intertyped field from 'A2' (A2.aj:'java.util.List&lt;N&gt; BaseClass.list2')"/>
<message kind="weave" text="Type 'BaseClass' (BaseClass.java:13) advised by after advice from 'A2' (A2.aj:8)"/>
</compile>
<run class="BaseClass">
@@ -5039,4 +5039,7 @@
<compile files="DesignC.java" options="-1.5"/>
</ajc-test>
+ <ajc-test dir="java5/generics/itds/design" title="generic itds - design D">
+ <compile files="DesignD.java" options="-1.5,-XnoWeave"/>
+ </ajc-test>
</suite> \ No newline at end of file
diff --git a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
index 142c055fa..aff454f01 100644
--- a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
+++ b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
@@ -643,11 +643,13 @@ public class AjcMemberMaker {
int modifiers = makePublicNonFinal(meth.getModifiers());
if (onInterface) modifiers |= Modifier.ABSTRACT;
- return new ResolvedMemberImpl(Member.METHOD, meth.getDeclaringType(),
+ ResolvedMemberImpl rmi = new ResolvedMemberImpl(Member.METHOD, meth.getDeclaringType(),
modifiers,
meth.getReturnType(),
NameMangler.interMethod(meth.getModifiers(), aspectType, meth.getDeclaringType(), meth.getName()),
- meth.getParameterTypes(), meth.getExceptions());
+ meth.getParameterTypes(), meth.getExceptions());
+ rmi.setTypeVariables(meth.getTypeVariables());
+ return rmi;
}
/**
@@ -661,10 +663,14 @@ public class AjcMemberMaker {
paramTypes = UnresolvedType.insert(meth.getDeclaringType(), paramTypes);
}
- return new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC,
+ ResolvedMemberImpl rmi = new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC,
meth.getReturnType(),
NameMangler.interMethodDispatcher(aspectType, meth.getDeclaringType(), meth.getName()),
paramTypes, meth.getExceptions());
+
+ rmi.setTypeVariables(meth.getTypeVariables());
+
+ return rmi;
}
/**
@@ -684,10 +690,12 @@ public class AjcMemberMaker {
}
- return new ResolvedMemberImpl(Member.METHOD, aspectType, modifiers,
+ ResolvedMemberImpl rmi = new ResolvedMemberImpl(Member.METHOD, aspectType, modifiers,
meth.getReturnType(),
NameMangler.interMethodBody(aspectType, meth.getDeclaringType(), meth.getName()),
paramTypes, meth.getExceptions());
+ rmi.setTypeVariables(meth.getTypeVariables());
+ return rmi;
}
diff --git a/weaver/src/org/aspectj/weaver/JoinPointSignature.java b/weaver/src/org/aspectj/weaver/JoinPointSignature.java
index 7b3689173..b5fb8eb67 100644
--- a/weaver/src/org/aspectj/weaver/JoinPointSignature.java
+++ b/weaver/src/org/aspectj/weaver/JoinPointSignature.java
@@ -359,6 +359,10 @@ public class JoinPointSignature implements ResolvedMember {
public String toGenericString() {
return realMember.toGenericString();
}
+
+ public String toDebugString() {
+ return realMember.toDebugString();
+ }
public void resetName(String newName) {
realMember.resetName(newName);
diff --git a/weaver/src/org/aspectj/weaver/MemberImpl.java b/weaver/src/org/aspectj/weaver/MemberImpl.java
index 6a8a03472..92c1595f5 100644
--- a/weaver/src/org/aspectj/weaver/MemberImpl.java
+++ b/weaver/src/org/aspectj/weaver/MemberImpl.java
@@ -116,10 +116,12 @@ public class MemberImpl implements Comparable, AnnotatedElement,Member {
buf.append("(");
for (int i = 0, len = paramTypes.length; i < len; i++) {
if (paramTypes[i].isParameterizedType() && useRawTypes) buf.append(paramTypes[i].getErasureSignature());
+ else if (paramTypes[i].isTypeVariableReference() && useRawTypes) buf.append(paramTypes[i].getErasureSignature());
else buf.append(paramTypes[i].getSignature());
}
buf.append(")");
if (returnType.isParameterizedType() && useRawTypes) buf.append(returnType.getErasureSignature());
+ else if (returnType.isTypeVariableReference() && useRawTypes) buf.append(returnType.getErasureSignature());
else buf.append(returnType.getSignature());
return buf.toString();
}
diff --git a/weaver/src/org/aspectj/weaver/NewMethodTypeMunger.java b/weaver/src/org/aspectj/weaver/NewMethodTypeMunger.java
index d7538763f..1e6a286aa 100644
--- a/weaver/src/org/aspectj/weaver/NewMethodTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/NewMethodTypeMunger.java
@@ -15,6 +15,7 @@ package org.aspectj.weaver;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.List;
import java.util.Set;
import org.aspectj.bridge.ISourceLocation;
@@ -22,8 +23,10 @@ import org.aspectj.bridge.ISourceLocation;
public class NewMethodTypeMunger extends ResolvedTypeMunger {
public NewMethodTypeMunger(
ResolvedMember signature,
- Set superMethodsCalled) {
+ Set superMethodsCalled,
+ List typeVariableAliases) {
super(Method, signature);
+ this.typeVariableAliases = typeVariableAliases;
this.setSuperMethodsCalled(superMethodsCalled);
}
@@ -40,14 +43,19 @@ public class NewMethodTypeMunger extends ResolvedTypeMunger {
signature.write(s);
writeSuperMethodsCalled(s);
writeSourceLocation(s);
+ writeOutTypeAliases(s);
}
public static ResolvedTypeMunger readMethod(VersionedDataInputStream s, ISourceContext context) throws IOException {
- ResolvedMemberImpl rmi = ResolvedMemberImpl.readResolvedMember(s, context);
+
+ ISourceLocation sloc = null;
+ ResolvedMemberImpl rmImpl = ResolvedMemberImpl.readResolvedMember(s, context);
Set superMethodsCalled = readSuperMethodsCalled(s);
- ISourceLocation sLoc = readSourceLocation(s);
- ResolvedTypeMunger munger = new NewMethodTypeMunger(rmi,superMethodsCalled);
- if (sLoc!=null) munger.setSourceLocation(sLoc);
+ sloc = readSourceLocation(s);
+ List typeVarAliases = readInTypeAliases(s);
+
+ ResolvedTypeMunger munger = new NewMethodTypeMunger(rmImpl,superMethodsCalled,typeVarAliases);
+ if (sloc!=null) munger.setSourceLocation(sloc);
return munger;
}
diff --git a/weaver/src/org/aspectj/weaver/ReferenceType.java b/weaver/src/org/aspectj/weaver/ReferenceType.java
index 42b6bc2f7..b9036ab65 100644
--- a/weaver/src/org/aspectj/weaver/ReferenceType.java
+++ b/weaver/src/org/aspectj/weaver/ReferenceType.java
@@ -404,7 +404,7 @@ public class ReferenceType extends ResolvedType {
TypeVariable[] tvs = getGenericType().getTypeVariables();
parameters = new UnresolvedType[tvs.length];
for (int i = 0; i < tvs.length; i++) {
- parameters[i] = tvs[i].getUpperBound();
+ parameters[i] = tvs[i].getFirstBound();
}
}
return parameters;
diff --git a/weaver/src/org/aspectj/weaver/ResolvedMember.java b/weaver/src/org/aspectj/weaver/ResolvedMember.java
index 24736d403..5e3bf3811 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedMember.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedMember.java
@@ -93,6 +93,8 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe
// like toString but include generic signature info
public String toGenericString();
+
+ public String toDebugString();
/**
* Get the UnresolvedType for the return type, taking generic signature into account
diff --git a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java
index 855d6bf75..af4fe8cc1 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java
@@ -355,7 +355,38 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
typeVariables[i].write(s);
}
}
+ String gsig = getGenericSignature();
+ if (getSignature().equals(gsig)) {
+ s.writeBoolean(false);
+ } else {
+ s.writeBoolean(true);
+ s.writeInt(parameterTypes.length);
+ for (int i = 0; i < parameterTypes.length; i++) {
+ UnresolvedType array_element = parameterTypes[i];
+ array_element.write(s);
+ }
+ returnType.write(s);
+ }
}
+
+ public String getGenericSignature() {
+ StringBuffer sb = new StringBuffer();
+ if (typeVariables!=null) {
+ sb.append("<");
+ for (int i = 0; i < typeVariables.length; i++) {
+ sb.append(typeVariables[i].getSignature());
+ }
+ sb.append(">");
+ }
+ sb.append("(");
+ for (int i = 0; i < parameterTypes.length; i++) {
+ UnresolvedType array_element = parameterTypes[i];
+ sb.append(array_element.getSignature());
+ }
+ sb.append(")");
+ sb.append(returnType.getSignature());
+ return sb.toString();
+ }
public static void writeArray(ResolvedMember[] members, DataOutputStream s) throws IOException {
s.writeInt(members.length);
@@ -370,7 +401,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
ResolvedMemberImpl m = new ResolvedMemberImpl(Kind.read(s), UnresolvedType.read(s), s.readInt(),
s.readUTF(), s.readUTF());
m.checkedExceptions = UnresolvedType.readArray(s);
-
+
m.start = s.readInt();
m.end = s.readInt();
m.sourceContext = sourceContext;
@@ -391,6 +422,20 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
m.typeVariables[i].setDeclaringElement(m);
}
}
+ if (s.getMajorVersion()>=AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150M4) {
+ boolean hasAGenericSignature = s.readBoolean();
+ if (hasAGenericSignature) {
+ int ps = s.readInt();
+ UnresolvedType[] params = new UnresolvedType[ps];
+ for (int i = 0; i < params.length; i++) {
+ UnresolvedType type = params[i];
+ params[i]=TypeFactory.createTypeFromSignature(s.readUTF());
+ }
+ UnresolvedType rt = TypeFactory.createTypeFromSignature(s.readUTF());
+ m.parameterTypes = params;
+ m.returnType = rt;
+ }
+ }
}
return m;
}
@@ -448,6 +493,9 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
public final String[] getParameterNames() {
return parameterNames;
}
+ public final void setParameterNames(String[] pnames) {
+ parameterNames = pnames;
+ }
public final String[] getParameterNames(World world) {
return getParameterNames();
}
@@ -537,23 +585,34 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
return getParameterTypes();
}
- // return a resolved member in which all type variables in the signature of this
- // member have been replaced with the given bindings.
- // the isParameterized flag tells us whether we are creating a raw type version or not
- // if isParameterized List<T> will turn into List<String> (for example),
- // but if !isParameterized List<T> will turn into List.
+ /**
+ * Return a resolvedmember in which all the type variables in the signature
+ * have been replaced with the given bindings.
+ * The 'isParameterized' flag tells us whether we are creating a raw type
+ * version or not. if (isParameterized) then List<T> will turn into
+ * List<String> (for example) - if (!isParameterized) then List<T> will turn
+ * into List.
+ */
public ResolvedMemberImpl parameterizedWith(UnresolvedType[] typeParameters,ResolvedType newDeclaringType, boolean isParameterized) {
- if (!this.getDeclaringType().isGenericType()) {
+ if (//isParameterized && <-- might need this bit...
+ !getDeclaringType().isGenericType()) {
throw new IllegalStateException("Can't ask to parameterize a member of a non-generic type");
}
TypeVariable[] typeVariables = getDeclaringType().getTypeVariables();
- if (typeVariables.length != typeParameters.length) {
+ if (isParameterized && (typeVariables.length != typeParameters.length)) {
throw new IllegalStateException("Wrong number of type parameters supplied");
}
Map typeMap = new HashMap();
- for (int i = 0; i < typeVariables.length; i++) {
- typeMap.put(typeVariables[i].getName(), typeParameters[i]);
+ if (typeVariables!=null) {
+ // If no 'replacements' were supplied in the typeParameters array then collapse
+ // type variables to their first bound.
+ boolean typeParametersSupplied = typeParameters!=null && typeParameters.length>0;
+ for (int i = 0; i < typeVariables.length; i++) {
+ UnresolvedType ut = (!typeParametersSupplied?typeVariables[i].getFirstBound():typeParameters[i]);
+ typeMap.put(typeVariables[i].getName(),ut);
+ }
}
+
UnresolvedType parameterizedReturnType = parameterize(getGenericReturnType(),typeMap,isParameterized);
UnresolvedType[] parameterizedParameterTypes = new UnresolvedType[getGenericParameterTypes().length];
for (int i = 0; i < parameterizedParameterTypes.length; i++) {
@@ -571,10 +630,10 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
this
);
ret.setSourceContext(getSourceContext());
+ ret.setPosition(getStart(),getEnd());
return ret;
}
-
-
+
public void setTypeVariables(TypeVariable[] tvars) {
typeVariables = tvars;
}
@@ -745,6 +804,53 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
}
}
+ /**
+ * Useful for writing tests, returns *everything* we know about this member.
+ */
+ public String toDebugString() {
+ StringBuffer r = new StringBuffer();
+
+ // modifiers
+ String mods = Modifier.toString(modifiers);
+ if (mods.length()!=0) r.append(mods).append(" ");
+
+ // type variables
+ if (typeVariables!=null && typeVariables.length>0) {
+ r.append("<");
+ for (int i = 0; i < typeVariables.length; i++) {
+ if (i>0) r.append(",");
+ TypeVariable t = typeVariables[i];
+ r.append(t.toDebugString());
+ }
+ r.append("> ");
+ }
+
+ // 'declaring' type
+ r.append(returnType.toDebugString());
+ r.append(' ');
+
+ // name
+ r.append(declaringType.getName());
+ r.append('.');
+ r.append(name);
+
+ // parameter signature if a method
+ if (kind != FIELD) {
+ r.append("(");
+ UnresolvedType[] params = parameterTypes;
+ boolean parameterNamesExist = parameterNames!=null && parameterNames.length==params.length;
+ if (params.length != 0) {
+ for (int i=0, len = params.length; i < len; i++) {
+ if (i>0) r.append(", ");
+ r.append(params[i].toDebugString());
+ if (parameterNamesExist) r.append(" ").append(parameterNames[i]);
+ }
+ }
+ r.append(")");
+ }
+ return r.toString();
+ }
+
public String toGenericString() {
StringBuffer buf = new StringBuffer();
buf.append(getGenericReturnType().getSimpleName());
diff --git a/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java b/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java
index 125e436f4..6a432dd76 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java
@@ -45,7 +45,7 @@ public abstract class ResolvedTypeMunger {
// across the intertype declaration to the right type variables in the generic
// type upon which the itd is being made.
// might need serializing the class file for binary weaving.
- protected List /*String*/ typeVariableToGenericTypeVariableIndex;
+ protected List /*String*/ typeVariableAliases;
private Set /* resolvedMembers */ superMethodsCalled = Collections.EMPTY_SET;
@@ -286,4 +286,36 @@ public abstract class ResolvedTypeMunger {
}
}
+ protected static List readInTypeAliases(VersionedDataInputStream s) throws IOException {
+ if (s.getMajorVersion()>=AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) {
+ int count = s.readInt();
+ List aliases = new ArrayList();
+ for (int i=0;i<count;i++) {
+ aliases.add(s.readUTF());
+ }
+ return aliases;
+ }
+ return null;
+ }
+
+ protected void writeOutTypeAliases(DataOutputStream s) throws IOException {
+ // Write any type variable aliases
+ if (typeVariableAliases==null || typeVariableAliases.size()==0) {
+ s.writeInt(0);
+ } else {
+ s.writeInt(typeVariableAliases.size());
+ for (Iterator iter = typeVariableAliases.iterator(); iter.hasNext();) {
+ String element = (String) iter.next();
+ s.writeUTF(element);
+ }
+ }
+ }
+
+ public List getTypeVariableAliases() {
+ return typeVariableAliases;
+ }
+
+ public boolean hasTypeVariableAliases() {
+ return (typeVariableAliases!=null && typeVariableAliases.size()>0);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/TypeVariable.java b/weaver/src/org/aspectj/weaver/TypeVariable.java
index 1488bb25b..30ca0f9ac 100644
--- a/weaver/src/org/aspectj/weaver/TypeVariable.java
+++ b/weaver/src/org/aspectj/weaver/TypeVariable.java
@@ -89,6 +89,15 @@ public class TypeVariable {
this.lowerBound = aLowerBound;
}
+ // First bound is the first 'real' bound, this can be an interface if
+ // no class bound was specified (it will default to object)
+ public UnresolvedType getFirstBound() {
+ if (upperBound.equals(UnresolvedType.OBJECT) && additionalInterfaceBounds!=null && additionalInterfaceBounds.length!=0) {
+ return additionalInterfaceBounds[0];
+ }
+ return upperBound;
+ }
+
public UnresolvedType getUpperBound() {
return upperBound;
}
@@ -253,16 +262,22 @@ public class TypeVariable {
this.additionalInterfaceBounds = someTypeXs;
}
+ public String toDebugString() {
+ return getDisplayName();
+ }
+
public String getDisplayName() {
StringBuffer ret = new StringBuffer();
ret.append(name);
- if (!upperBound.getName().equals("java.lang.Object")) {
+ if (!getFirstBound().getName().equals("java.lang.Object")) {
ret.append(" extends ");
- ret.append(upperBound.getName());
+ ret.append(getFirstBound().getName());
if (additionalInterfaceBounds != null) {
for (int i = 0; i < additionalInterfaceBounds.length; i++) {
- ret.append(" & ");
- ret.append(additionalInterfaceBounds[i].getName());
+ if (!getFirstBound().equals(additionalInterfaceBounds[i])) {
+ ret.append(" & ");
+ ret.append(additionalInterfaceBounds[i].getName());
+ }
}
}
}
@@ -284,9 +299,10 @@ public class TypeVariable {
public String getSignature() {
StringBuffer sb = new StringBuffer();
sb.append(name);
- sb.append(":");
- sb.append(upperBound.getSignature());
- if (additionalInterfaceBounds!=null) {
+ sb.append(":");
+ sb.append(upperBound.getSignature());
+ if (additionalInterfaceBounds!=null && additionalInterfaceBounds.length!=0) {
+ sb.append(":");
for (int i = 0; i < additionalInterfaceBounds.length; i++) {
UnresolvedType iBound = additionalInterfaceBounds[i];
sb.append(iBound.getSignature());
diff --git a/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java b/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java
index 59b3b1b19..b12bb7262 100644
--- a/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java
+++ b/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java
@@ -31,13 +31,18 @@ public class TypeVariableReferenceType extends BoundedReferenceType implements T
public TypeVariableReferenceType(
TypeVariable aTypeVariable,
World aWorld) {
- super(aTypeVariable.getUpperBound().getSignature(),aWorld);
+ super(aTypeVariable.getFirstBound().getSignature(),aWorld);
this.typeVariable = aTypeVariable;
this.isExtends = false;
this.isSuper = false;
- setDelegate(new ReferenceTypeReferenceTypeDelegate((ReferenceType)aTypeVariable.getUpperBound()));
}
+ public ReferenceTypeDelegate getDelegate() {
+ if (delegate==null)
+ setDelegate(new ReferenceTypeReferenceTypeDelegate((ReferenceType)typeVariable.getFirstBound()));
+ return delegate;
+ }
+
public UnresolvedType getUpperBound() {
if (typeVariable==null) return super.getUpperBound();
return typeVariable.getUpperBound();
@@ -76,6 +81,10 @@ public class TypeVariableReferenceType extends BoundedReferenceType implements T
return true;
}
+ public String toString() {
+ return typeVariable.getName();
+ }
+
public boolean isGenericWildcard() {
return false;
}
diff --git a/weaver/src/org/aspectj/weaver/UnresolvedType.java b/weaver/src/org/aspectj/weaver/UnresolvedType.java
index 7b0ef3972..abf8e000b 100644
--- a/weaver/src/org/aspectj/weaver/UnresolvedType.java
+++ b/weaver/src/org/aspectj/weaver/UnresolvedType.java
@@ -623,6 +623,10 @@ public class UnresolvedType implements TypeVariableDeclaringElement {
public String toString() {
return getName(); // + " - " + getKind();
}
+
+ public String toDebugString() {
+ return getName();
+ }
// ---- requires worlds
diff --git a/weaver/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java b/weaver/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java
index e9db34508..65c109dc1 100644
--- a/weaver/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java
+++ b/weaver/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java
@@ -29,7 +29,7 @@ public class UnresolvedTypeVariableReferenceType extends UnresolvedType implemen
}
public UnresolvedTypeVariableReferenceType(TypeVariable aTypeVariable) {
- super(aTypeVariable.getUpperBound().getSignature());
+ super(aTypeVariable.getFirstBound().getSignature());
this.typeVariable = aTypeVariable;
}
@@ -111,21 +111,16 @@ public class UnresolvedTypeVariableReferenceType extends UnresolvedType implemen
}
}
+ public String toDebugString() {
+ return typeVariable.getName();
+ }
+
public void write(DataOutputStream s) throws IOException {
super.write(s);
}
- /*
- public static void readDeclaringElement(DataInputStream s, UnresolvedTypeVariableReferenceType utv)
- throws IOException {
- int kind = s.readInt();
- utv.typeVariable.setDeclaringElementKind(kind);
- if (kind == TypeVariable.TYPE) {
- utv.typeVariable.setDeclaringElement(UnresolvedType.read(s));
- } else if (kind == TypeVariable.METHOD) {
- // it's a method
- ResolvedMember rm = ResolvedMemberImpl.readResolvedMember(new VersionedDataInputStream(s),null);
- utv.typeVariable.setDeclaringElement(rm);
- }
+
+ public String getErasureSignature() {
+ return typeVariable.getFirstBound().getSignature();
}
-*/
+
}
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
index fae1d10b7..0ad3caa64 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
@@ -1656,7 +1656,7 @@ class BcelClassWeaver implements IClassWeaver {
ResolvedMember resolvedDooberry = world.resolve(declaredSig);
annotations = resolvedDooberry.getAnnotationTypes();
} else {
- ResolvedMember realthing = AjcMemberMaker.interMethodDispatcher(rm,memberHostType);
+ ResolvedMember realthing = AjcMemberMaker.interMethodDispatcher(rm.resolve(world),memberHostType);
ResolvedMember resolvedDooberry = world.resolve(realthing);
// AMC temp guard for M4
if (resolvedDooberry == null) {
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXConverter.java b/weaver/src/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXConverter.java
index 312280503..dbe499fd1 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXConverter.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXConverter.java
@@ -220,7 +220,11 @@ public class BcelGenericSignatureToTypeXConverter {
}
}
if (typeVarBounds == null) {
- throw new GenericSignatureFormatException("Undeclared type variable in signature: " + aTypeVarSig.typeVariableName);
+ // blowing up here breaks the situation with ITDs where the type variable is mentioned in the
+ // declaring type and used somewhere in the signature. Temporary change to allow it to return just a
+ // 'dumb' typevariablereference.
+ return new TypeVariableReferenceType(new TypeVariable(aTypeVarSig.typeVariableName),world);
+ // throw new GenericSignatureFormatException("Undeclared type variable in signature: " + aTypeVarSig.typeVariableName);
}
if (inProgressTypeVariableResolutions.containsKey(typeVarBounds)) {
return (ResolvedType) inProgressTypeVariableResolutions.get(typeVarBounds);
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
index 7250d0f2d..32a8d36d7 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
@@ -54,9 +54,11 @@ import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.ResolvedTypeMunger;
import org.aspectj.weaver.Shadow;
+import org.aspectj.weaver.TypeVariableReference;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.WeaverMessages;
import org.aspectj.weaver.WeaverStateInfo;
+import org.aspectj.weaver.World;
import org.aspectj.weaver.patterns.DeclareAnnotation;
import org.aspectj.weaver.patterns.Pointcut;
@@ -710,15 +712,18 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
}
private boolean mungeNewMethod(BcelClassWeaver weaver, NewMethodTypeMunger munger) {
- ResolvedMember unMangledInterMethod = munger.getSignature();
+ World w = weaver.getWorld();
+ // Resolving it will sort out the tvars
+ ResolvedMember unMangledInterMethod = munger.getSignature().resolve(w);
// do matching on the unMangled one, but actually add them to the mangled method
ResolvedMember interMethodBody = munger.getInterMethodBody(aspectType);
ResolvedMember interMethodDispatcher = munger.getInterMethodDispatcher(aspectType);
+ ResolvedMember memberHoldingAnyAnnotations = interMethodDispatcher;
+ ResolvedType onType = weaver.getWorld().resolve(unMangledInterMethod.getDeclaringType(),munger.getSourceLocation());
LazyClassGen gen = weaver.getLazyClassGen();
boolean mungingInterface = gen.isInterface();
- ResolvedType onType = weaver.getWorld().resolve(unMangledInterMethod.getDeclaringType(),munger.getSourceLocation());
if (onType.isRawType()) onType = onType.getGenericType();
boolean onInterface = onType.isInterface();
@@ -758,9 +763,9 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
AnnotationX annotationsOnRealMember[] = null;
ResolvedType toLookOn = aspectType;
if (aspectType.isRawType()) toLookOn = aspectType.getGenericType();
- ResolvedMember realMember = getRealMemberForITDFromAspect(toLookOn,interMethodDispatcher);
+ ResolvedMember realMember = getRealMemberForITDFromAspect(toLookOn,memberHoldingAnyAnnotations,false);
if (realMember==null) throw new BCException("Couldn't find ITD holder member '"+
- interMethodDispatcher+"' on aspect "+aspectType);
+ memberHoldingAnyAnnotations+"' on aspect "+aspectType);
annotationsOnRealMember = realMember.getAnnotations();
if (annotationsOnRealMember!=null) {
@@ -878,7 +883,13 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
}
}
- private ResolvedMember getRealMemberForITDFromAspect(ResolvedType aspectType,ResolvedMember lookingFor) {
+ private ResolvedMember getRealMemberForITDFromAspect(ResolvedType aspectType,ResolvedMember lookingFor,boolean isCtorRelated) {
+ World world = aspectType.getWorld();
+ boolean debug = false;
+ if (debug) {
+ System.err.println("Searching for a member on type: "+aspectType);
+ System.err.println("Member we are looking for: "+lookingFor);
+ }
ResolvedMember aspectMethods[] = aspectType.getDeclaredMethods();
UnresolvedType [] lookingForParams = lookingFor.getParameterTypes();
@@ -886,21 +897,39 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
for (int i = 0; realMember==null && i < aspectMethods.length; i++) {
ResolvedMember member = aspectMethods[i];
if (member.getName().equals(lookingFor.getName())){
- UnresolvedType [] memberParams = member.getParameterTypes();
+ UnresolvedType [] memberParams = member.getGenericParameterTypes();
if (memberParams.length == lookingForParams.length){
+ if (debug) System.err.println("Reviewing potential candidates: "+member);
boolean matchOK = true;
- for (int j = 0; j < memberParams.length && matchOK; j++){
- UnresolvedType memberParam = memberParams[j];
- UnresolvedType lookingForParam = lookingForParams[j].resolve(aspectType.getWorld());
- if (lookingForParam.isTypeVariableReference()) lookingForParam = lookingForParam.getUpperBound();
- if (!memberParam.equals(lookingForParam)){
+ // If not related to a ctor ITD then the name is enough to confirm we have the
+ // right one. If it is ctor related we need to check the params all match, although
+ // only the erasure.
+ if (isCtorRelated) {
+ for (int j = 0; j < memberParams.length && matchOK; j++){
+ ResolvedType pMember = memberParams[j].resolve(world);
+ ResolvedType pLookingFor = lookingForParams[j].resolve(world);
+
+ if (pMember.isTypeVariableReference())
+ pMember = ((TypeVariableReference)pMember).getTypeVariable().getFirstBound().resolve(world);
+ if (pMember.isParameterizedType() || pMember.isGenericType())
+ pMember = pMember.getRawType().resolve(aspectType.getWorld());
+
+ if (pLookingFor.isTypeVariableReference())
+ pLookingFor = ((TypeVariableReference)pLookingFor).getTypeVariable().getFirstBound().resolve(world);
+ if (pLookingFor.isParameterizedType() || pLookingFor.isGenericType())
+ pLookingFor = pLookingFor.getRawType().resolve(world);
+
+ if (debug) System.err.println("Comparing parameter "+j+" member="+pMember+" lookingFor="+pLookingFor);
+ if (!pMember.equals(pLookingFor)){
matchOK=false;
}
+ }
}
if (matchOK) realMember = member;
}
}
}
+ if (debug && realMember==null) System.err.println("Didn't find a match");
return realMember;
}
@@ -981,7 +1010,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
ResolvedMember interMethodDispatcher =AjcMemberMaker.postIntroducedConstructor(aspectType,onType,newConstructorTypeMunger.getSignature().getParameterTypes());
AnnotationX annotationsOnRealMember[] = null;
- ResolvedMember realMember = getRealMemberForITDFromAspect(aspectType,interMethodDispatcher);
+ ResolvedMember realMember = getRealMemberForITDFromAspect(aspectType,interMethodDispatcher,true);
if (realMember==null) throw new BCException("Couldn't find ITD holder member '"+
interMethodDispatcher+"' on aspect "+aspectType);
annotationsOnRealMember = realMember.getAnnotations();
@@ -1159,7 +1188,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
// the below line just gets the method with the same name in aspectType.getDeclaredMethods();
ResolvedType toLookOn = aspectType;
if (aspectType.isRawType()) toLookOn = aspectType.getGenericType();
- ResolvedMember realMember = getRealMemberForITDFromAspect(toLookOn,interMethodBody);
+ ResolvedMember realMember = getRealMemberForITDFromAspect(toLookOn,interMethodBody,false);
if (realMember==null) throw new BCException("Couldn't find ITD init member '"+
interMethodBody+"' on aspect "+aspectType);
annotationsOnRealMember = realMember.getAnnotations();
diff --git a/weaver/testdata/dummyAspect.jar b/weaver/testdata/dummyAspect.jar
index 22dccf292..2f4662864 100644
--- a/weaver/testdata/dummyAspect.jar
+++ b/weaver/testdata/dummyAspect.jar
Binary files differ
diff --git a/weaver/testdata/ltw-acaspects.jar b/weaver/testdata/ltw-acaspects.jar
index d637f7e9e..357f924ce 100644
--- a/weaver/testdata/ltw-acaspects.jar
+++ b/weaver/testdata/ltw-acaspects.jar
Binary files differ
diff --git a/weaver/testdata/ltw-aspects.jar b/weaver/testdata/ltw-aspects.jar
index 5a6a924a0..9ec31adc7 100644
--- a/weaver/testdata/ltw-aspects.jar
+++ b/weaver/testdata/ltw-aspects.jar
Binary files differ
diff --git a/weaver/testdata/ltw-classes.jar b/weaver/testdata/ltw-classes.jar
index de87ac21f..029ad0c5d 100644
--- a/weaver/testdata/ltw-classes.jar
+++ b/weaver/testdata/ltw-classes.jar
Binary files differ
diff --git a/weaver/testdata/ltw-deaspects.jar b/weaver/testdata/ltw-deaspects.jar
index 39e0903ce..4d3908db0 100644
--- a/weaver/testdata/ltw-deaspects.jar
+++ b/weaver/testdata/ltw-deaspects.jar
Binary files differ
diff --git a/weaver/testdata/ltw-dwaspects.jar b/weaver/testdata/ltw-dwaspects.jar
index 278379033..fe86800bc 100644
--- a/weaver/testdata/ltw-dwaspects.jar
+++ b/weaver/testdata/ltw-dwaspects.jar
Binary files differ
diff --git a/weaver/testdata/ltw-itdaspects.jar b/weaver/testdata/ltw-itdaspects.jar
index ac8abfcf6..ce3fff669 100644
--- a/weaver/testdata/ltw-itdaspects.jar
+++ b/weaver/testdata/ltw-itdaspects.jar
Binary files differ
diff --git a/weaver/testdata/ltw-peraspects.jar b/weaver/testdata/ltw-peraspects.jar
index 3214321fb..84c8b473b 100644
--- a/weaver/testdata/ltw-peraspects.jar
+++ b/weaver/testdata/ltw-peraspects.jar
Binary files differ
diff --git a/weaver/testdata/ltw-woven.jar b/weaver/testdata/ltw-woven.jar
index 15cb0ec85..d2b4c54b2 100644
--- a/weaver/testdata/ltw-woven.jar
+++ b/weaver/testdata/ltw-woven.jar
Binary files differ
diff --git a/weaver/testdata/megatrace.jar b/weaver/testdata/megatrace.jar
index ea05f8ab5..2887da72e 100644
--- a/weaver/testdata/megatrace.jar
+++ b/weaver/testdata/megatrace.jar
Binary files differ
diff --git a/weaver/testdata/megatrace0easy.jar b/weaver/testdata/megatrace0easy.jar
index 68085fae7..42cbb2bac 100644
--- a/weaver/testdata/megatrace0easy.jar
+++ b/weaver/testdata/megatrace0easy.jar
Binary files differ
diff --git a/weaver/testdata/megatrace0hard.jar b/weaver/testdata/megatrace0hard.jar
index 08b449bba..94dfd4e98 100644
--- a/weaver/testdata/megatrace0hard.jar
+++ b/weaver/testdata/megatrace0hard.jar
Binary files differ
diff --git a/weaver/testdata/megatraceNoweave.jar b/weaver/testdata/megatraceNoweave.jar
index e0e5a5e87..9ccb03be4 100644
--- a/weaver/testdata/megatraceNoweave.jar
+++ b/weaver/testdata/megatraceNoweave.jar
Binary files differ
diff --git a/weaver/testdata/tracing.jar b/weaver/testdata/tracing.jar
index 46aeb0b70..6afb051f0 100644
--- a/weaver/testdata/tracing.jar
+++ b/weaver/testdata/tracing.jar
Binary files differ