diff options
author | aclement <aclement> | 2008-10-20 18:31:36 +0000 |
---|---|---|
committer | aclement <aclement> | 2008-10-20 18:31:36 +0000 |
commit | 315fa045aa378b43c36635b4e2edc435ab324737 (patch) | |
tree | ba8d39000c22795c8bae98269ec5d2008e9e2dd6 /weaver5 | |
parent | 22c9c825e93a8ad85904462499fcd0b7ca5f7845 (diff) | |
download | aspectj-315fa045aa378b43c36635b4e2edc435ab324737.tar.gz aspectj-315fa045aa378b43c36635b4e2edc435ab324737.zip |
246125: promoted generic sig parsing code to util
Diffstat (limited to 'weaver5')
-rw-r--r-- | weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java index f849352d7..58f774840 100644 --- a/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java +++ b/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java @@ -14,58 +14,55 @@ package org.aspectj.weaver.bcel; import junit.framework.TestCase; import org.aspectj.apache.bcel.Repository; -import org.aspectj.apache.bcel.classfile.GenericSignatureParser; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Signature; +import org.aspectj.util.GenericSignature; +import org.aspectj.util.GenericSignatureParser; +import org.aspectj.util.GenericSignature.ClassSignature; import org.aspectj.weaver.UnresolvedType; /** * @author colyer - * + * */ public class BcelGenericSignatureToTypeXTestCase extends TestCase { + public final GenericSignature.ClassSignature getGenericClassTypeSignature(JavaClass jClass) { + Signature sig = jClass.getSignatureAttribute(); + if (sig != null) { + GenericSignatureParser parser = new GenericSignatureParser(); + ClassSignature classSig = parser.parseAsClassSignature(sig.getSignature()); + return classSig; + } + return null; + } + public void testEnumFromHell() throws Exception { BcelWorld world = new BcelWorld(); JavaClass javaLangEnum = Repository.lookupClass("java/lang/Enum"); - Signature.ClassSignature cSig = javaLangEnum.getGenericClassTypeSignature(); - UnresolvedType superclass = - BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX( - cSig.superclassSignature, - cSig.formalTypeParameters, - world - ); - assertEquals("Ljava/lang/Object;",superclass.getSignature()); - assertEquals("2 superinterfaces",2,cSig.superInterfaceSignatures.length); - UnresolvedType comparable = - BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX( - cSig.superInterfaceSignatures[0], - cSig.formalTypeParameters, - world - ); - assertEquals("Pjava/lang/Comparable<TE;>;",comparable.getSignature()); - UnresolvedType serializable = - BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX( - cSig.superInterfaceSignatures[1], - cSig.formalTypeParameters, - world - ); - assertEquals("Ljava/io/Serializable;",serializable.getSignature()); + GenericSignature.ClassSignature cSig = getGenericClassTypeSignature(javaLangEnum); + UnresolvedType superclass = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superclassSignature, + cSig.formalTypeParameters, world); + assertEquals("Ljava/lang/Object;", superclass.getSignature()); + assertEquals("2 superinterfaces", 2, cSig.superInterfaceSignatures.length); + UnresolvedType comparable = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superInterfaceSignatures[0], + cSig.formalTypeParameters, world); + assertEquals("Pjava/lang/Comparable<TE;>;", comparable.getSignature()); + UnresolvedType serializable = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX( + cSig.superInterfaceSignatures[1], cSig.formalTypeParameters, world); + assertEquals("Ljava/io/Serializable;", serializable.getSignature()); } - + public void testColonColon() throws Exception { BcelWorld world = new BcelWorld(); - Signature.ClassSignature cSig = new GenericSignatureParser().parseAsClassSignature("<T::Ljava/io/Serializable;>Ljava/lang/Object;Ljava/lang/Comparable<TT;>;"); - UnresolvedType resolved = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX( - cSig.superclassSignature, - cSig.formalTypeParameters, + GenericSignature.ClassSignature cSig = new GenericSignatureParser() + .parseAsClassSignature("<T::Ljava/io/Serializable;>Ljava/lang/Object;Ljava/lang/Comparable<TT;>;"); + UnresolvedType resolved = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superclassSignature, + cSig.formalTypeParameters, world); + assertEquals("Ljava/lang/Object;", resolved.getSignature()); + BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superInterfaceSignatures[0], cSig.formalTypeParameters, world); - assertEquals("Ljava/lang/Object;",resolved.getSignature()); - BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX( - cSig.superInterfaceSignatures[0], - cSig.formalTypeParameters, - world); - + } - + } |