aboutsummaryrefslogtreecommitdiffstats
path: root/weaver/testsrc/org
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-07-20 11:11:29 +0000
committeracolyer <acolyer>2005-07-20 11:11:29 +0000
commitaaa349d1543fbad515ff4fce869799fac591118d (patch)
tree25c8c750ff64767dfca53f399f6dd5be43d05b6b /weaver/testsrc/org
parent9fc901ce7a0af0fca72f266504a0a7bc637cb10a (diff)
downloadaspectj-aaa349d1543fbad515ff4fce869799fac591118d.tar.gz
aspectj-aaa349d1543fbad515ff4fce869799fac591118d.zip
changes to construction and representation of parameterized types, and enforcement of the constraint that type mungers always operate on the generic type (never raw or parameterized)
Diffstat (limited to 'weaver/testsrc/org')
-rw-r--r--weaver/testsrc/org/aspectj/weaver/MemberTestCase15.java8
-rw-r--r--weaver/testsrc/org/aspectj/weaver/ParameterizedReferenceTypeTestCase.java3
-rw-r--r--weaver/testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java26
-rw-r--r--weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java26
-rw-r--r--weaver/testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java2
5 files changed, 44 insertions, 21 deletions
diff --git a/weaver/testsrc/org/aspectj/weaver/MemberTestCase15.java b/weaver/testsrc/org/aspectj/weaver/MemberTestCase15.java
index 4610b6e3c..a3c60d709 100644
--- a/weaver/testsrc/org/aspectj/weaver/MemberTestCase15.java
+++ b/weaver/testsrc/org/aspectj/weaver/MemberTestCase15.java
@@ -40,7 +40,9 @@ public class MemberTestCase15 extends TestCase {
public void testCanBeParameterizedGenericMethod() {
BcelWorld world = new BcelWorld();
- ResolvedType javaLangClass = world.resolve(UnresolvedType.forName("java/lang/Class"));
+ ResolvedType javaLangClass = world.resolve(UnresolvedType.forName("java.lang.Class"));
+ javaLangClass = javaLangClass.getGenericType();
+ if (javaLangClass == null) return; // for < 1.5
ResolvedMember[] methods = javaLangClass.getDeclaredMethods();
ResolvedMember asSubclass = null;
for (int i = 0; i < methods.length; i++) {
@@ -57,7 +59,9 @@ public class MemberTestCase15 extends TestCase {
public void testCanBeParameterizedMethodInGenericType() {
BcelWorld world = new BcelWorld();
- ResolvedType javaUtilList = world.resolve(UnresolvedType.forName("java/util/List"));
+ ResolvedType javaUtilList = world.resolve(UnresolvedType.forName("java.util.List"));
+ javaUtilList = javaUtilList.getGenericType();
+ if (javaUtilList == null) return; // for < 1.5
ResolvedMember[] methods = javaUtilList.getDeclaredMethods();
ResolvedMember add = null;
for (int i = 0; i < methods.length; i++) {
diff --git a/weaver/testsrc/org/aspectj/weaver/ParameterizedReferenceTypeTestCase.java b/weaver/testsrc/org/aspectj/weaver/ParameterizedReferenceTypeTestCase.java
index bf4ae07ad..71a640caa 100644
--- a/weaver/testsrc/org/aspectj/weaver/ParameterizedReferenceTypeTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/ParameterizedReferenceTypeTestCase.java
@@ -62,7 +62,6 @@ public class ParameterizedReferenceTypeTestCase extends TestCase {
super.setUp();
world = new BcelWorld();
listOfString = (ReferenceType)
- world.resolve(UnresolvedType.forParameterizedTypeNames("java/util/List",
- new String[] {"java/lang/String"}));
+ TypeFactory.createTypeFromSignature("Ljava/util/List<Ljava/lang/String;>;").resolve(world);
}
}
diff --git a/weaver/testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java b/weaver/testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java
index 21930aa35..1e0e435c7 100644
--- a/weaver/testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java
@@ -19,22 +19,36 @@ import junit.framework.TestCase;
// XXX - couldn't find any unit test cases for the rest of the ReferenceType class
public class ReferenceTypeTestCase extends TestCase {
- public void testIsGenericTrue() {
+ public void testIsRawTrue() {
BcelWorld world = new BcelWorld();
- UnresolvedType javaLangClass = UnresolvedType.forName("java/lang/Class");
+ UnresolvedType javaLangClass = UnresolvedType.forName("java.lang.Class");
ResolvedType rtx = world.resolve(javaLangClass);
assertTrue("Resolves to reference type",(rtx instanceof ReferenceType));
ReferenceType rt = (ReferenceType) rtx;
- assertTrue("java.lang.Class is generic",rt.isGenericType());
+ assertTrue("java.lang.Class is raw",rt.isRawType());
}
- public void testIsGenericFalse() {
+ public void testIsRawFalse() {
BcelWorld world = new BcelWorld();
- UnresolvedType javaLangObject = UnresolvedType.forName("java/lang/Object");
+ UnresolvedType javaLangObject = UnresolvedType.forName("java.lang.Object");
ResolvedType rtx = world.resolve(javaLangObject);
assertTrue("Resolves to reference type",(rtx instanceof ReferenceType));
ReferenceType rt = (ReferenceType) rtx;
- assertFalse("java.lang.Object is not generic",rt.isGenericType());
+ assertFalse("java.lang.Object is not raw",rt.isRawType());
+ }
+
+ public void testIsGenericTrue() {
+ BcelWorld world = new BcelWorld();
+ UnresolvedType javaLangClass = UnresolvedType.forName("java.lang.Class");
+ ResolvedType rtx = world.resolve(javaLangClass);
+ assertTrue("java.lang.Class has underpinning generic type",rtx.getGenericType().isGenericType());
+ }
+
+ public void testIsGenericFalse() {
+ BcelWorld world = new BcelWorld();
+ UnresolvedType javaLangObject = UnresolvedType.forName("java.lang.Object");
+ ResolvedType rtx = world.resolve(javaLangObject);
+ assertFalse(rtx.isGenericType());
}
}
diff --git a/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java b/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java
index 793a071bf..432e441cb 100644
--- a/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java
@@ -16,6 +16,7 @@ package org.aspectj.weaver;
import junit.framework.TestCase;
import org.aspectj.testing.util.TestUtil;
+import org.aspectj.weaver.bcel.BcelWorld;
/**
* This is a test case for all the portions of UnresolvedType that don't require a world.
@@ -65,16 +66,16 @@ public class TypeXTestCase extends TestCase {
public void testNameAndSigWithParameters() {
UnresolvedType t = UnresolvedType.forName("java.util.List<java.lang.String>");
assertEquals(t.getName(),"java.util.List<java.lang.String>");
- assertEquals(t.getSignature(),"Ljava/util/List<Ljava/lang/String;>;");
- t = new UnresolvedType("Ljava/util/List<Ljava/lang/String;>;");
+ assertEquals(t.getSignature(),"Pjava/util/List<Ljava/lang/String;>;");
+ t = UnresolvedType.forSignature("Pjava/util/List<Ljava/lang/String;>;");
assertEquals(t.getName(),"java.util.List<java.lang.String>");
- assertEquals(t.getSignature(),"Ljava/util/List<Ljava/lang/String;>;");
+ assertEquals(t.getSignature(),"Pjava/util/List<Ljava/lang/String;>;");
t = UnresolvedType.forName("java.util.Map<java.util.String,java.util.List<java.lang.Integer>>");
assertEquals(t.getName(),"java.util.Map<java.util.String,java.util.List<java.lang.Integer>>");
- assertEquals(t.getSignature(),"Ljava/util/Map<Ljava/util/String;Ljava/util/List<Ljava/lang/Integer;>;>;");
- t = new UnresolvedType("Ljava/util/Map<Ljava/util/String;Ljava/util/List<Ljava/lang/Integer;>;>;");
+ assertEquals(t.getSignature(),"Pjava/util/Map<Ljava/util/String;Pjava/util/List<Ljava/lang/Integer;>;>;");
+ t = UnresolvedType.forSignature("Pjava/util/Map<Ljava/util/String;Pjava/util/List<Ljava/lang/Integer;>;>;");
assertEquals(t.getName(),"java.util.Map<java.util.String,java.util.List<java.lang.Integer>>");
- assertEquals(t.getSignature(),"Ljava/util/Map<Ljava/util/String;Ljava/util/List<Ljava/lang/Integer;>;>;");
+ assertEquals(t.getSignature(),"Pjava/util/Map<Ljava/util/String;Pjava/util/List<Ljava/lang/Integer;>;>;");
}
/**
@@ -91,13 +92,13 @@ public class TypeXTestCase extends TestCase {
public void testTypexGenericSignatureProcessing() {
UnresolvedType tx = null;
- tx = new UnresolvedType("Ljava/util/Set<Ljava/lang/String;>;");
+ tx = UnresolvedType.forSignature("Pjava/util/Set<Ljava/lang/String;>;");
checkTX(tx,true,1);
- tx = new UnresolvedType("Ljava/util/Set<Ljava/util/List<Ljava/lang/String;>;>;");
+ tx = UnresolvedType.forSignature("Pjava/util/Set<Pjava/util/List<Ljava/lang/String;>;>;");
checkTX(tx,true,1);
- tx = new UnresolvedType("Ljava/util/Map<Ljava/util/List<Ljava/lang/String;>;Ljava/lang/String;>;");
+ tx = UnresolvedType.forSignature("Pjava/util/Map<Pjava/util/List<Ljava/lang/String;>;Ljava/lang/String;>;");
checkTX(tx,true,2);
checkTX(tx.getTypeParameters()[0],true,1);
checkTX(tx.getTypeParameters()[1],false,0);
@@ -105,8 +106,13 @@ public class TypeXTestCase extends TestCase {
}
public void testTypeXForParameterizedTypes() {
+ World world = new BcelWorld();
UnresolvedType stringType = UnresolvedType.forName("java/lang/String");
- UnresolvedType listOfStringType = UnresolvedType.forParameterizedTypes(UnresolvedType.forName("java/util/List"), new UnresolvedType[] {stringType});
+ ResolvedType listOfStringType =
+ TypeFactory.createParameterizedType(
+ UnresolvedType.forName("java/util/List").resolve(world),
+ new UnresolvedType[] {stringType},
+ world);
assertEquals("1 type param",1,listOfStringType.typeParameters.length);
assertEquals(stringType,listOfStringType.typeParameters[0]);
assertTrue(listOfStringType.isParameterizedType());
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java
index d42e769d2..f36b86023 100644
--- a/weaver/testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java
@@ -45,7 +45,7 @@ public class BcelGenericSignatureToTypeXTestCase extends TestCase {
cSig.formalTypeParameters,
world
);
- assertEquals("Ljava/lang/Comparable<Ljava/lang/Enum<Ljava/lang/Object;>;>;",comparable.getSignature());
+ assertEquals("Pjava/lang/Comparable<Pjava/lang/Enum<Ljava/lang/Object;>;>;",comparable.getSignature());
UnresolvedType serializable =
BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
cSig.superInterfaceSignatures[1],