You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Kris Coolsaet (JIRA)" <ji...@apache.org> on 2009/04/12 11:30:06 UTC

[jira] Created: (WW-3083) Certain annotations should not only be inherited from their super class package but also from their super class itself

Certain annotations should not only be inherited from their super class package but also from their super class itself
----------------------------------------------------------------------------------------------------------------------

                 Key: WW-3083
                 URL: https://issues.apache.org/struts/browse/WW-3083
             Project: Struts 2
          Issue Type: Bug
          Components: Plugin - Convention
    Affects Versions: 2.1.6
            Reporter: Kris Coolsaet
            Priority: Minor


The API documentation of AnnotationTools.findAnnotation expected me to think that  annotation were inherited.

Example: assume mypackage.MyAction extends otherpackage.SuperAction

If MyAction does not have a @ParentPackage annotation and SuperAction does, then I had expected that the parent package of SuperAction would also be used for MyAction. This is not the case. However, if the package-info.java of otherpackage has a @ParentPackage annotation (and mypackage does not) then that annotation is used also for MyAction. This distinction between classes and the packages they belong to, feels counterintuitive.

Apart from @ParentPackage, other annotations might benifit from inheritance as well, e.g., @InterceptorRef.

There are two ways to implement this requested behavior: add and @Inherited (meta-)annotation to the annotations, or reimplement AnnotationTools.findAnnotation to also look at the annotations of the super class. (The latter solution would however not distinguish between different types of annotation.)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-3083) Certain annotations should not only be inherited from their super class package but also from their super class itself

Posted by "Musachy Barroso (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-3083?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Musachy Barroso updated WW-3083:
--------------------------------

    Fix Version/s: 2.1.7

> Certain annotations should not only be inherited from their super class package but also from their super class itself
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-3083
>                 URL: https://issues.apache.org/struts/browse/WW-3083
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Convention
>    Affects Versions: 2.1.6
>            Reporter: Kris Coolsaet
>            Priority: Minor
>             Fix For: 2.1.7
>
>
> The API documentation of AnnotationTools.findAnnotation expected me to think that  annotation were inherited.
> Example: assume mypackage.MyAction extends otherpackage.SuperAction
> If MyAction does not have a @ParentPackage annotation and SuperAction does, then I had expected that the parent package of SuperAction would also be used for MyAction. This is not the case. However, if the package-info.java of otherpackage has a @ParentPackage annotation (and mypackage does not) then that annotation is used also for MyAction. This distinction between classes and the packages they belong to, feels counterintuitive.
> Apart from @ParentPackage, other annotations might benifit from inheritance as well, e.g., @InterceptorRef.
> There are two ways to implement this requested behavior: add and @Inherited (meta-)annotation to the annotations, or reimplement AnnotationTools.findAnnotation to also look at the annotations of the super class. (The latter solution would however not distinguish between different types of annotation.)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WW-3083) Certain annotations should not only be inherited from their super class package but also from their super class itself

Posted by "Musachy Barroso (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-3083?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Musachy Barroso resolved WW-3083.
---------------------------------

    Resolution: Fixed

Good catch. I used your second suggestion, and added some tests. I went for the second option because any annotation that can be applied to the package level, and the action level, should follow the same rules:

#1 try to find the annotation in the class
#2 try to find the annotation in the package
#3 move up in the class hierarchy and go to #1

thanks for reporting.

> Certain annotations should not only be inherited from their super class package but also from their super class itself
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-3083
>                 URL: https://issues.apache.org/struts/browse/WW-3083
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Convention
>    Affects Versions: 2.1.6
>            Reporter: Kris Coolsaet
>            Priority: Minor
>             Fix For: 2.1.7
>
>
> The API documentation of AnnotationTools.findAnnotation expected me to think that  annotation were inherited.
> Example: assume mypackage.MyAction extends otherpackage.SuperAction
> If MyAction does not have a @ParentPackage annotation and SuperAction does, then I had expected that the parent package of SuperAction would also be used for MyAction. This is not the case. However, if the package-info.java of otherpackage has a @ParentPackage annotation (and mypackage does not) then that annotation is used also for MyAction. This distinction between classes and the packages they belong to, feels counterintuitive.
> Apart from @ParentPackage, other annotations might benifit from inheritance as well, e.g., @InterceptorRef.
> There are two ways to implement this requested behavior: add and @Inherited (meta-)annotation to the annotations, or reimplement AnnotationTools.findAnnotation to also look at the annotations of the super class. (The latter solution would however not distinguish between different types of annotation.)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.