[cdi-dev] [JBoss JIRA] (CDI-438) Fix type parameters ordering in ProcessProducerMethod and ProcessProducerField events

Martin Kouba (JIRA) issues at jboss.org
Tue Jul 7 08:17:05 EDT 2015


    [ https://issues.jboss.org/browse/CDI-438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13087282#comment-13087282 ] 

Martin Kouba commented on CDI-438:
----------------------------------

{quote}
With this change done, is there still any reason to prevent delivering of ProcessProducerMethod<Foo,Producer> to observer of ProcessBean<Foo>? I think it could make sense in certain use cases...
{quote}
Yes, I think so. For a producer method like this:
{code}
class Producer {
  Foo produce() {
    return new Foo();
  }
}
{code}
The event types include {{ProcessProducerMethod<Foo,Producer>}}, {{ProcessBean<Producer>}} and {{Object}}. And none of these types is assignable to {{ProcessBean<Foo>}}.

To be honest I'm not quite sure whether it would be better to observe the return type or the bean class (current wording) for producer methods/fields. But if I understand your previous comment correctly we can't fix this anyway...

We should also fix the {{javax.enterprise.inject.spi.ProcessBean}} javadoc:
{quote}
...
For a producer method with method return type X of a bean with bean class T, the container must raise an event of type javax.enterprise.inject.spi.ProcessProducerMethod<T, X>.
...
{quote}

> Fix type parameters ordering in ProcessProducerMethod and ProcessProducerField events
> -------------------------------------------------------------------------------------
>
>                 Key: CDI-438
>                 URL: https://issues.jboss.org/browse/CDI-438
>             Project: CDI Specification Issues
>          Issue Type: Bug
>    Affects Versions: 1.2.Final
>            Reporter: Martin Kouba
>            Assignee: Antoine Sabot-Durand
>             Fix For: 2.0-EDR1
>
>
> Since CDI 1.0 there is an inconsistency in the description of {{ProcessProducerMethod}} event...
> The text:
> {quote}
> For a producer method with method *return type X* of a bean with *bean class T*, the container must raise an event of type ProcessProducerMethod<T, X>.
> {quote}
> API:
> {code:java}
> /**
>  * @param <T> The return type of the producer method
>  * @param <X> The class of the bean declaring the producer method
>  */
> public interface ProcessProducerMethod<T, X> extends ProcessBean<X> {
> }
> {code}
> The same applies to {{ProcessProducerField}}. 
> TCK and RI (Weld) follow the API. As one of the consequences an {{ProcessProducerMethod<Foo,Producer>}} event is not delivered to an observer with the event parameter {{ProcessBean<Foo>}} - which is required by the spec but does not make sense at the same time.
> It's obvious that JCP compatibility rules required to keep the wrong ordering for CDI 1.x (see also the comments in {{javax.enterprise.inject.spi.ProcessProducerMethod}}). I believe this should be fixed in CDI 2.0.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


More information about the cdi-dev mailing list