[ 
http://issues.apache.org/jira/browse/TUSCANY-25?page=comments#action_12369461 ] 

Jeremy Boynes commented on TUSCANY-25:
--------------------------------------

Although this seems like useful behaviour, this lead to problems when 
fields/methods in superclasses are annotated in this manner. The Java 
programming model defines specific contracts for sub- or "friend" (same 
package) classes which this definition contradicts.

For example, is the container supposed to inject values into fields/methods 
that a superclass has marked private? What should the container do if a field 
is redefined in a subclass with a different type?

This also leads to a discrepancy between fields/methods described using 
annotations and those using XML sidefiles. For security reasons, the container 
must not allow private or package fields to be made settable simply by being 
defined in 

Private field/method injection also creates problems with testability in that 
the value cannot be initialized easily. The user needs to perform the same 
unsafe operations that the container does.

Finally, this may not be supportable in all environments. It requires that the 
container code run with permissions not normally granted to user code requiring 
an administrative override of the the security model in many environments; this 
may be hard for users to justify.

> @Reference doesn't work on fields with protected or default access modifier
> ---------------------------------------------------------------------------
>
>          Key: TUSCANY-25
>          URL: http://issues.apache.org/jira/browse/TUSCANY-25
>      Project: Tuscany
>         Type: Bug
>   Components: Java SCA POJO Container
>     Reporter: ant elder

>
> The @Reference annotation only works on a field which is private or public. 
> If the field is protected or uses the default access modifier then the 
> reference is silently ignored.
> The section on @Reference in the SCA client and implementaion model for Java 
> doc doesn't clearly say if this is correct or not, but if private and public 
> work then it seems reasonable that the others should as well.
> Looks like this is caused by 
> org.apache.tuscany.container.java.config.Java5ComponentTypeIntrospector 
> method introspectPrivateFields which ignores all fields which aren't private. 
> Also looks like the same problem will happen with @Property or when 
> annotating methods instead of fields. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to