[
https://issues.jboss.org/browse/CDI-740?page=com.atlassian.jira.plugin.sy...
]
Martin Kouba commented on CDI-740:
----------------------------------
bq. Data classes with public fields would make sense.
I think that data classes are not supposed to be CDI beans whose lifecycle is managed by
the container.
Anyway, if you disallow protected fields you will limit the possibilities of class
hierarchies a lot.
I can't think of any practical reason for package-private fields though. Which of
course does not mean there isn't any ;-)
Proxy fields can be accessed if they are protected or package
private
---------------------------------------------------------------------
Key: CDI-740
URL:
https://issues.jboss.org/browse/CDI-740
Project: CDI Specification Issues
Issue Type: Bug
Components: Beans, Contexts, Java EE integration
Environment: IBM WebSphere Liberty, Java EE 7.0 Full Platform
Reporter: Frigo Coder
Priority: Major
CDI detects and rejects proxyable beans if they expose a public field. However protected
and package private fields are silently accepted. In the following example the method
returns 0 instead of the correct value of 8:
{code:java}
@ApplicationScoped
public class Car {
@Inject
private Engine engine;
public int numberOfEngineCylinders() {
return engine.cylinders;
}
}
@RequestScoped
public class Engine {
protected int cylinders;
@PostConstruct
public void init() {
cylinders = 8;
}
}
{code}
--
This message was sent by Atlassian Jira
(v7.12.1#712002)