]> source.dussan.org Git - aspectj.git/commitdiff
167197: Make array a subclass of referencetype and not resolvedtype
authoraclement <aclement>
Mon, 17 Mar 2008 17:03:13 +0000 (17:03 +0000)
committeraclement <aclement>
Mon, 17 Mar 2008 17:03:13 +0000 (17:03 +0000)
weaver/src/org/aspectj/weaver/ArrayReferenceType.java [new file with mode: 0644]
weaver/src/org/aspectj/weaver/ResolvedType.java
weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java
weaver/src/org/aspectj/weaver/World.java

diff --git a/weaver/src/org/aspectj/weaver/ArrayReferenceType.java b/weaver/src/org/aspectj/weaver/ArrayReferenceType.java
new file mode 100644 (file)
index 0000000..1b42e48
--- /dev/null
@@ -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;
+    }
+}
index 6399cb985de6a0b34b41ae80d4a6f1bb320c3063..c7009a7a63bb76efc643ce99d10bf93dd5e9df2c 100644 (file)
@@ -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);
     }
     
index 4f6e8234b27397e990d920b20b14ab7b12a0ca55..e81574f2cf00491667f269137911880540fa5f4c 100644 (file)
@@ -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;
        }
        
index 99b7c89e5939d33e2c2236563a420ed905fd7963..493aec9a0c483da444d7a0660fc1b6ae8afdd122 100644 (file)
@@ -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 {