aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2008-06-04 17:55:21 +0000
committeraclement <aclement>2008-06-04 17:55:21 +0000
commitd9767a2dbe6c6a32c58fd547128a5b53f40b5b6a (patch)
tree7bcf6d17ffcfcdd98abb29a973fca5dec3c60216
parent4f91c7ee4bb1bec78360e3c851d68202edd69c49 (diff)
downloadaspectj-d9767a2dbe6c6a32c58fd547128a5b53f40b5b6a.tar.gz
aspectj-d9767a2dbe6c6a32c58fd547128a5b53f40b5b6a.zip
231396: refactoring AspectJ: moving stuff around in the Member hierarchy
-rw-r--r--weaver/src/org/aspectj/weaver/Member.java28
-rw-r--r--weaver/src/org/aspectj/weaver/MemberImpl.java52
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedMember.java4
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java23
4 files changed, 38 insertions, 69 deletions
diff --git a/weaver/src/org/aspectj/weaver/Member.java b/weaver/src/org/aspectj/weaver/Member.java
index a29ccd505..a911722f7 100644
--- a/weaver/src/org/aspectj/weaver/Member.java
+++ b/weaver/src/org/aspectj/weaver/Member.java
@@ -16,7 +16,7 @@ package org.aspectj.weaver;
import java.util.Collection;
import java.util.Iterator;
-public interface Member {
+public interface Member extends Comparable {
public static final Member[] NONE = new Member[0];
public static final MemberKind METHOD = new MemberKind("METHOD", 1);
@@ -36,7 +36,7 @@ public interface Member {
public ResolvedMember resolve(World world);
- public int compareTo(Object other);
+ public int compareTo(Object other);
public String toLongString();
@@ -53,10 +53,6 @@ public interface Member {
public UnresolvedType[] getParameterTypes();
- public AnnotationX[][] getParameterAnnotations();
- public ResolvedType[][] getParameterAnnotationTypes();
-
- public String getAnnotationDefaultValue();
/**
* Return full signature, including return type, e.g. "()LFastCar;" for a signature without the return type,
@@ -83,7 +79,6 @@ public interface Member {
public int getModifiers();
- public UnresolvedType[] getExceptions(World world);
public boolean isStatic();
@@ -101,28 +96,19 @@ public interface Member {
public String getExtractableName();
- /**
- * If you want a sensible answer, resolve the member and call
- * hasAnnotation() on the ResolvedMember.
- */
- public boolean hasAnnotation(UnresolvedType ofType);
-
- /* (non-Javadoc)
- * @see org.aspectj.weaver.AnnotatedElement#getAnnotationTypes()
- */
- public ResolvedType[] getAnnotationTypes();
-
- public AnnotationX[] getAnnotations();
-
- public Collection/*ResolvedType*/getDeclaringTypes(World world);
+ public AnnotationX[] getAnnotations();
// ---- reflective thisJoinPoint stuff
public String getSignatureMakerName();
public String getSignatureType();
+
+ public Collection/* ResolvedType */getDeclaringTypes(World world);
+
public String getSignatureString(World world);
public String[] getParameterNames(World world);
+ public UnresolvedType[] getExceptions(World world);
} \ No newline at end of file
diff --git a/weaver/src/org/aspectj/weaver/MemberImpl.java b/weaver/src/org/aspectj/weaver/MemberImpl.java
index f56871b49..f88444d0d 100644
--- a/weaver/src/org/aspectj/weaver/MemberImpl.java
+++ b/weaver/src/org/aspectj/weaver/MemberImpl.java
@@ -21,7 +21,7 @@ import java.util.Iterator;
import java.util.List;
-public class MemberImpl implements Comparable, AnnotatedElement,Member {
+public class MemberImpl implements Member {
protected MemberKind kind;
protected String name;
@@ -91,13 +91,10 @@ public class MemberImpl implements Comparable, AnnotatedElement,Member {
}
}
- /* (non-Javadoc)
- * @see org.aspectj.weaver.Member#resolve(org.aspectj.weaver.World)
- */
public ResolvedMember resolve(World world) {
return world.resolve(this);
}
-
+
// ---- utility methods
/** returns an Object[] pair of UnresolvedType, UnresolvedType[] representing return type,
@@ -303,17 +300,15 @@ public class MemberImpl implements Comparable, AnnotatedElement,Member {
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 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());
@@ -383,19 +378,7 @@ public class MemberImpl implements Comparable, AnnotatedElement,Member {
*/
public UnresolvedType[] getParameterTypes() { return parameterTypes; }
- public AnnotationX[][] getParameterAnnotations() {
- throw new UnsupportedOperationException("You should resolve this member and call getParameterAnnotations() on the result...");
- }
- public ResolvedType[][] getParameterAnnotationTypes() {
- throw new UnsupportedOperationException("You should resolve this member and call getParameterAnnotationTypes() on the result...");
- }
- public String getAnnotationDefaultValue() {
- throw new UnsupportedOperationException("You should resolve this member and call getAnnotationDefaultValue() on the result...");
- }
- /* (non-Javadoc)
- * @see org.aspectj.weaver.Member#getSignature()
- */
public String getSignature() { return signature; }
public int getArity() { return parameterTypes.length; }
@@ -530,21 +513,6 @@ public class MemberImpl implements Comparable, AnnotatedElement,Member {
else return name;
}
- /* (non-Javadoc)
- * @see org.aspectj.weaver.Member#hasAnnotation(org.aspectj.weaver.UnresolvedType)
- */
- // OPTIMIZE dont have these here, move them down to ResolvedMember
- public boolean hasAnnotation(UnresolvedType ofType) {
- throw new UnsupportedOperationException("You should resolve this member and call hasAnnotation() on the result...");
- }
-
- public ResolvedType[] getAnnotationTypes() {
- throw new UnsupportedOperationException("You should resolve this member and call hasAnnotation() on the result...");
- }
-
- public AnnotationX getAnnotationOfType(UnresolvedType ofType) {
- throw new UnsupportedOperationException("You should resolve this member and call getAnnotationOfType() on the result...");
- }
/* (non-Javadoc)
* @see org.aspectj.weaver.Member#getAnnotations()
diff --git a/weaver/src/org/aspectj/weaver/ResolvedMember.java b/weaver/src/org/aspectj/weaver/ResolvedMember.java
index 057762d66..b3a23e0a8 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedMember.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedMember.java
@@ -60,6 +60,10 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe
public String[] getParameterNames();
public void setParameterNames(String[] names);
+ public AnnotationX[][] getParameterAnnotations();
+ public ResolvedType[][] getParameterAnnotationTypes();
+ public String getAnnotationDefaultValue();
+
public String[] getParameterNames(World world);
public AjAttribute.EffectiveSignatureAttribute getEffectiveSignature();
diff --git a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java
index d40f00053..a4db3746f 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java
@@ -308,7 +308,11 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
if (annotationTypes == null) return null;
return (ResolvedType[])annotationTypes.toArray(new ResolvedType[]{});
}
-
+
+ public String getAnnotationDefaultValue() {
+ throw new UnsupportedOperationException("You should resolve this member and call getAnnotationDefaultValue() on the result...");
+ }
+
public AnnotationX[] getAnnotations() {
if (backingGenericMember != null) return backingGenericMember.getAnnotations();
return super.getAnnotations();
@@ -327,12 +331,14 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
return parameterAnnotationTypes;
}
- public AnnotationX[][] getParameterAnnotations() {
- if (backingGenericMember != null) return backingGenericMember.getParameterAnnotations();
- return super.getParameterAnnotations();
+
+ public AnnotationX[][] getParameterAnnotations() {
+ if (backingGenericMember != null) return backingGenericMember.getParameterAnnotations();
+ throw new BCException("Cannot return parameter annotations for a " + this.getClass().getName() + " member");
+// return super.getParameterAnnotations();
}
-
- public void addAnnotation(AnnotationX annotation) {
+
+ public void addAnnotation(AnnotationX annotation) {
// FIXME asc only allows for annotation types, not instances - should it?
if (annotationTypes == null) annotationTypes = new HashSet();
annotationTypes.add(annotation.getSignature());
@@ -472,6 +478,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
+ // OPTIMIZE dont like how resolve(world) on ResolvedMemberImpl does something different to world.resolve(member)
public ResolvedMember resolve(World world) {
// make sure all the pieces of a resolvedmember really are resolved
try {
@@ -1040,5 +1047,9 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
}
public void evictWeavingState() { }
+
+ public AnnotationX getAnnotationOfType(UnresolvedType ofType) {
+ throw new UnsupportedOperationException("You should resolve this member and call getAnnotationOfType() on the result...");
+ }
}