You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Nicolas Dumont <ni...@gmail.com> on 2010/07/30 11:01:29 UTC

IPojo manipulation & annotation on parameters

Hi,
I am trying to read by reflection annotations at runtime, and I found a
strange behaviour.

I defined some new annotations targeting methods
(@Target(ElementType.METHOD)) or parameters @Target(ElementType.PARAMETER),
with RetentionPolicy set to RUNTIME.

When I look at an ipojo class containing those kind of annotations, I find
the annotations on method, but not on its parameters. I find the parameters
annotations on the parameters of the __method.

Regarding the explanation on
http://felix.apache.org/site/dive-into-the-ipojo-manipulation-depths.html /
"The annotation special case":


"The manipulation has a special behavior when a visible (at runtime) method
or constructor annotation is detected. As the methods are replaced by
private methods, the annotations are moved to the iPOJO replacements such as
in:
public class MyClass {
  @MyAnnotation
  public void myMethod() {
     //my code here
 }
}
is transformed into:
public class MyClass {
  @MyAnnotation
  public void myMethod() {
     // iPojo code here
 }
  private void _myMethod() {
   // my code here
 }
"



In my case I have a annotation on a parameter of myMethod and the observed
result is:

public class MyClass {
  @MyAnnotation
  public void myMethod(@MyParameterAnnotation int param) {
     //my code here
 }
}
is transformed into:
public class MyClass {
  @MyAnnotation
  public void myMethod(int param) {
     // iPojo code here
 }
  private void _myMethod(@MyParameterAnnotation int param) {
   // my code here
 }

Naively I would have think that parameters annotation would have been moved
to the ipojo replacement class, as for methods annotations. Is this a bug or
standard behaviour ?

Thanks in advance.

Re: IPojo manipulation & annotation on parameters

Posted by Clement Escoffier <cl...@gmail.com>.
On 30.07.2010, at 11:01, Nicolas Dumont wrote:

> Hi,
> I am trying to read by reflection annotations at runtime, and I found a
> strange behaviour.
> 
> I defined some new annotations targeting methods
> (@Target(ElementType.METHOD)) or parameters @Target(ElementType.PARAMETER),
> with RetentionPolicy set to RUNTIME.
> 
> When I look at an ipojo class containing those kind of annotations, I find
> the annotations on method, but not on its parameters. I find the parameters
> annotations on the parameters of the __method.
> 
> Regarding the explanation on
> http://felix.apache.org/site/dive-into-the-ipojo-manipulation-depths.html /
> "The annotation special case":
> 
> 
> "The manipulation has a special behavior when a visible (at runtime) method
> or constructor annotation is detected. As the methods are replaced by
> private methods, the annotations are moved to the iPOJO replacements such as
> in:
> public class MyClass {
>  @MyAnnotation
>  public void myMethod() {
>     //my code here
> }
> }
> is transformed into:
> public class MyClass {
>  @MyAnnotation
>  public void myMethod() {
>     // iPojo code here
> }
>  private void _myMethod() {
>   // my code here
> }
> "
> 
> 
> 
> In my case I have a annotation on a parameter of myMethod and the observed
> result is:
> 
> public class MyClass {
>  @MyAnnotation
>  public void myMethod(@MyParameterAnnotation int param) {
>     //my code here
> }
> }
> is transformed into:
> public class MyClass {
>  @MyAnnotation
>  public void myMethod(int param) {
>     // iPojo code here
> }
>  private void _myMethod(@MyParameterAnnotation int param) {
>   // my code here
> }
> 
> Naively I would have think that parameters annotation would have been moved
> to the ipojo replacement class, as for methods annotations. Is this a bug or
> standard behaviour ?


It sounds like a bug :-)
The annotations on parameter are not moved. It should be done. Please open a bug about that on 'https://issues.apache.org/jira/secure/BrowseProject.jspa' (component : iPOJO).

Thanks,

Clement

> 
> Thanks in advance.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org