[cdi-dev] [JBoss JIRA] (CDI-244) Allow public static fields on managed beans which declare any other scope than dependent

Martin Kouba (JIRA) jira-events at lists.jboss.org
Tue Jul 31 08:22:07 EDT 2012


Martin Kouba created CDI-244:
--------------------------------

             Summary: 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: Feature Request
            Reporter: Martin Kouba


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

        


More information about the cdi-dev mailing list