-
Notifications
You must be signed in to change notification settings - Fork 100
Description
I use Jandex in a Weld SE project.
Jandex does not discover subclasses of classes with @Inherited bean-defining annotations.
I tested with a play Gradle project that only has weld-se-core as implementation dependency and jandex as runtimeOnly dependeny (or not, depending on tested case).
I tested with weld-se-core 4.0.3.Final and jandex 2.4.5.Final as well as weld-se-core 6.0.3.Final and jandex 3.5.3, both combinations show the same faulty behavior.
The only source file in the play project is Foo.java with content
package foo;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.Initialized;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.Instance;
import jakarta.enterprise.inject.Vetoed;
import jakarta.enterprise.inject.se.SeContainerInitializer;
import jakarta.inject.Inject;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
public class Foo {
public static void main(String[] args) {
SeContainerInitializer.newInstance()
.addProperty("jakarta.enterprise.inject.scan.implicit", TRUE)
.addProperty("org.jboss.weld.construction.relaxed", FALSE)
.initialize();
}
}
@ApplicationScoped
class Main {
@Inject
Instance<Bar> bars;
void ensureInitializationAtStartup(@Observes @Initialized(ApplicationScoped.class) Object event) {
bars.stream().map(Bar::getRealClass).forEach(System.out::println);
}
}
interface Bar {
Class<?> getRealClass();
}
//@Vetoed
@ApplicationScoped
class Baz implements Bar {
void ensureInitializationAtStartup(@Observes @Initialized(ApplicationScoped.class) Object event) {
}
@Override
public Class<?> getRealClass() {
return getClass();
}
}
//@ApplicationScoped
class Bam extends Baz {}Without @Vetoed and without Jandex, I get both classes.
Without @Vetoed and with Jandex, I only get the superclass.
With @Vetoed but without Jandex I only get the the subclass.
With @Vetoed and Jandex I get neither class.
With @Vetoed on the superclass and @ApplicationScoped on both and without Jandex, I get only the subclass.
With @Vetoed on the superclass and @ApplicationScoped on both and with Jandex, I also get only the subclass.
So my conclusion is, that Jandex does not consider the @Inherited @ApplicationScoped annotation on the superclass.