What's the point of package annotations?

Viewed 15401
6 Answers

I suppose @Deprecated would make sense. And maybe something like @Generated if the whole package was generated by some tool from non-Java source. Or @Internal if this package is not part of a public API.

Maybe OSGi tools (where you need to declare the versions of your packages, and the packages you depend on) could make use of this, too.

Has anyone seen those in the wild?

Two reasons that I can think of:

  • Annotating special packages to let some aspects (for example using AspectJ) to weave the classes in them for specific functionality.
  • Annotating some packages that are to be read by some tools, for example for source, meta-data or other kinds of resource generation.
Related