[weld-dev] Use of "to" and "from" when refering to assignments in section 5.2.3

Bill Wigger bill.w.1024 at gmail.com
Fri Jul 30 12:49:23 EDT 2010


In section 5.2.3 the spec seems to be misworded with respsect to "assignable
to" and "assignable from".

The start of this section states (capitalization addded):

"A parameterized BEAN TYPE is considered ASSIGNABLE TO a parameterized
REQUIRED TYPE if they have identical raw type and for each parameter:"

and then it list as one of the cases:

"the REQUIRED TYPE parameter is an ACTUAL TYPE, the BEAN TYPE parameter is a
TYPE VARIABLE and the ACTUAL TYPE is ASSIGNABLE TO the upper bound, if any,
of the TYPE VARIABLE"

This seems to state that a Bean Type is assignable to a Required Type if ...
the Required type is assignable to the upper bound of the Bean Type.  This
seems to then be contradicting itself, and the reading of that second part
should be:

"the required type parameter is an actual type, the bean type parameter is a
type variable and the actual type is ASSIGNABLE FROM the upper bound, if
any, of the type variable"

The question comes down which injection below is valid:

public class C1<T extends MediumClass> {
 @Produces ... ArrayList<T> m1()

@Inject  ... ArrayList<SmallClass> s1;
@Inject  ... ArrayList<BigClass> b1;

where
MediumClass extends SmallClass
and
BigClass extends MediumClass

Seems like the injection using SmallClass should work, since what is
produced will be a MediumClass which will have all the methods needed by
SmallClass.

And the injection using BigClass should fail, since what is produced will be
a MediumClass which will not have all the methods needed by BigClass.

But, according to the spec (and what seems to be enforced by the TCK) is
that since Required Type (in this case SmallClass and BigClass), must be
assignable TO the Bean Type (Medium Class),  therefore the BigClass
assignment is the one that works, since BigClass is assignable TO
MediumClass.   But since MediumClass doesn't have all the methods that
BigClass has, then what is
produced will be insufficient for the injection.
So, is the spec misworded here?   Which of these injections should be
resolved, and which one should give an error?
Bill W.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20100730/82778372/attachment.html 


More information about the weld-dev mailing list