Dahakka
Dahakka

Reputation: 277

Using java annotations without CDI

I have been searching for a while, but I could not found any usefull informations about my question. is it possible to use Java annotations without initializing annotation implementation with CDI or EJB?

Upvotes: 1

Views: 114

Answers (1)

Seelenvirtuose
Seelenvirtuose

Reputation: 20658

You can use annotations as much as you like.

Some annotations are used by the compiler, like @Override, for example. Most annotations are available at runtime also, and are heavily used with reflection.

CDI implementations - for example - use reflection to find injection points and injectable types. If you use the typical CDI annotations, but do not have any CDI implementation in your running program, then it just does nothing. That's it. You could - of course - do the reflective analysis yourself.

One additional note about annotations: If the class file of an annotation is not found in the class patth, the annotation on an element will be silently dropped, so that it is not available anymore for reflective access.

Upvotes: 3

Related Questions