summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2005-11-28 15:52:50 +0000
committeraclement <aclement>2005-11-28 15:52:50 +0000
commit97b5f52b520f534ac712d1ce3cff7b6ed5cca14f (patch)
treebaf2baf03a91614aa20bc760bd54ecc0a05db633
parent340f99477cb028f696760f54ebaaf91f840d9eca (diff)
downloadaspectj-97b5f52b520f534ac712d1ce3cff7b6ed5cca14f.tar.gz
aspectj-97b5f52b520f534ac712d1ce3cff7b6ed5cca14f.zip
fixes for 118192
-rw-r--r--weaver/src/org/aspectj/weaver/UnresolvedType.java1
-rw-r--r--weaver/testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java88
-rw-r--r--weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java8
3 files changed, 93 insertions, 4 deletions
diff --git a/weaver/src/org/aspectj/weaver/UnresolvedType.java b/weaver/src/org/aspectj/weaver/UnresolvedType.java
index 1b8b62a93..360fd5085 100644
--- a/weaver/src/org/aspectj/weaver/UnresolvedType.java
+++ b/weaver/src/org/aspectj/weaver/UnresolvedType.java
@@ -187,6 +187,7 @@ public class UnresolvedType implements TypeVariableDeclaringElement {
public boolean isGenericWildcard() { return typeKind == TypeKind.WILDCARD; }
public boolean isExtends() { return isExtends;}
public boolean isSuper() { return isSuper; }
+ public TypeKind getTypekind() { return typeKind;}
// for any reference type, we can get some extra information...
public final boolean isArray() { return signature.startsWith("["); }
diff --git a/weaver/testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java b/weaver/testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java
index 26c34db9e..2a86a1c47 100644
--- a/weaver/testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java
+++ b/weaver/testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java
@@ -14,17 +14,17 @@ package org.aspectj.weaver.reflect;
import junit.framework.TestCase;
+import org.aspectj.weaver.ReferenceType;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.UnresolvedType;
+import org.aspectj.weaver.bcel.BcelWorld;
public class ReflectionBasedReferenceTypeDelegateTest extends TestCase {
protected ReflectionWorld world;
private ResolvedType objectType;
private ResolvedType classType;
- private ResolvedType enumType;
-
public void testIsAspect() {
assertFalse(objectType.isAspect());
@@ -173,6 +173,90 @@ public class ReflectionBasedReferenceTypeDelegateTest extends TestCase {
assertEquals(0,pointcuts.length);
}
+
+
+ public void testSerializableSuperclass() {
+ ResolvedType serializableType = world.resolve("java.io.Serializable");
+ ResolvedType superType = serializableType.getSuperclass();
+ assertTrue("Superclass of serializable should be Object but was "+superType,superType.equals(UnresolvedType.OBJECT));
+
+ BcelWorld bcelworld = new BcelWorld();
+ bcelworld.setBehaveInJava5Way(true);
+ ResolvedType bcelSupertype = bcelworld.resolve(UnresolvedType.SERIALIZABLE).getSuperclass();
+ assertTrue("Should be null but is "+bcelSupertype,bcelSupertype.equals(UnresolvedType.OBJECT));
+ }
+
+ public void testSubinterfaceSuperclass() {
+ ResolvedType ifaceType = world.resolve("java.security.Key");
+ ResolvedType superType = ifaceType.getSuperclass();
+ assertTrue("Superclass should be Object but was "+superType,superType.equals(UnresolvedType.OBJECT));
+
+ BcelWorld bcelworld = new BcelWorld();
+ bcelworld.setBehaveInJava5Way(true);
+ ResolvedType bcelSupertype = bcelworld.resolve("java.security.Key").getSuperclass();
+ assertTrue("Should be null but is "+bcelSupertype,bcelSupertype.equals(UnresolvedType.OBJECT));
+ }
+
+ public void testVoidSuperclass() {
+ ResolvedType voidType = world.resolve(Void.TYPE);
+ ResolvedType superType = voidType.getSuperclass();
+ assertNull(superType);
+
+ BcelWorld bcelworld = new BcelWorld();
+ bcelworld.setBehaveInJava5Way(true);
+ ResolvedType bcelSupertype = bcelworld.resolve("void").getSuperclass();
+ assertTrue("Should be null but is "+bcelSupertype,bcelSupertype==null);
+ }
+
+ public void testIntSuperclass() {
+ ResolvedType voidType = world.resolve(Integer.TYPE);
+ ResolvedType superType = voidType.getSuperclass();
+ assertNull(superType);
+
+ BcelWorld bcelworld = new BcelWorld();
+ bcelworld.setBehaveInJava5Way(true);
+ ResolvedType bcelSupertype = bcelworld.resolve("int").getSuperclass();
+ assertTrue("Should be null but is "+bcelSupertype,bcelSupertype==null);
+ }
+
+ public void testGenericInterfaceSuperclass_BcelWorldResolution() {
+ BcelWorld bcelworld = new BcelWorld();
+ bcelworld.setBehaveInJava5Way(true);
+
+ UnresolvedType javaUtilMap = UnresolvedType.forName("java.util.Map");
+
+ ReferenceType rawType = (ReferenceType) bcelworld.resolve(javaUtilMap);
+ assertTrue("Should be the raw type ?!? "+rawType.getTypekind(),rawType.isRawType());
+
+ ReferenceType genericType = (ReferenceType)rawType.getGenericType();
+ assertTrue("Should be the generic type ?!? "+genericType.getTypekind(),genericType.isGenericType());
+
+ ResolvedType rt = rawType.getSuperclass();
+ assertTrue("Superclass for Map raw type should be Object but was "+rt,rt.equals(UnresolvedType.OBJECT));
+
+ ResolvedType rt2 = genericType.getSuperclass();
+ assertTrue("Superclass for Map generic type should be Object but was "+rt2,rt2.equals(UnresolvedType.OBJECT));
+ }
+
+ public void testGenericInterfaceSuperclass_ReflectionWorldResolution() {
+
+ UnresolvedType javaUtilMap = UnresolvedType.forName("java.util.Map");
+
+ ReferenceType rawType = (ReferenceType) world.resolve(javaUtilMap);
+ assertTrue("Should be the raw type ?!? "+rawType.getTypekind(),rawType.isRawType());
+
+ ReferenceType genericType = (ReferenceType)rawType.getGenericType();
+ assertTrue("Should be the generic type ?!? "+genericType.getTypekind(),genericType.isGenericType());
+
+ ResolvedType rt = rawType.getSuperclass();
+ assertTrue("Superclass for Map raw type should be Object but was "+rt,rt.equals(UnresolvedType.OBJECT));
+
+ ResolvedType rt2 = genericType.getSuperclass();
+ assertTrue("Superclass for Map generic type should be Object but was "+rt2,rt2.equals(UnresolvedType.OBJECT));
+ }
+
+ // todo: array of int
+
protected void setUp() throws Exception {
world = new ReflectionWorld();
objectType = world.resolve("java.lang.Object");
diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java
index 9d6e99cb8..57909f6df 100644
--- a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java
+++ b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java
@@ -129,9 +129,13 @@ public class Java15ReflectionBasedReferenceTypeDelegate extends
return superInterfaces;
}
+ // If the superclass is null, return Object - same as bcel does
public ResolvedType getSuperclass() {
- if (superclass == null && getBaseClass()!=Object.class) // superclass of Object is null
- superclass = fromType(this.getBaseClass().getGenericSuperclass());
+ if (superclass == null && getBaseClass()!=Object.class) {// superclass of Object is null
+ Type t = this.getBaseClass().getGenericSuperclass();
+ if (t!=null) superclass = fromType(t);
+ if (t==null) superclass = getWorld().resolve(UnresolvedType.OBJECT);
+ }
return superclass;
}