Skip to content

Commit

Permalink
Relax the scope requirement on pseudo-scoped beans
Browse files Browse the repository at this point in the history
Currently, the specification says that non-`@Dependent` beans may not have
public fields. This is overly restrictive; in particular, implementing this
rule precisely precludes passing the AtInject TCK, where `@Singleton` beans
have public fields.

This commit relaxes the requirement: all pseudo-scoped beans may have public
fields; normal scoped beans may not. This makes most sense, it is what all
existing implementations do (checked ArC, Weld and OpenWebBeans) and it is
how the TCK is already written.
  • Loading branch information
Ladicek committed Nov 7, 2023
1 parent 7aae05c commit 5bf162e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spec/src/main/asciidoc/core/implementation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ A _managed bean_ is a bean that is implemented by a Java class.
This class is called the _bean class_ of the managed bean.
The basic lifecycle and semantics of managed beans are defined by the Managed Beans specification.


If a managed bean has a non-static public field, it must have scope `@Dependent`. If a managed bean with a non-static public field declares any scope other than `@Dependent`, the container automatically detects the problem and treats it as a definition error.
If a managed bean has a non-static public field, its scope must be a pseudo-scope.
If a managed bean with a non-static public field declares a normal scope, the container automatically detects the problem and treats it as a definition error.

If the managed bean class is a generic type, it must have scope `@Dependent`. If a managed bean with a parameterized bean class declares any scope other than `@Dependent`, the container automatically detects the problem and treats it as a definition error.

Expand Down

0 comments on commit 5bf162e

Please sign in to comment.