[
https://issues.jboss.org/browse/CDI-244?page=com.atlassian.jira.plugin.sy...
]
Pete Muir commented on CDI-244:
-------------------------------
I think I pushed a fix to my clone on github, but it's not showing up in the UI. Note
to self, remember to issue a pull when github is fixed ;-)
Allow public static fields on managed beans which declare any other
scope than dependent
----------------------------------------------------------------------------------------
Key: CDI-244
URL:
https://issues.jboss.org/browse/CDI-244
Project: CDI Specification Issues
Issue Type: Clarification
Reporter: Martin Kouba
Assignee: Pete Muir
Fix For: 1.1 (Proposed)
See 3.1. Managed beans:
{quote}
If a managed bean has a public field, it must have scope @Dependent. If a managed bean
with a public field declares any scope other than @Dependent, the container automatically
detects the problem and treats it as a definition error.
{quote}
I see no reason why to disallow public _static_ fields on normal scoped beans. To treat
public _non-static_ fields as a definition error due to proxy generation is reasonable.
However public static fields are usually referenced by the class name and refering to
static fields with an object reference (proxy in this case) is discouraged. Moreover,
protected and package-private fields which might also cause confusion around proxies are
allowed.
BTW Weld allows public static fields on normal scoped beans at the moment.
Maybe the spec wording could be:
{quote}
3.1. Managed beans
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.
{quote}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira