Search code examples
javaejbstateless

Does Statless annotation propagate to extensions of Abstract Class?


I've found this @Stateless annotation in some code like:

public Interface A

@Stateless
public abstract class B implements A

public class C extends B

public class D extends B

But Intellij is then saying B shouldn't be declared as abstract. Is Intellij right here and the Stateless is not actually propagated to the classes extending B and I'd have to declare them as Stateless or C, D are properly set as Stateless?


Solution

  • You need to add Stateless in all subclasses too.

    Take a look at this: Inheriting class annotations

    Only the annotations annotated with @Inherited are propagated https://www.logicbig.com/tutorials/core-java-tutorial/annotations/inherited-meta-annotation.html