Re: [aspectwerkz-dev] MethodComparator.compareMethodInfo throws exception

Alexandre Vasseur <[email protected]> Wed, 8 Dec 2004 14:19:35 +0100
Newsgroups gmane.comp.java.aspectwerkz.devel
Message-ID <[email protected]>
Hi

You are right
Thanks a  lot for the the test case.
It will be fixed in RC2 and is the fix is already in CVS.

Alex


On Wed, 08 Dec 2004 11:39:30 +0100, Niklas Therning <[email protected]> wrote:
> I just upgraded from RC1 to the latest CVS. Now when I run my app I get
> a java.lang.Error in MethodComparator.compareMethodInfo(). I've found
> that it happens when the methods of net.sf.cglib.proxy.Factory are
> sorted. This interface has two methods of the same name and the same
> number of args but different arg types. The following test code can be
> used to reproduce this:
> 
> import org.codehaus.aspectwerkz.reflect.ClassInfoHelper;
> import org.codehaus.aspectwerkz.reflect.impl.asm.AsmClassInfo;
> 
> public class Test {
>     public static interface TestInterface {
>         void test(String s);
>         void test(String[] s);
>     }
> 
>     public static void main(String[] args) {
>         ClassInfoHelper.createSortedMethodList(
>                 AsmClassInfo.getClassInfo(TestInterface.class.getName(),
>                         Test.class.getClassLoader()));
>     }
> }
> 
> I've had a look at MethodComparator.compareMethodInfo() and I think the
> for loop at the end of that method should be changed from
> 
> for (int i = 0; i < args1.length; i++) {
>     if (args1[i].getName().equals(args2[i].getName())) {
>         return 0;
>     }
> }
> 
> to something like
> 
> for (int i = 0; i < args1.length; i++) {
>     int c = args1[i].getName().compareTo(args2[i].getName());
>     if (c != 0) {
>         return c;
>     }
> }
> 
> /Niklas
> 
>