From: aclement Date: Fri, 9 Dec 2005 08:40:12 +0000 (+0000) Subject: delegates modified to return the same thing as BCEL. Ctors have the name ... X-Git-Tag: V1_5_0RC1~40 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b52515fc2319ca34a045a0823ca0f5c8ffeaa2de;p=aspectj.git delegates modified to return the same thing as BCEL. Ctors have the name and a return type of 'void'. Fix for 119353 --- diff --git a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java index 5063fb0a0..3214156cd 100644 --- a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java +++ b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java @@ -153,8 +153,9 @@ public class ReflectionBasedReferenceTypeDelegateFactory { new ReflectionBasedResolvedMemberImpl(org.aspectj.weaver.Member.CONSTRUCTOR, toResolvedType(aConstructor.getDeclaringClass(),(ReflectionWorld)inWorld), aConstructor.getModifiers(), - toResolvedType(aConstructor.getDeclaringClass(),(ReflectionWorld)inWorld), - "init", + // to return what BCEL returns, the return type for ctor is void + ResolvedType.VOID,//toResolvedType(aConstructor.getDeclaringClass(),(ReflectionWorld)inWorld), + "", toResolvedTypeArray(aConstructor.getParameterTypes(),inWorld), toResolvedTypeArray(aConstructor.getExceptionTypes(),inWorld), aConstructor diff --git a/weaver/testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java b/weaver/testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java index cc0407c5c..fe5aaec0a 100644 --- a/weaver/testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java +++ b/weaver/testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java @@ -12,6 +12,9 @@ package org.aspectj.weaver.reflect; +import java.util.HashSet; +import java.util.Set; + import junit.framework.TestCase; import org.aspectj.weaver.ReferenceType; @@ -130,7 +133,7 @@ public class ReflectionBasedReferenceTypeDelegateTest extends TestCase { assertEquals(1,methods[idx].getExceptions().length); assertEquals(world.resolve("java.lang.Exception"),methods[idx].getExceptions()[0]); int baridx = findMethod("bar", methods); - int initidx = findMethod("init", methods); + int initidx = findMethod("", methods); assertTrue(baridx > -1); assertTrue(initidx > -1); assertTrue(baridx != initidx && baridx != idx && idx <= 2 && initidx <= 2 && baridx <= 2); @@ -238,6 +241,51 @@ public class ReflectionBasedReferenceTypeDelegateTest extends TestCase { assertTrue("Superclass for Map generic type should be Object but was "+rt2,rt2.equals(UnresolvedType.OBJECT)); } + // FIXME asc maybe. The reflection list of methods returned doesn't include (the static initializer) ... is that really a problem. + public void testCompareSubclassDelegates() { + + boolean barfIfClinitMissing = false; + world.setBehaveInJava5Way(true); + + BcelWorld bcelWorld = new BcelWorld(); + bcelWorld.setBehaveInJava5Way(true); + UnresolvedType javaUtilHashMap = UnresolvedType.forName("java.util.HashMap"); + ReferenceType rawType =(ReferenceType)bcelWorld.resolve(javaUtilHashMap ); + + ReferenceType rawReflectType =(ReferenceType)world.resolve(javaUtilHashMap ); + ResolvedMember[] rms1 = rawType.getDelegate().getDeclaredMethods(); + ResolvedMember[] rms2 = rawReflectType.getDelegate().getDeclaredMethods(); + StringBuffer errors = new StringBuffer(); + Set one = new HashSet(); + for (int i = 0; i < rms1.length; i++) { + one.add(rms1[i].toString()); + } + Set two = new HashSet(); + for (int i = 0; i < rms2.length; i++) { + two.add(rms2[i].toString()); + } + for (int i = 0;i")) continue; + errors.append("Couldn't find "+rms1[i].toString()+" in the reflection set\n"); + } + } + assertTrue("Errors:"+errors.toString(),errors.length()==0); + + if (barfIfClinitMissing) { + // the numbers must be exact + assertEquals(rms1.length,rms2.length); + } else { + // the numbers can be out by one in favour of bcel + assertTrue("Should be one extra (clinit) in BCEL case, but bcel="+rms1.length+" reflect="+rms2.length,rms1.length==rms2.length+1); + } + } + // todo: array of int protected void setUp() throws Exception { diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java index d153ccdc7..a5c57f13f 100644 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java +++ b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java @@ -213,8 +213,9 @@ public class Java15ReflectionBasedReferenceTypeDelegate extends new ReflectionBasedResolvedMemberImpl(org.aspectj.weaver.Member.METHOD, getGenericResolvedType(), forConstructor.getModifiers(), - getGenericResolvedType(), - "init", + // to return what BCEL returns the return type is void + ResolvedType.VOID,//getGenericResolvedType(), + "", typeConverter.fromTypes(forConstructor.getParameterTypes()), typeConverter.fromTypes(forConstructor.getExceptionTypes()), forConstructor