APT (Annotation Processing Tool)

Nuwan Arambage picture Nuwan Arambage · Feb 17, 2011 · Viewed 12.6k times · Source

I was trying to find simple example to understand the usage of apt command, but I couldn't find a helpful resource for this.

I have referred this Getting Started with the Annotation Processing Tool but I do get a high level understanding. Moreover I want to write a code to test apt command. Can somebody post a simple example or better link to refer?

Answer

kschneid picture kschneid · Feb 17, 2011

Here's an example of creating a Note annotation and associated processor:

APT: Compile-Time Annotation Processing with Java

Update. As of Java 1.7:

JSR 269, also known as the Language Model API, has two basic pieces: an API that models the Java programming language, and an API for writing annotation processors. This functionality is accessed through new options to the javac command; by including JSR 269 support, javac now acts analogously to the apt command in JDK 5.