[jboss-cvs] JBossAS SVN: r63889 - projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/assignability.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jul 6 20:22:15 EDT 2007
Author: flavia.rainone at jboss.com
Date: 2007-07-06 20:22:15 -0400 (Fri, 06 Jul 2007)
New Revision: 63889
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/assignability/Algorithm.java
projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/assignability/VariableNode.java
Log:
[JBAOP-420] Bug fixed.
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/assignability/Algorithm.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/assignability/Algorithm.java 2007-07-06 22:27:01 UTC (rev 63888)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/assignability/Algorithm.java 2007-07-07 00:22:15 UTC (rev 63889)
@@ -76,7 +76,7 @@
VariableHierarchy variableHierarchy)
{
VariableNode fromNode = variableHierarchy.getVariableNode((TypeVariable) fromType);
- return fromNode.assignValue(type);
+ return fromNode.addMaximumUpperBound(type);
}
protected boolean addBound(Type type, Type fromType,
@@ -281,9 +281,9 @@
{
public boolean isSame(Type type, Type fromType, Algorithm client, VariableHierarchy variableHierarchy)
{
- if(Algorithm.VARIABLE_TARGET.isVariableOperationApplicable(type, fromType))
+ if(client.isVariableOperationApplicable(type, fromType))
{
- return Algorithm.VARIABLE_TARGET.assignValue(type, fromType, variableHierarchy);
+ return client.assignValue(type, fromType, variableHierarchy);
}
if (type instanceof Class)
{
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/assignability/VariableNode.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/assignability/VariableNode.java 2007-07-06 22:27:01 UTC (rev 63888)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/assignability/VariableNode.java 2007-07-07 00:22:15 UTC (rev 63889)
@@ -63,17 +63,10 @@
public final boolean assignValue(Type value)
{
- // assigned bounds can only be assigned to concrete types
- if (this.hierarchy.isBoundComparation() && !(value instanceof Class)
- && !(value instanceof ParameterizedType))
+ if (!isAssignabilityPermited(value))
{
return false;
}
- // real bounds can have values assigned to variables
- if (this.hierarchy.isRealBoundComparation() && (value instanceof WildcardType))
- {
- return false;
- }
if (this.assignedValue != null)
{
@@ -87,7 +80,7 @@
this.assignedValue = value;
return true;
}
-
+
public final boolean addLowerBound(Type lowerBound)
{
if (!isInsideUpperBounds(lowerBound, false) ||
@@ -114,6 +107,15 @@
{
return false;
}
+ addToUpperBounds(upperBound);
+ return true;
+ }
+
+ /**
+ * @param upperBound
+ */
+ private void addToUpperBounds(Type upperBound)
+ {
if (upperBound instanceof TypeVariable)
{
Type[] bounds = ((TypeVariable) upperBound).getBounds();
@@ -123,9 +125,65 @@
{
this.upperBounds.add(upperBound);
}
- return true;
}
+ public final boolean addMaximumUpperBound(Type upperBound)
+ {
+ if (!isAssignabilityPermited(upperBound))
+ {
+ return false;
+ }
+ for (Type oldUpperBound: upperBounds)
+ {
+ if (!isAssignable(upperBound, oldUpperBound))
+ {
+ return false;
+ }
+ }
+ for (Type oldLowerBound: lowerBounds)
+ {
+ if (!isAssignable(upperBound, oldLowerBound))
+ {
+ return false;
+ }
+ }
+ if (this.assignedValue != null && !isAssignable(upperBound, assignedValue))
+ {
+ return false;
+ }
+ if (this.next != null)
+ {
+ return this.next.addMaximumUpperBound(upperBound);
+ }
+ Type[] bounds = this.variable.getBounds();
+ if (bounds.length == 1 && bounds[0] == Object.class)
+ {
+ return true;
+ }
+ else
+ {
+ for (Type bound: bounds)
+ {
+ if (!isAssignable(upperBound, bound))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ private boolean isAssignabilityPermited(Type value)
+ {
+ // assigned bounds can only be assigned to concrete types
+ return !(
+ ((this.hierarchy.isBoundComparation() && !(value instanceof Class)
+ && !(value instanceof ParameterizedType))) ||
+ (
+ // real bounds can have values assigned to variables
+ (this.hierarchy.isRealBoundComparation() && (value instanceof WildcardType))));
+ }
+
private boolean areLowerBoundsInside(Type bound, boolean checkUpperBounds)
{
if (this.assignedValue != null && !isAssignable(bound, assignedValue))
@@ -409,6 +467,25 @@
}
return true;
}
+ if (type instanceof WildcardType)
+ {
+ WildcardType wildcard = (WildcardType) type;
+ for (Type bound: wildcard.getUpperBounds())
+ {
+ if (!isAssignable(bound, fromType))
+ {
+ return false;
+ }
+ }
+ for (Type bound: wildcard.getLowerBounds())
+ {
+ if (!isAssignable(bound, fromType))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
ChoiceBound choiceBound = (ChoiceBound) type;
if (fromType instanceof TypeVariable &&
!isAssignable(choiceBound.variable, (TypeVariable) fromType))
More information about the jboss-cvs-commits
mailing list