aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.matcher
diff options
context:
space:
mode:
authorAndy Clement <andrew.clement@gmail.com>2012-08-17 14:31:53 -0700
committerAndy Clement <andrew.clement@gmail.com>2012-08-17 14:31:53 -0700
commitd0c81b74d7c2254cea2b8820a1cabda158978e83 (patch)
tree72a7116e3266c8949543d2657e28466b15305b08 /org.aspectj.matcher
parent993cef1c34849b5a3c92f5ddf4839ccf9047da77 (diff)
downloadaspectj-d0c81b74d7c2254cea2b8820a1cabda158978e83.tar.gz
aspectj-d0c81b74d7c2254cea2b8820a1cabda158978e83.zip
73507 - it'd fields on interfaces no longer get mangled names by default
Diffstat (limited to 'org.aspectj.matcher')
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java11
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java61
2 files changed, 58 insertions, 14 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java b/org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
index 8874dcd03..249e19bbb 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
@@ -485,10 +485,15 @@ public class AjcMemberMaker {
/**
* This field goes on top-most implementers of the interface the field is declared onto
*/
- public static ResolvedMember interFieldInterfaceField(ResolvedMember field, UnresolvedType onClass, UnresolvedType aspectType) {
+ public static ResolvedMember interFieldInterfaceField(ResolvedMember field, UnresolvedType onClass, UnresolvedType aspectType, boolean newStyle) {
+ String name = null;
+ if (newStyle) {
+ name = field.getName();
+ } else {
+ name = NameMangler.interFieldInterfaceField(aspectType, field.getDeclaringType(), field.getName());
+ }
return new ResolvedMemberImpl(Member.FIELD, onClass, makePublicNonFinal(field.getModifiers()), field.getReturnType(),
- NameMangler.interFieldInterfaceField(aspectType, field.getDeclaringType(), field.getName()), UnresolvedType.NONE,
- UnresolvedType.NONE);
+ name, UnresolvedType.NONE, UnresolvedType.NONE);
}
/**
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
index a87a69871..366f16b1a 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
@@ -661,21 +661,34 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
return false;
}
-
public static boolean conflictingSignature(Member m1, Member m2) {
+ return conflictingSignature(m1,m2,true);
+ }
+
+ /**
+ * Do the two members conflict? Due to the change in 1.7.1, field itds on interfaces now act like 'default' fields - so types implementing
+ * those fields get the field if they don't have it already, otherwise they keep what they have. The conflict detection below had to be
+ * altered. Previously (<1.7.1) it is not a conflict if the declaring types are different. With v2itds it may still be a conflict if the
+ * declaring types are different.
+ */
+ public static boolean conflictingSignature(Member m1, Member m2, boolean v2itds) {
if (m1 == null || m2 == null) {
return false;
}
-
if (!m1.getName().equals(m2.getName())) {
return false;
}
if (m1.getKind() != m2.getKind()) {
return false;
}
-
if (m1.getKind() == Member.FIELD) {
- return m1.getDeclaringType().equals(m2.getDeclaringType());
+ if (v2itds) {
+ if (m1.getDeclaringType().equals(m2.getDeclaringType())) {
+ return true;
+ }
+ } else {
+ return m1.getDeclaringType().equals(m2.getDeclaringType());
+ }
} else if (m1.getKind() == Member.POINTCUT) {
return true;
}
@@ -1735,12 +1748,15 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
}
}
+ boolean needsAdding =true;
+ boolean needsToBeAddedEarlier =false;
// now compare to existingMungers
for (Iterator<ConcreteTypeMunger> i = interTypeMungers.iterator(); i.hasNext();) {
ConcreteTypeMunger existingMunger = i.next();
- if (conflictingSignature(existingMunger.getSignature(), munger.getSignature())) {
- // System.err.println("match " + munger + " with " +
- // existingMunger);
+ boolean v2itds = munger.getSignature().getKind()== Member.FIELD && (munger.getMunger() instanceof NewFieldTypeMunger) && ((NewFieldTypeMunger)munger.getMunger()).version==NewFieldTypeMunger.VersionTwo;
+
+ if (conflictingSignature(existingMunger.getSignature(), munger.getSignature(),v2itds)) {
+ // System.err.println("match " + munger + " with " + existingMunger);
if (isVisible(munger.getSignature().getModifiers(), munger.getAspectType(), existingMunger.getAspectType())) {
// System.err.println(" is visible");
int c = compareMemberPrecedence(sig, existingMunger.getSignature());
@@ -1751,11 +1767,23 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
if (c < 0) {
// the existing munger dominates the new munger
checkLegalOverride(munger.getSignature(), existingMunger.getSignature(), 0x11, null);
- return;
+ needsAdding = false;
+ if (munger.getSignature().getKind()== Member.FIELD && munger.getSignature().getDeclaringType().resolve(world).isInterface() && ((NewFieldTypeMunger)munger.getMunger()).version==NewFieldTypeMunger.VersionTwo) {
+ // still need to add it
+ needsAdding=true;
+ }
+ break;
} else if (c > 0) {
// the new munger dominates the existing one
checkLegalOverride(existingMunger.getSignature(), munger.getSignature(), 0x11, null);
- i.remove();
+// i.remove();
+ if (existingMunger.getSignature().getKind()==Member.FIELD &&
+ existingMunger.getSignature().getDeclaringType().resolve(world).isInterface()
+ && ((NewFieldTypeMunger)existingMunger.getMunger()).version==NewFieldTypeMunger.VersionTwo) {
+ needsToBeAddedEarlier=true;
+ } else {
+ i.remove();
+ }
break;
} else {
interTypeConflictError(munger, existingMunger);
@@ -1769,7 +1797,13 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
// we are adding the parameterized form of the ITD to the list of
// mungers. Within it, the munger knows the original declared
// signature for the ITD so it can be retrieved.
- interTypeMungers.add(munger);
+ if (needsAdding) {
+ if (!needsToBeAddedEarlier) {
+ interTypeMungers.add(munger);
+ } else {
+ interTypeMungers.add(0,munger);
+ }
+ }
}
/**
@@ -1802,13 +1836,18 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
// sig = ctm.getSignature(); // possible sig change when type parameters
// filled in
// }
+ ResolvedTypeMunger rtm = typeTransformer.getMunger();
+ boolean v2itds = true;
+ if (rtm instanceof NewFieldTypeMunger && ((NewFieldTypeMunger)rtm).version==NewFieldTypeMunger.VersionOne) {
+ v2itds = false;
+ }
while (existingMembers.hasNext()) {
ResolvedMember existingMember = existingMembers.next();
// don't worry about clashing with bridge methods
if (existingMember.isBridgeMethod()) {
continue;
}
- if (conflictingSignature(existingMember, typeTransformerSignature)) {
+ if (conflictingSignature(existingMember, typeTransformerSignature,v2itds)) {
// System.err.println("conflict: existingMember=" +
// existingMember + " typeMunger=" + munger);
// System.err.println(munger.getSourceLocation() + ", " +