Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Annotation processing (in Java 1.6 flavour)
Annotation processing (in Java 1.6 flavour) [message #259338] Sun, 05 April 2009 11:18 Go to next message
Eclipse UserFriend
I wrote a simple annotation processor catching some annotations on methods
and constructors. Apparently I can not access parameters because the
method getParameters() of ExecutableElement always return a void list.

It is because this functionality is not yet implemented or it is an error?

Federico
Re: Annotation processing (in Java 1.6 flavour) [message #259342 is a reply to message #259338] Mon, 06 April 2009 01:22 Go to previous messageGo to next message
Eclipse UserFriend
"Federico Tomassetti" <f.tomassetti@gmail.com> wrote in message
news:0ffbd510f9569b38f76e0fe44a3a7ded$1@www.eclipse.org...
>I wrote a simple annotation processor catching some annotations on methods
>and constructors. Apparently I can not access parameters because the method
>getParameters() of ExecutableElement always return a void list.
>
> It is because this functionality is not yet implemented or it is an error?

There have been some bugs fixed recently regarding annotations on
parameters. What version of Eclipse are you using? Can you try Eclipse
3.4.2, and/or Eclipse 3.5 M5, and see if the problem still exists?
Re: Annotation processing (in Java 1.6 flavour) [message #259421 is a reply to message #259342] Tue, 07 April 2009 14:32 Go to previous messageGo to next message
Eclipse UserFriend
Walter Harley wrote:

> "Federico Tomassetti" <f.tomassetti@gmail.com> wrote in message
> news:0ffbd510f9569b38f76e0fe44a3a7ded$1@www.eclipse.org...
>>I wrote a simple annotation processor catching some annotations on methods
>>and constructors. Apparently I can not access parameters because the method
>>getParameters() of ExecutableElement always return a void list.
>>
>> It is because this functionality is not yet implemented or it is an error?

> There have been some bugs fixed recently regarding annotations on
> parameters. What version of Eclipse are you using? Can you try Eclipse
> 3.4.2, and/or Eclipse 3.5 M5, and see if the problem still exists?

First of all thank you for you reply.

Under Eclipse 3.4.0 I used this code:
@SupportedAnnotationTypes("it.tomassetti.NotNullParams") // Process all
annotations
@SupportedSourceVersion(RELEASE_6)
public class CommonAnnoProcessor extends AbstractProcessor {

@Override
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
for (Element e :
roundEnv.getElementsAnnotatedWith(NotNullParams.class)){
if (e instanceof ExecutableElement){
ExecutableElement ee = (ExecutableElement)e;
String s =
"name="+ee.getSimpleName()+",n_params="+ee.getParameters().size();
this.processingEnv.getMessager().printMessage(Kind.OTHER, "Annotated
"+s, e);
} else {
this.processingEnv.getMessager().printMessage(Kind.ERROR, "Not
executable element", e);
}
}
return true;
}

}

---

package it.tomassetti;
import it.tomassetti.NotNullParams;


public class TestA {

@NotNullParams("")
public void a(){

}

@NotNullParams("")
public void b(){

}

@NotNullParams("")
public void c(int a){

}

@NotNullParams("")
public void d(String a, String b){

}

}

---

In the editor I can see a note on all of my methods (a,b,c,d) and all of
theese notes reports that the number of parameters is zero.

I am going to test it under Eclipse 3.4.2 and look if it behaves
differently.

Federico Tomassetti
Re: Annotation processing (in Java 1.6 flavour) [message #259425 is a reply to message #259421] Tue, 07 April 2009 14:48 Go to previous messageGo to next message
Eclipse UserFriend
Federico Tomassetti wrote:

> Walter Harley wrote:

>> "Federico Tomassetti" <f.tomassetti@gmail.com> wrote in message
>> news:0ffbd510f9569b38f76e0fe44a3a7ded$1@www.eclipse.org...
>>>I wrote a simple annotation processor catching some annotations on methods
>>>and constructors. Apparently I can not access parameters because the method
>>>getParameters() of ExecutableElement always return a void list.
>>>
>>> It is because this functionality is not yet implemented or it is an error?

>> There have been some bugs fixed recently regarding annotations on
>> parameters. What version of Eclipse are you using? Can you try Eclipse
>> 3.4.2, and/or Eclipse 3.5 M5, and see if the problem still exists?

> First of all thank you for you reply.

> Under Eclipse 3.4.0 I used this code:
> @SupportedAnnotationTypes("it.tomassetti.NotNullParams") // Process all
> annotations
> @SupportedSourceVersion(RELEASE_6)
> public class CommonAnnoProcessor extends AbstractProcessor {

> @Override
> public boolean process(Set<? extends TypeElement> annotations,
> RoundEnvironment roundEnv) {
> for (Element e :
> roundEnv.getElementsAnnotatedWith(NotNullParams.class)){
> if (e instanceof ExecutableElement){
> ExecutableElement ee = (ExecutableElement)e;
> String s =
> "name="+ee.getSimpleName()+",n_params="+ee.getParameters().size();
> this.processingEnv.getMessager().printMessage(Kind.OTHER, "Annotated
> "+s, e);
> } else {
> this.processingEnv.getMessager().printMessage(Kind.ERROR, "Not
> executable element", e);
> }
> }
> return true;
> }

> }

> ---

> package it.tomassetti;
> import it.tomassetti.NotNullParams;


> public class TestA {

> @NotNullParams("")
> public void a(){

> }

> @NotNullParams("")
> public void b(){

> }

> @NotNullParams("")
> public void c(int a){

> }

> @NotNullParams("")
> public void d(String a, String b){

> }

> }

> ---

> In the editor I can see a note on all of my methods (a,b,c,d) and all of
> theese notes reports that the number of parameters is zero.

> I am going to test it under Eclipse 3.4.2 and look if it behaves
> differently.

> Federico Tomassetti
Under Eclipse 3.4.2 the correct number of params is recognized.

Federico Tomassetti
Re: Annotation processing (in Java 1.6 flavour) [message #259481 is a reply to message #259425] Wed, 08 April 2009 22:42 Go to previous message
Eclipse UserFriend
"Federico Tomassetti" <f.tomassetti@gmail.com> wrote in message
news:1ac702301b5ae758631eadf89e50d277$1@www.eclipse.org...
> Under Eclipse 3.4.2 the correct number of params is recognized.

Good. Yes, I think this was
https://bugs.eclipse.org/bugs/show_bug.cgi?id=248163 , fixed in 3.4.2.
Previous Topic:Can I have all my workspaces use the same preferences?
Next Topic:compilation error indicator in java editor
Goto Forum:
  


Current Time: Wed May 07 13:13:21 EDT 2025

Powered by FUDForum. Page generated in 0.03598 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top