[
https://issues.jboss.org/browse/WELD-904?page=com.atlassian.jira.plugin.s...
]
Christian Bauer updated WELD-904:
---------------------------------
Description:
{code}
/*
<beans
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<alternatives>
<class>Foo$Bar</class>
</alternatives>
</beans>
*/
@ApplicationScoped
public class Foo {
public static void main(String[] args) {
WeldContainer weld = new Weld().initialize();
weld.event().select(MyEvent.class).fire(new MyEvent());
}
static class MyEvent {
}
@Qualifier
@Target({FIELD, PARAMETER})
@Retention(RUNTIME)
public @interface SomeQualifier {
}
@PostConstruct
void init() {
System.out.println("INIT FOO");
}
void onEvent(@Observes MyEvent e) {
System.out.println("EVENT FOO");
}
@Alternative
@Specializes
static public class Bar extends Foo {
@Override
void init() {
System.out.println("INIT BAR");
}
@Override
void onEvent(@Observes @SomeQualifier MyEvent e) {
System.out.println("EVENT BAR");
}
}
}
{code}
The expected output is:
INIT BAR
The actual output is:
INIT BAR
EVENT BAR
Removing the @SomeQualifier annotation on the Bar#onEvent() method results in:
INIT BAR
EVENT BAR
EVENT BAR
Removing also the @Observes annotation on the Bar#onEvent() method results in:
INIT BAR
EVENT BAR
One or several of these outcomes is wrong. Also, section 4.2 of the spec says that
observer methods are only inherited if the subclass doesn't override the method.
I'm confused why everyone (e.g.
https://issues.jboss.org/browse/CDITCK-186) seems to
assume the exact opposite.
was:
/*
<beans
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<alternatives>
<class>Foo$Bar</class>
</alternatives>
</beans>
*/
@ApplicationScoped
public class Foo {
public static void main(String[] args) {
WeldContainer weld = new Weld().initialize();
weld.event().select(MyEvent.class).fire(new MyEvent());
}
static class MyEvent {
}
@Qualifier
@Target({FIELD, PARAMETER})
@Retention(RUNTIME)
public @interface SomeQualifier {
}
@PostConstruct
void init() {
System.out.println("INIT FOO");
}
void onEvent(@Observes MyEvent e) {
System.out.println("EVENT FOO");
}
@Alternative
@Specializes
static public class Bar extends Foo {
@Override
void init() {
System.out.println("INIT BAR");
}
@Override
void onEvent(@Observes @SomeQualifier MyEvent e) {
System.out.println("EVENT BAR");
}
}
}
The expected output is:
INIT BAR
The actual output is:
INIT BAR
EVENT BAR
Removing the @SomeQualifier annotation on the Bar#onEvent() method results in:
INIT BAR
EVENT BAR
EVENT BAR
Removing also the @Observes annotation on the Bar#onEvent() method results in:
INIT BAR
EVENT BAR
One or several of these outcomes is wrong. Also, section 4.2 of the spec says that
observer methods are only inherited if the subclass doesn't override the method.
I'm confused why everyone (e.g.
https://issues.jboss.org/browse/CDITCK-186) seems to
assume the exact opposite.
Observer method inheritance broken
----------------------------------
Key: WELD-904
URL:
https://issues.jboss.org/browse/WELD-904
Project: Weld
Issue Type: Bug
Affects Versions: 1.1.1.Final
Reporter: Christian Bauer
Priority: Minor
{code}
/*
<beans
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<alternatives>
<class>Foo$Bar</class>
</alternatives>
</beans>
*/
@ApplicationScoped
public class Foo {
public static void main(String[] args) {
WeldContainer weld = new Weld().initialize();
weld.event().select(MyEvent.class).fire(new MyEvent());
}
static class MyEvent {
}
@Qualifier
@Target({FIELD, PARAMETER})
@Retention(RUNTIME)
public @interface SomeQualifier {
}
@PostConstruct
void init() {
System.out.println("INIT FOO");
}
void onEvent(@Observes MyEvent e) {
System.out.println("EVENT FOO");
}
@Alternative
@Specializes
static public class Bar extends Foo {
@Override
void init() {
System.out.println("INIT BAR");
}
@Override
void onEvent(@Observes @SomeQualifier MyEvent e) {
System.out.println("EVENT BAR");
}
}
}
{code}
The expected output is:
INIT BAR
The actual output is:
INIT BAR
EVENT BAR
Removing the @SomeQualifier annotation on the Bar#onEvent() method results in:
INIT BAR
EVENT BAR
EVENT BAR
Removing also the @Observes annotation on the Bar#onEvent() method results in:
INIT BAR
EVENT BAR
One or several of these outcomes is wrong. Also, section 4.2 of the spec says that
observer methods are only inherited if the subclass doesn't override the method.
I'm confused why everyone (e.g.
https://issues.jboss.org/browse/CDITCK-186) seems to
assume the exact opposite.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira