Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

Annotation on interface method argument

Thread view: 
Marc - 14 Jul 2007 12:27 GMT
Hello,

i have an interface like this:

public interface I {
  void foo(@MyAnnotation Object o);
}

It seems that the annotation is ignored by eclipse JDT. So is it a bug
in eclipse or is it part of the annotations specifications ?
Tom Hawtin - 14 Jul 2007 14:28 GMT
> public interface I {
>   void foo(@MyAnnotation Object o);
> }
>
> It seems that the annotation is ignored by eclipse JDT. So is it a bug
> in eclipse or is it part of the annotations specifications ?

Does it work using Sun's javac? How have you set up the retention
policy, and how are you determining whether the annotation is present? A
small, complete, compilable example wouldn't go amiss.

Tom Hawtin
Marc - 14 Jul 2007 15:04 GMT
Tom Hawtin a écrit :

>> public interface I {
>>   void foo(@MyAnnotation Object o);
[quoted text clipped - 6 lines]
> policy, and how are you determining whether the annotation is present? A
> small, complete, compilable example wouldn't go amiss.

I don't know if it's work with javac, since i'm using eclipse AST API. I
think, it's just a misuse of the eclipse API by me, since the AST view
plugin show the annotation. Sorry for bothering.
Marc - 14 Jul 2007 15:23 GMT
Tom Hawtin a écrit :

>> public interface I {
>>   void foo(@MyAnnotation Object o);
[quoted text clipped - 8 lines]
>
> Tom Hawtin

Sorry for the previous post, i was wrong. So the small compilable
example would be:

//--
package org;
public @interface MyAnnotation {
}

//--
// from here, I1.foo() doesn't have any annotations on
// its arguments
public class X implements I1, I2 {
  public void foo(Object o1, Object o2) {
  }
}

//--
public interface I1 {
  void foo(@MyAnnotation Object o1, Object o2);
}

//--
public interface I2 {
  void foo(Object o1, @MyAnnotation Object o2);
}

I tried to put @Retention(RetentionPolicy.RUNTIME) but nothing changes.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.