summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2006-03-07 16:08:34 +0000
committeraclement <aclement>2006-03-07 16:08:34 +0000
commitecfdab0ddc577d043fc5e471ea55469fe488aa9b (patch)
treecdadce76d51dddc11d75343445a318cd640e0e8b
parent7808f3c29e34fe462c2f248d00727bbbc25fde2c (diff)
downloadaspectj-ecfdab0ddc577d043fc5e471ea55469fe488aa9b.tar.gz
aspectj-ecfdab0ddc577d043fc5e471ea55469fe488aa9b.zip
129163: more bits...: equals in the type munger hierarchy
-rw-r--r--weaver/src/org/aspectj/weaver/Advice.java24
-rw-r--r--weaver/src/org/aspectj/weaver/AnnotationOnTypeMunger.java17
-rw-r--r--weaver/src/org/aspectj/weaver/MemberImpl.java39
-rw-r--r--weaver/src/org/aspectj/weaver/MethodDelegateTypeMunger.java34
-rw-r--r--weaver/src/org/aspectj/weaver/NewConstructorTypeMunger.java22
-rw-r--r--weaver/src/org/aspectj/weaver/NewFieldTypeMunger.java18
-rw-r--r--weaver/src/org/aspectj/weaver/NewMethodTypeMunger.java17
-rw-r--r--weaver/src/org/aspectj/weaver/NewParentTypeMunger.java16
-rw-r--r--weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java20
-rw-r--r--weaver/src/org/aspectj/weaver/PerTypeWithinTargetTypeMunger.java18
-rw-r--r--weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java18
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java19
12 files changed, 232 insertions, 30 deletions
diff --git a/weaver/src/org/aspectj/weaver/Advice.java b/weaver/src/org/aspectj/weaver/Advice.java
index 4f663de6a..38e0d9c88 100644
--- a/weaver/src/org/aspectj/weaver/Advice.java
+++ b/weaver/src/org/aspectj/weaver/Advice.java
@@ -240,6 +240,8 @@ public abstract class Advice extends ShadowMunger {
// only called as part of parameterization....
public void setSignature(Member signature) {
this.signature = signature;
+ // reset hashCode value so it can be recalculated next time
+ hashCode = 0;
}
public boolean hasExtraParameter() {
@@ -366,22 +368,26 @@ public abstract class Advice extends ShadowMunger {
// + signature
// + ")";
}
+
+ // XXX this perhaps ought to take account of the other fields in advice ...
public boolean equals(Object other) {
if (! (other instanceof Advice)) return false;
Advice o = (Advice) other;
- return o.attribute.equals(attribute)
- && o.pointcut.equals(pointcut)
- && o.signature.equals(signature);
+ return o.kind.equals(kind)
+ && ((o.pointcut == null) ? (pointcut == null) : o.pointcut.equals(pointcut))
+ && ((o.signature == null) ? (signature == null) : o.signature.equals(signature));
+
}
- private volatile int hashCode = 0;
+
+ private volatile int hashCode = 0;
public int hashCode() {
- if (hashCode == 0) {
+ if (hashCode == 0) {
int result = 17;
result = 37*result + kind.hashCode();
- result = 37*result + pointcut.hashCode();
- if (signature != null) result = 37*result + signature.hashCode();
- hashCode = result;
- }
+ result = 37*result + ((pointcut == null) ? 0 : pointcut.hashCode());
+ result = 37*result + ((signature == null) ? 0 : signature.hashCode());
+ hashCode = result;
+ }
return hashCode;
}
diff --git a/weaver/src/org/aspectj/weaver/AnnotationOnTypeMunger.java b/weaver/src/org/aspectj/weaver/AnnotationOnTypeMunger.java
index f12e98d63..2860810ac 100644
--- a/weaver/src/org/aspectj/weaver/AnnotationOnTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/AnnotationOnTypeMunger.java
@@ -35,4 +35,21 @@ public class AnnotationOnTypeMunger extends ResolvedTypeMunger {
public AnnotationX getNewAnnotation() {
return newAnnotation;
}
+
+ public boolean equals(Object other) {
+ if (!(other instanceof AnnotationOnTypeMunger)) return false;
+ AnnotationOnTypeMunger o = (AnnotationOnTypeMunger)other;
+ return newAnnotation.getSignature().equals(o.newAnnotation.getSignature());
+ }
+
+ private volatile int hashCode = 0;
+ public int hashCode() {
+ if (hashCode == 0) {
+ int result = 17;
+ result = 37*result + newAnnotation.getSignature().hashCode();
+ hashCode = result;
+ }
+ return hashCode;
+ }
+
}
diff --git a/weaver/src/org/aspectj/weaver/MemberImpl.java b/weaver/src/org/aspectj/weaver/MemberImpl.java
index 039210378..fc118f42c 100644
--- a/weaver/src/org/aspectj/weaver/MemberImpl.java
+++ b/weaver/src/org/aspectj/weaver/MemberImpl.java
@@ -365,22 +365,10 @@ public class MemberImpl implements Comparable, AnnotatedElement,Member {
public boolean equals(Object other) {
if (! (other instanceof Member)) return false;
Member o = (Member) other;
-
- return (kind == o.getKind()
- && name.equals(o.getName())
- && signature.equals(o.getSignature())
- && declaringType.equals(o.getDeclaringType()));
- }
-
- /* (non-Javadoc)
- * @see org.aspectj.weaver.Member#compareTo(java.lang.Object)
- */
- public int compareTo(Object other) {
- Member o = (Member) other;
-
- int i = getName().compareTo(o.getName());
- if (i != 0) return i;
- return getSignature().compareTo(o.getSignature());
+ return (getKind() == o.getKind()
+ && getName().equals(o.getName())
+ && getSignature().equals(o.getSignature())
+ && getDeclaringType().equals(o.getDeclaringType()));
}
/**
@@ -392,15 +380,26 @@ public class MemberImpl implements Comparable, AnnotatedElement,Member {
public int hashCode() {
if (hashCode == 0) {
int result = 17;
- result = 37*result + kind.hashCode();
- result = 37*result + name.hashCode();
- result = 37*result + signature.hashCode();
- result = 37*result + declaringType.hashCode();
+ result = 37*result + getKind().hashCode();
+ result = 37*result + getName().hashCode();
+ result = 37*result + getSignature().hashCode();
+ result = 37*result + getDeclaringType().hashCode();
hashCode = result;
}
return hashCode;
}
+ /* (non-Javadoc)
+ * @see org.aspectj.weaver.Member#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object other) {
+ Member o = (Member) other;
+
+ int i = getName().compareTo(o.getName());
+ if (i != 0) return i;
+ return getSignature().compareTo(o.getSignature());
+ }
+
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append(returnType.getName());
diff --git a/weaver/src/org/aspectj/weaver/MethodDelegateTypeMunger.java b/weaver/src/org/aspectj/weaver/MethodDelegateTypeMunger.java
index fbfccd606..3ecac9882 100644
--- a/weaver/src/org/aspectj/weaver/MethodDelegateTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/MethodDelegateTypeMunger.java
@@ -55,6 +55,26 @@ public class MethodDelegateTypeMunger extends ResolvedTypeMunger {
this.implClassName = implClassName;
}
+ public boolean equals(Object other) {
+ if (!(other instanceof MethodDelegateTypeMunger)) return false;
+ MethodDelegateTypeMunger o = (MethodDelegateTypeMunger)other;
+ return ((o.aspect == null) ? (aspect == null ) : aspect.equals(o.aspect))
+ && ((o.typePattern == null) ? (typePattern == null ) : typePattern.equals(o.typePattern))
+ && ((o.implClassName == null) ? (implClassName == null) : implClassName.equals(o.implClassName));
+ }
+
+ private volatile int hashCode = 0;
+ public int hashCode() {
+ if (hashCode == 0) {
+ int result = 17;
+ result = 37*result + ((aspect == null) ? 0 : aspect.hashCode());
+ result = 37*result + ((typePattern == null) ? 0 : typePattern.hashCode());
+ result = 37*result + ((implClassName == null) ? 0 : implClassName.hashCode());
+ hashCode = result;
+ }
+ return hashCode;
+ }
+
public ResolvedMember getDelegate(ResolvedType targetType) {
return AjcMemberMaker.itdAtDeclareParentsField(
targetType,
@@ -130,6 +150,20 @@ public class MethodDelegateTypeMunger extends ResolvedTypeMunger {
this.typePattern = typePattern;
}
+ public boolean equals(Object other) {
+ if (!(other instanceof FieldHostTypeMunger)) return false;
+ FieldHostTypeMunger o = (FieldHostTypeMunger)other;
+ return ((o.aspect == null) ? (aspect == null ) : aspect.equals(o.aspect))
+ && ((o.typePattern == null) ? (typePattern == null ) : typePattern.equals(o.typePattern));
+ }
+
+ public int hashCode() {
+ int result = 17;
+ result = 37*result + ((aspect == null) ? 0 : aspect.hashCode());
+ result = 37*result + ((typePattern == null) ? 0 : typePattern.hashCode());
+ return result;
+ }
+
public void write(DataOutputStream s) throws IOException {
kind.write(s);
signature.write(s);
diff --git a/weaver/src/org/aspectj/weaver/NewConstructorTypeMunger.java b/weaver/src/org/aspectj/weaver/NewConstructorTypeMunger.java
index e1ed8fbe1..411b4d1f2 100644
--- a/weaver/src/org/aspectj/weaver/NewConstructorTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/NewConstructorTypeMunger.java
@@ -40,6 +40,26 @@ public class NewConstructorTypeMunger extends ResolvedTypeMunger {
}
+ public boolean equals(Object other) {
+ if (!(other instanceof NewConstructorTypeMunger)) return false;
+ NewConstructorTypeMunger o = (NewConstructorTypeMunger)other;
+ return ((o.syntheticConstructor == null) ? (syntheticConstructor == null )
+ : syntheticConstructor.equals(o.syntheticConstructor))
+ & ((o.explicitConstructor == null) ? (explicitConstructor == null )
+ : explicitConstructor.equals(o.explicitConstructor));
+ }
+
+ private volatile int hashCode = 0;
+ public int hashCode() {
+ if (hashCode == 0) {
+ int result = 17;
+ result = 37*result + ((syntheticConstructor == null) ? 0 : syntheticConstructor.hashCode());
+ result = 37*result + ((explicitConstructor == null) ? 0 : explicitConstructor.hashCode());
+ hashCode = result;
+ }
+ return hashCode;
+ }
+
// doesnt seem required....
// public ResolvedMember getDispatchMethod(UnresolvedType aspectType) {
// return AjcMemberMaker.interMethodBody(signature, aspectType);
@@ -78,6 +98,8 @@ public class NewConstructorTypeMunger extends ResolvedTypeMunger {
public void setExplicitConstructor(ResolvedMember explicitConstructor) {
this.explicitConstructor = explicitConstructor;
+ // reset hashCode so that its recalculated with new value
+ hashCode = 0;
}
public ResolvedMember getMatchingSyntheticMember(Member member, ResolvedType aspectType) {
diff --git a/weaver/src/org/aspectj/weaver/NewFieldTypeMunger.java b/weaver/src/org/aspectj/weaver/NewFieldTypeMunger.java
index c58493312..989fa476f 100644
--- a/weaver/src/org/aspectj/weaver/NewFieldTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/NewFieldTypeMunger.java
@@ -93,4 +93,22 @@ public class NewFieldTypeMunger extends ResolvedTypeMunger {
return nftm;
}
+ public boolean equals(Object other) {
+ if (! (other instanceof NewFieldTypeMunger)) return false;
+ NewFieldTypeMunger o = (NewFieldTypeMunger) other;
+ return kind.equals(o.kind)
+ && ((o.signature == null) ? (signature == null ) : signature.equals(o.signature))
+ && ((o.declaredSignature == null) ? (declaredSignature == null ) : declaredSignature.equals(o.declaredSignature))
+ && ((o.typeVariableAliases == null) ? (typeVariableAliases == null ) : typeVariableAliases.equals(o.typeVariableAliases));
+ }
+
+ public int hashCode() {
+ int result = 17;
+ result = 37*result + kind.hashCode();
+ result = 37*result + ((signature == null) ? 0 : signature.hashCode());
+ result = 37*result + ((declaredSignature == null) ? 0 : declaredSignature.hashCode());
+ result = 37*result + ((typeVariableAliases == null) ? 0 : typeVariableAliases.hashCode());
+ return result;
+ }
+
}
diff --git a/weaver/src/org/aspectj/weaver/NewMethodTypeMunger.java b/weaver/src/org/aspectj/weaver/NewMethodTypeMunger.java
index b08b70bb9..4febb7c95 100644
--- a/weaver/src/org/aspectj/weaver/NewMethodTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/NewMethodTypeMunger.java
@@ -110,5 +110,22 @@ public class NewMethodTypeMunger extends ResolvedTypeMunger {
return nmtm;
}
+ public boolean equals(Object other) {
+ if (! (other instanceof NewMethodTypeMunger)) return false;
+ NewMethodTypeMunger o = (NewMethodTypeMunger) other;
+ return kind.equals(o.kind)
+ && ((o.signature == null) ? (signature == null ) : signature.equals(o.signature))
+ && ((o.declaredSignature == null) ? (declaredSignature == null ) : declaredSignature.equals(o.declaredSignature))
+ && ((o.typeVariableAliases == null) ? (typeVariableAliases == null ) : typeVariableAliases.equals(o.typeVariableAliases));
+ }
+
+ public int hashCode() {
+ int result = 17;
+ result = 37*result + kind.hashCode();
+ result = 37*result + ((signature == null) ? 0 : signature.hashCode());
+ result = 37*result + ((declaredSignature == null) ? 0 : declaredSignature.hashCode());
+ result = 37*result + ((typeVariableAliases == null) ? 0 : typeVariableAliases.hashCode());
+ return result;
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/NewParentTypeMunger.java b/weaver/src/org/aspectj/weaver/NewParentTypeMunger.java
index 312a7538d..8e76e2245 100644
--- a/weaver/src/org/aspectj/weaver/NewParentTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/NewParentTypeMunger.java
@@ -33,5 +33,19 @@ public class NewParentTypeMunger extends ResolvedTypeMunger {
return newParent;
}
-
+ public boolean equals(Object other) {
+ if (! (other instanceof NewParentTypeMunger)) return false;
+ NewParentTypeMunger o = (NewParentTypeMunger) other;
+ return newParent.equals(o.newParent);
+ }
+
+ private volatile int hashCode = 0;
+ public int hashCode() {
+ if (hashCode == 0) {
+ int result = 17;
+ result = 37*result + newParent.hashCode();
+ hashCode = result;
+ }
+ return hashCode;
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java b/weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java
index 3c3e31509..6f473c749 100644
--- a/weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java
@@ -26,7 +26,25 @@ public class PerObjectInterfaceTypeMunger extends ResolvedTypeMunger {
private final UnresolvedType interfaceType;
private final Pointcut testPointcut;
private TypePattern lazyTestTypePattern;
+
+ public boolean equals(Object other) {
+ if (!(other instanceof PerObjectInterfaceTypeMunger)) return false;
+ PerObjectInterfaceTypeMunger o = (PerObjectInterfaceTypeMunger)other;
+ return ((o.testPointcut == null) ? (testPointcut == null ) : testPointcut.equals(o.testPointcut))
+ && ((o.lazyTestTypePattern == null) ? (lazyTestTypePattern == null ) : lazyTestTypePattern.equals(o.lazyTestTypePattern));
+ }
+ private volatile int hashCode = 0;
+ public int hashCode() {
+ if (hashCode == 0) {
+ int result = 17;
+ result = 37*result + ((testPointcut == null) ? 0 : testPointcut.hashCode());
+ result = 37*result + ((lazyTestTypePattern == null) ? 0 : lazyTestTypePattern.hashCode());
+ hashCode = result;
+ }
+ return hashCode;
+ }
+
public PerObjectInterfaceTypeMunger(UnresolvedType aspectType, Pointcut testPointcut) {
super(PerObjectInterface, null);
this.testPointcut = testPointcut;
@@ -44,6 +62,8 @@ public class PerObjectInterfaceTypeMunger extends ResolvedTypeMunger {
}
PerThisOrTargetPointcutVisitor v = new PerThisOrTargetPointcutVisitor(!isPerThis, aspectType);
lazyTestTypePattern = v.getPerTypePointcut(testPointcut);
+ // reset hashCode so that its recalculated with the new lazyTestTypePattern
+ hashCode = 0;
}
return lazyTestTypePattern;
}
diff --git a/weaver/src/org/aspectj/weaver/PerTypeWithinTargetTypeMunger.java b/weaver/src/org/aspectj/weaver/PerTypeWithinTargetTypeMunger.java
index 6fc52000a..04e3a3132 100644
--- a/weaver/src/org/aspectj/weaver/PerTypeWithinTargetTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/PerTypeWithinTargetTypeMunger.java
@@ -30,6 +30,24 @@ public class PerTypeWithinTargetTypeMunger extends ResolvedTypeMunger {
this.testPointcut = testPointcut;
}
+ public boolean equals(Object other) {
+ if (!(other instanceof PerTypeWithinTargetTypeMunger)) return false;
+ PerTypeWithinTargetTypeMunger o = (PerTypeWithinTargetTypeMunger)other;
+ return ((o.testPointcut == null) ? (testPointcut == null ) : testPointcut.equals(o.testPointcut))
+ && ((o.aspectType == null) ? (aspectType == null ) : aspectType.equals(o.aspectType));
+ }
+
+ private volatile int hashCode = 0;
+ public int hashCode() {
+ if (hashCode == 0) {
+ int result = 17;
+ result = 37*result + ((testPointcut == null) ? 0 : testPointcut.hashCode());
+ result = 37*result + ((aspectType == null) ? 0 : aspectType.hashCode());
+ hashCode = result;
+ }
+ return hashCode;
+ }
+
public void write(DataOutputStream s) throws IOException {
throw new RuntimeException("shouldn't be serialized");
}
diff --git a/weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java b/weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java
index b17850249..21c7a1fc2 100644
--- a/weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java
+++ b/weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java
@@ -45,4 +45,22 @@ public class PrivilegedAccessMunger extends ResolvedTypeMunger {
return null;
}
+ public boolean equals(Object other) {
+ if (! (other instanceof PrivilegedAccessMunger)) return false;
+ PrivilegedAccessMunger o = (PrivilegedAccessMunger) other;
+ return kind.equals(o.kind)
+ && ((o.signature == null) ? (signature == null ) : signature.equals(o.signature))
+ && ((o.declaredSignature == null) ? (declaredSignature == null ) : declaredSignature.equals(o.declaredSignature))
+ && ((o.typeVariableAliases == null) ? (typeVariableAliases == null ) : typeVariableAliases.equals(o.typeVariableAliases));
+ }
+
+ public int hashCode() {
+ int result = 17;
+ result = 37*result + kind.hashCode();
+ result = 37*result + ((signature == null) ? 0 : signature.hashCode());
+ result = 37*result + ((declaredSignature == null) ? 0 : declaredSignature.hashCode());
+ result = 37*result + ((typeVariableAliases == null) ? 0 : typeVariableAliases.hashCode());
+ return result;
+ }
+
}
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
index 156525993..5c4e918d8 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
@@ -1645,6 +1645,25 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
return munger.getTypeVariableAliases();
}
+ public boolean equals(Object other) {
+ if (! (other instanceof BcelTypeMunger)) return false;
+ BcelTypeMunger o = (BcelTypeMunger) other;
+ return ((o.getMunger() == null) ? (getMunger() == null) : o.getMunger().equals(getMunger()))
+ && ((o.getAspectType() == null) ? (getAspectType() == null) : o.getAspectType().equals(getAspectType()));
+ }
+
+ private volatile int hashCode = 0;
+ public int hashCode() {
+ if (hashCode == 0) {
+ int result = 17;
+ result = 37*result + ((getMunger() == null) ? 0 : getMunger().hashCode());
+ result = 37*result + ((getAspectType() == null) ? 0 : getAspectType().hashCode());
+ hashCode = result;
+ }
+ return hashCode;
+ }
+
+
/**
* Some type mungers are created purely to help with the implementation of shadow mungers.
* For example to support the cflow() pointcut we create a new cflow field in the aspect, and