aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authoraclement <aclement>2008-03-17 17:03:13 +0000
committeraclement <aclement>2008-03-17 17:03:13 +0000
commit2dc8002a98d373c0cf6082dfcbf8f83a11182f58 (patch)
tree473b7c683050f3c9541542dc7dec5f99507d613e /weaver
parentcf8e7d49370e4d8b9a52818be560f43fd91c0ff2 (diff)
downloadaspectj-2dc8002a98d373c0cf6082dfcbf8f83a11182f58.tar.gz
aspectj-2dc8002a98d373c0cf6082dfcbf8f83a11182f58.zip
167197: Make array a subclass of referencetype and not resolvedtype
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/ArrayReferenceType.java186
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedType.java2
-rw-r--r--weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java2
-rw-r--r--weaver/src/org/aspectj/weaver/World.java2
4 files changed, 189 insertions, 3 deletions
diff --git a/weaver/src/org/aspectj/weaver/ArrayReferenceType.java b/weaver/src/org/aspectj/weaver/ArrayReferenceType.java
new file mode 100644
index 000000000..1b42e4875
--- /dev/null
+++ b/weaver/src/org/aspectj/weaver/ArrayReferenceType.java
@@ -0,0 +1,186 @@
+/* *******************************************************************
+ * Copyright (c) 2008 Contributors
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement initial implementation
+ * ******************************************************************/
+package org.aspectj.weaver;
+
+import java.lang.reflect.Modifier;
+
+/**
+ * Represents a resolved array type
+ *
+ * @author Andy Clement
+ */
+public class ArrayReferenceType extends ReferenceType {
+
+ private ResolvedType componentType;
+
+
+ public ArrayReferenceType(String sig, String erasureSig, World world, ResolvedType componentType) {
+ super(sig, erasureSig, world);
+ this.componentType = componentType;
+ }
+
+ // These methods are from the original implementation when Array was a ResolvedType and not a ReferenceType
+
+ public final ResolvedMember[] getDeclaredFields() {
+ return ResolvedMember.NONE;
+ }
+
+ public final ResolvedMember[] getDeclaredMethods() {
+ // ??? should this return clone? Probably not...
+ // If it ever does, here is the code:
+ // ResolvedMember cloneMethod =
+ // new ResolvedMember(Member.METHOD,this,Modifier.PUBLIC,UnresolvedType.OBJECT,"clone",new UnresolvedType[]{});
+ // return new ResolvedMember[]{cloneMethod};
+ return ResolvedMember.NONE;
+ }
+
+ public final ResolvedType[] getDeclaredInterfaces() {
+ return new ResolvedType[] { world.getCoreType(CLONEABLE), world.getCoreType(SERIALIZABLE) };
+ }
+
+ public final ResolvedMember[] getDeclaredPointcuts() {
+ return ResolvedMember.NONE;
+ }
+
+ public boolean hasAnnotation(UnresolvedType ofType) {
+ return false;
+ }
+
+ public final ResolvedType getSuperclass() {
+ return world.getCoreType(OBJECT);
+ }
+
+ public final boolean isAssignableFrom(ResolvedType o) {
+ if (!o.isArray())
+ return false;
+ if (o.getComponentType().isPrimitiveType()) {
+ return o.equals(this);
+ } else {
+ return getComponentType().resolve(world).isAssignableFrom(o.getComponentType().resolve(world));
+ }
+ }
+
+ public boolean isAssignableFrom(ResolvedType o, boolean allowMissing) {
+ return isAssignableFrom(o);
+ }
+
+ public final boolean isCoerceableFrom(ResolvedType o) {
+ if (o.equals(UnresolvedType.OBJECT) || o.equals(UnresolvedType.SERIALIZABLE) || o.equals(UnresolvedType.CLONEABLE)) {
+ return true;
+ }
+ if (!o.isArray())
+ return false;
+ if (o.getComponentType().isPrimitiveType()) {
+ return o.equals(this);
+ } else {
+ return getComponentType().resolve(world).isCoerceableFrom(o.getComponentType().resolve(world));
+ }
+ }
+
+ public final int getModifiers() {
+ int mask = Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED;
+ return (componentType.getModifiers() & mask) | Modifier.FINAL;
+ }
+
+ public UnresolvedType getComponentType() {
+ return componentType;
+ }
+
+ public ResolvedType getResolvedComponentType() {
+ return componentType;
+ }
+
+ public ISourceContext getSourceContext() {
+ return getResolvedComponentType().getSourceContext();
+ }
+
+
+ // Methods overridden from ReferenceType follow
+
+ public TypeVariable[] getTypeVariables() {
+ if (this.typeVariables == null) {
+ this.typeVariables = componentType.getTypeVariables();
+ for (int i = 0; i < this.typeVariables.length; i++) {
+ this.typeVariables[i].resolve(world);
+ }
+ }
+ return this.typeVariables;
+ }
+
+ public boolean isAnnotation() {
+ return false;
+ }
+
+ public boolean isAnonymous() {
+ return false;
+ }
+
+ public boolean isAnnotationStyleAspect() {
+ return false;
+ }
+
+ public boolean isAspect() {
+ return false;
+ }
+
+ public boolean isPrimitiveType() {
+ return typeKind == TypeKind.PRIMITIVE;
+ }
+
+ public boolean isSimpleType() {
+ return typeKind == TypeKind.SIMPLE;
+ }
+
+ public boolean isRawType() {
+ return typeKind == TypeKind.RAW;
+ }
+
+ public boolean isGenericType() {
+ return typeKind == TypeKind.GENERIC;
+ }
+
+ public boolean isParameterizedType() {
+ return typeKind == TypeKind.PARAMETERIZED;
+ }
+
+ public boolean isTypeVariableReference() {
+ return typeKind == TypeKind.TYPE_VARIABLE;
+ }
+
+ public boolean isGenericWildcard() {
+ return typeKind == TypeKind.WILDCARD;
+ }
+
+ public boolean isEnum() {
+ return false;
+ }
+
+ public boolean isNested() {
+ return false;
+ }
+
+ public boolean isClass() {
+ return false;
+ }
+
+ public boolean canAnnotationTargetType() {
+ return false;
+ }
+
+ public AnnotationTargetKind[] getAnnotationTargetKinds() {
+ return null;
+ }
+
+ public boolean isAnnotationWithRuntimeRetention() {
+ return false;
+ }
+}
diff --git a/weaver/src/org/aspectj/weaver/ResolvedType.java b/weaver/src/org/aspectj/weaver/ResolvedType.java
index 6399cb985..c7009a7a6 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedType.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedType.java
@@ -848,7 +848,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
// ---- types
public static ResolvedType makeArray(ResolvedType type, int dim) {
if (dim == 0) return type;
- ResolvedType array = new Array("[" + type.getSignature(),"["+type.getErasureSignature(),type.getWorld(),type);
+ ResolvedType array = new ArrayReferenceType("[" + type.getSignature(),"["+type.getErasureSignature(),type.getWorld(),type);
return makeArray(array,dim-1);
}
diff --git a/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java b/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java
index 4f6e8234b..e81574f2c 100644
--- a/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java
+++ b/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java
@@ -70,7 +70,7 @@ public class TypeVariableReferenceType extends BoundedReferenceType implements T
public UnresolvedType parameterize(Map typeBindings) {
UnresolvedType ut = (UnresolvedType) typeBindings.get(getName());
- if (ut!=null) return ut;
+ if (ut!=null) return world.resolve(ut);
return this;
}
diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java
index 99b7c89e5..493aec9a0 100644
--- a/weaver/src/org/aspectj/weaver/World.java
+++ b/weaver/src/org/aspectj/weaver/World.java
@@ -271,7 +271,7 @@ public abstract class World implements Dump.INode {
if (ty.isArray()) {
ResolvedType componentType = resolve(ty.getComponentType(),allowMissing);
//String brackets = signature.substring(0,signature.lastIndexOf("[")+1);
- ret = new ResolvedType.Array(signature, "["+componentType.getErasureSignature(),
+ ret = new ArrayReferenceType(signature, "["+componentType.getErasureSignature(),
this,
componentType);
} else {