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.

Reply via email to