From: aclement Date: Mon, 16 Nov 2009 21:06:44 +0000 (+0000) Subject: work in progress to improve MemberImpl X-Git-Tag: V1_6_7~73 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ea9f35ae874ab50e91cafec3f4b9a7ff6219e1d6;p=aspectj.git work in progress to improve MemberImpl --- diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java b/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java index 8014289e7..7838c0696 100644 --- a/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java +++ b/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java @@ -11,13 +11,15 @@ * ******************************************************************/ package org.aspectj.weaver; +import java.util.List; + import org.aspectj.weaver.bcel.BcelWorld; import junit.framework.TestCase; /** * @author colyer - * + * @author clement */ public class MemberTestCase15 extends TestCase { @@ -77,5 +79,79 @@ public class MemberTestCase15 extends TestCase { assertTrue(add.canBeParameterized()); } } + /* + public void testGenericReferenceTypeCreation() { + UnresolvedType genericType = UnresolvedType.forGenericTypeSignature("Lorg/aspectj/weaver/MemberTestCase15$One;","Ljava/lang/Object;"); + assertEquals("Porg/aspectj/weaver/MemberTestCase15$One;",genericType.getSignature()); + assertEquals("Lorg/aspectj/weaver/MemberTestCase15$One;",genericType.getErasureSignature()); + } + + public void testMemberSignatureCreation() { + World world = new BcelWorld("../weaver5/bin/"); + //new ReflectionWorld(false, getClass().getClassLoader()); + world.setBehaveInJava5Way(true); + ResolvedType one = world.resolve("org.aspectj.weaver.MemberTestCase15$One"); + assertNotNull(one); + assertFalse(one.isMissing()); + + // Look at the methods on the parameterized type One + ResolvedMember member = findMethod("getter",one); + String erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),true); + assertEquals("()Ljava/lang/String;",erasedSignature); + String nonErasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false); + assertEquals("()Ljava/lang/String;",nonErasedSignature); + erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),true); + assertEquals("()Ljava/lang/String;",erasedSignature); + nonErasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false); + assertEquals("()Ljava/lang/String;",nonErasedSignature); + + member = findMethod("getterTwo",one); + erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),true); + assertEquals("()Ljava/util/List;",erasedSignature); + nonErasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false); + assertEquals("()Pjava/util/List;",nonErasedSignature); + nonErasedSignature = MemberImpl.typesToSignature(member.getGenericReturnType(),member.getGenericParameterTypes(),true); + assertEquals("()Ljava/util/List;",nonErasedSignature); + nonErasedSignature = MemberImpl.typesToSignature(member.getGenericReturnType(),member.getGenericParameterTypes(),false); + assertEquals("()Pjava/util/List;",nonErasedSignature); + + // Grab the generic type backing the parameterized type + ResolvedType oneGeneric = one.getGenericType(); + assertTrue(oneGeneric.isGenericType()); + member = findMethod("getterTwo",oneGeneric); + erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),true); + assertEquals("()Ljava/util/List;",erasedSignature); + erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false); + assertEquals("()Ljava/util/List;",erasedSignature); + nonErasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false); + assertEquals("()Pjava/util/List;",nonErasedSignature); + nonErasedSignature = MemberImpl.typesToSignature(member.getGenericReturnType(),member.getGenericParameterTypes(),false); + assertEquals("()Ljava/util/List;",nonErasedSignature); + + + ResolvedType oneRaw = oneGeneric.getRawType(); + member = findMethod("getterTwo",oneRaw); + } + private ResolvedMember findMethod(String name, ResolvedType type) { + ResolvedMember[] members = type.getDeclaredMethods(); + for (ResolvedMember member: members) { + if (member.getName().equals(name)) { + return member; + } + } + return null; + } + + // testcode + class One { + T t; + T getter() { + return null; + } + List getterTwo() { + return null; + } + } + */ }