简体   繁体   English

Java:反射(在运行时)与镜像(在注释处理中)

[英]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 反射 (在运行时使用Class, Method, Field, Annotation, ... ),和
  • mirroring (done during annotation processing using TypeMirror, TypeElement, ... ). 镜像 (使用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. 谢谢。

  • Reflection classes are used to represent the classes of objects in a running JVM . 反射类用于表示正在运行的JVM中的对象类。 Reflection is a very old concept that has been present in Java since the very beginning. 反射是一个非常古老的概念,从一开始就存在于Java中。 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 . javax.lang.model中的类用于处理Java源代码 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. 它们是在Generics已经存在的情况下设计的,并且可以(并且必须)更广泛地支持它们,因为它们是类型擦除发生之前使用的。

我想你会在本文中找到答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM