[jboss-cvs] JBossAS SVN: r61102 - projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 5 15:50:50 EST 2007
Author: flavia.rainone at jboss.com
Date: 2007-03-05 15:50:50 -0500 (Mon, 05 Mar 2007)
New Revision: 61102
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceInfo.java
Log:
[JBAOP] Fixed assignability degree algorithm bug, that wasn't treating correctly the case interface to java.lang.Object (this bug is spot on overloaded throwable test case
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceInfo.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceInfo.java 2007-03-05 20:49:47 UTC (rev 61101)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceInfo.java 2007-03-05 20:50:50 UTC (rev 61102)
@@ -1,6 +1,7 @@
package org.jboss.aop.advice.annotation;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import org.jboss.aop.advice.AdviceMethodProperties;
import org.jboss.aop.advice.annotation.AdviceMethodFactory.ReturnType;
@@ -77,7 +78,40 @@
}
if (fromType.isInterface())
{
- // you can't get to a class from an interface
+ // if is object, the degree is the size of this interface hierarchy + 1
+ if (toType.getName() == "java.lang.Object")
+ {
+ ArrayList<Class[]> list1 = new ArrayList<Class[]>();
+ ArrayList<Class[]> list2 = new ArrayList<Class[]>();
+ Class[] fromTypeInterfaces = fromType.getInterfaces();
+ if (fromTypeInterfaces.length == 0)
+ {
+ return 1;
+ }
+ list1.add(fromTypeInterfaces);
+ short degree = 2;
+ while (true)
+ {
+ for (Class[] interfaces : list1)
+ {
+ for (int i = 0; i < interfaces.length; i++)
+ {
+ Class[] superInterfaces = interfaces[i].getInterfaces();
+ if (superInterfaces.length == 0)
+ {
+ return degree;
+ }
+ list2.add(superInterfaces);
+ }
+ }
+ degree ++;
+ list1.clear();
+ ArrayList<Class[]> temp = list1;
+ list1 = list2;
+ list2 = temp;
+ }
+ }
+ // you can't get to a class (except Object) from an interface
return AdviceMethodFactory.NOT_ASSIGNABLE_DEGREE;
}
// assignability degree on class inheritance
More information about the jboss-cvs-commits
mailing list