This discussion is archived
2 Replies Latest reply: Mar 17, 2010 2:43 AM by 791266 RSS

Is it with ClassLoader that frameworks work with annotations?

800288 Newbie
Currently Being Moderated
I was reading about the ClassLoader class, and wondering if the usual way to handle annotations (by frameworks, for example) is by overriding the default class loader.
Is it?
  • 1. Re: Is it with ClassLoader that frameworks work with annotations?
    843798 Newbie
    Currently Being Moderated
    Using class loaders and byte code manipulation is one way to make use of annotation.

    But you can do a ton of different things with annotations. If you simply want to get some values from the annotations and don't need them to magically influence the behaviour or the annotated object itself, then you don't need to do any class loader magic at all.

    A third way is to use apt to react to the presence of an annotation at compilation time, in which case you usually don't need any class loader tricks either.
  • 2. Re: Is it with ClassLoader that frameworks work with annotations?
    791266 Explorer
    Currently Being Moderated
    wellington7 wrote:
    I was reading about the ClassLoader class, and wondering if the usual way to handle annotations (by frameworks, for example) is by overriding the default class loader.
    Is it?
    You need to be a more specific than that. Some are using custom classloaders, but most of them aren't. It all depends on what you want to accomplish.

    Kaj