Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: reflection (at runtime) versus mirroring (at annotation processing)

I understand the general differences between the concepts of

  • reflection (done at runtime using Class, Method, Field, Annotation, ...), and
  • mirroring (done during annotation processing using TypeMirror, TypeElement, ...).

But can someone please compare the two concepts in-depth (or point me to a resource, where it is done)?

For instance, which concept offers what kinds of information that the other does not offer...

Thank you.

like image 953
java.is.for.desktop Avatar asked Dec 16 '10 20:12

java.is.for.desktop


1 Answers

  • Reflection classes are used to represent the classes of objects in a running JVM. Reflection is a very old concept that has been present in Java since the very beginning. As such, it is a bit clunky in some areas, having been extended to accomodate new language constructs (especially generics).
  • The classes in javax.lang.model are used to work with Java source code. They were designed when Generics already existed and can (and have to) support them much more extensively, since they are used before type erasure happens.
like image 154
Michael Borgwardt Avatar answered Sep 27 '22 22:09

Michael Borgwardt