The CDI 4.1 specification reads, in part:
An event object is an instance of a concrete Java class with no unresolvable type variables. The event types of the event include all superclasses and interfaces of the runtime class of the event object.
Given this:
Object eventObject = new ArrayList<String>();
…if the part of the specification that reads "the event types of the event [object] include all superclasses and interfaces of the runtime class of the event object" is true, then the event types would not include ArrayList<String>, but only what eventObject.getClass() returns (ArrayList.class) and its transitive supertype closure.
Does this section of the specification therefore need to be rewritten/clarified, since Weld, at least, (properly, IMHO) includes the parameterized type ArrayList<String> in the collection of event types for this example?
(Clearly the event types in real-world CDI implementations such as Weld are actually derived from the type argument supplied to the "broadcaster" (e.g. the ArrayList<String> in jakarta.enterprise.event.Event<ArrayList<String>>), not "the runtime class of the event object" (which cannot yield ArrayList<String> by itself), no matter what the specification says. It would be nice to bring the specification into line with real-world implementations.)
The CDI 4.1 specification reads, in part:
Given this:
…if the part of the specification that reads "the event types of the event [object] include all superclasses and interfaces of the runtime class of the event object" is true, then the event types would not include
ArrayList<String>, but only whateventObject.getClass()returns (ArrayList.class) and its transitive supertype closure.Does this section of the specification therefore need to be rewritten/clarified, since Weld, at least, (properly, IMHO) includes the parameterized type
ArrayList<String>in the collection of event types for this example?(Clearly the event types in real-world CDI implementations such as Weld are actually derived from the type argument supplied to the "broadcaster" (e.g. the
ArrayList<String>injakarta.enterprise.event.Event<ArrayList<String>>), not "the runtime class of the event object" (which cannot yieldArrayList<String>by itself), no matter what the specification says. It would be nice to bring the specification into line with real-world implementations.)