Jump to content

Talk:Java annotation

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Just added in a line in 'See Also' mentioning the equivelent construct from .NET, Attributes which predate this by a while. I'm sure there's languages out there that actually supply a much older example, so maybe it's worth finding a very early example of this kind of declarative/reflective reasoning and inter-referencing the articles.

Additionally, I know this sounds odd, given what I've just done, but is it really worth having a whole article on a small langauge feature like this? I know it's new, but it seems very much something that could live in another article. The .NET languages do not have an 'Attributes' page, and the feature has been around since inception and is supported in just about every language that runs in the CLR. Seems like a merge-candidate to me....

84.12.100.241 10:31, 15 April 2007 (UTC)[reply]

Alternative to XML?

[edit]

The article claims that "many times" annotations are used as an alternative to XML. Apart from the weaselly "many times", what does this mean? AFAICT the two are completely orthogonal. I could say something like

@FooFile("foo.xml")

or

@FooInfo("<bar><spam>quux</spam></bar>")

I could use reflection to serialize annotation data as XML, I could use information that happened to be represented as XML to generate annotations, etc., etc.

Annotations are a programming construct. XML is, well, I don't want to open that can of worms too far, but let's say "a syntax and a data model" and leave it at that. This sounds like one of those "Is it farther to Chicago or by boat?" comparisons. -Dmh 12:36, 26 September 2007 (UTC)[reply]

  • The point of the comparison is about how you associate metadata with a class. Many frameworks (like hibernate) required an XML file that maps data in a class to how it should be persisted. They later added annotations like @Id to indicate which field/methods represent the unique id of an object, @ManyToOne to indicate cardinality of a relationship, and so forth. Javamage (talk) 18:18, 3 August 2009 (UTC)[reply]

Impact and Perception

[edit]

The content of this paragraph was really purely written:

Pros
Declarative programming
Annotations allow the programmer to declare in their source code how the software should behave. It is an example of how declarative programming constructs can be added to an object oriented language.
Cons
Performance
Adding metadata to a run time causes additional memory overhead.
Standards lack
There are few standards that dictate what metadata tags should be used.

As to the Cons above - the application performance is not affected by adding metadata. The metadata are just a part of solution and their effectiveness shall be compared to some other type of solution. Also, the Standards lack does not make sense here.Standards of what?--Stagalj (talk) 15:49, 9 February 2008 (UTC)[reply]

Uncited Source and Innacuracy in "History"

[edit]

Part of the "History" section, particularly the beginning, was copied from Annotations.

Also, where the same section says "version 1.5" and "version 1.6," Sun says "release 5.0" and (outside of the above article) "release 6.0." Are these in agreement or not? (I know that Sun renamed 1.5 to 5.0, but I don't know whether the old format is still accurate.) —Preceding unsigned comment added by Jesdisciple (talkcontribs) 17:56, 28 April 2008 (UTC)[reply]

What do they do?

[edit]

Being a complete 0 at the subject, i read the whole article and still got absolutely no idea on how an annotation would alter an entity. An example of an annotated vs. equal unannotated code would be very helpful. 78.107.153.188 (talk) 19:34, 22 April 2010 (UTC)[reply]

I didn't understand the article, and that is not for lack of knowledge. I believe the link Of Java Annotations by John Hunt is the best example on how the article should be structured: that external article have the right kind of information needed to introduce the concept. Rursus dixit. (mbork3!) 09:43, 15 June 2010 (UTC)[reply]

setId() ????

[edit]

I recommend removing the 'setId()' function from the 4th example as it is not needed for the illustration and is against the design, because we stated that the 'id' is a primary key which is automatically generated by the database. Changing a database-calculated primary key value has no point. Doing it from the application has even less. Notinlist (talk) 08:54, 6 June 2011 (UTC)[reply]

EJB code is far from comment in text

[edit]

This page has an EJB example showing the mapping of an entity bean to a relational model, as accomplished by annotations. The code is far away from a comment about ORM, and that distance makes it confusing.

I also suggest mentioning that annotations are fully qualified with package names; e.g., you can write @java.lang.Deprecated if you want to be especially verbose. — Preceding unsigned comment added by 108.35.229.42 (talk) 15:49, 7 February 2012 (UTC)[reply]

Example much too complex

[edit]

I think that the example tries to do too much. I'm using annotations very day (even coding custom ones), and even I find the example very difficult to understand. Too much code there. Hervegirod (talk) 13:19, 23 March 2014 (UTC)[reply]

[edit]

Hello fellow Wikipedians,

I have just modified one external link on Java annotation. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:

When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.

This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}} (last update: 5 June 2024).

  • If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
  • If you found an error with any archives or the URLs themselves, you can fix them with this tool.

Cheers.—InternetArchiveBot (Report bug) 23:33, 19 April 2017 (UTC)[reply]

Add Javadoc

[edit]

It appears that annotations external to javadoc entries must follow the javadoc entries.

Adding javadoc to the example would help illustrate these relationships.

Don Brutzman (talk) 14:46, 29 January 2022 (UTC)[reply]

Custom annoations examples do not clearly demonstrate what annotations actually do/how they work

[edit]

For instance, this example is presented:

  // Same as: @Edible(value = true)
  @Edible(true)
  Item item = new Carrot();
  
  public @interface Edible {
      boolean value() default false;
  }
  
  @Author(first = "Oompah", last = "Loompah")
  Book book = new Book();
  
  public @interface Author {
      String first();
      String last();
  }

However, there is no demonstration of how to actually do anything useful with the "Edible" value when the annotation is applied to a class. The example demonstrates applying @Edible(true) to a Carrot but it doesn't show how to do anything with this information. 81.187.9.95 (talk) 19:52, 9 October 2024 (UTC)[reply]