I read about Java Reflections, but so far it has been an uncertain concept to me.
Here is a brief reflection in java:
Structural introspection . The main reflection concerns the introspection of the object at runtime. This means that you can study the structure of objects and classes at runtime programmatically, for example. get the class of the object, list the methods of the class, list the fields defined in the class, etc.
Reflective invocation and instantiation . With reflection, you can call a method at runtime that is not defined at compile time, for example. invoke method named M on object O, where M is read in the configuration file. You can also create objects dynamically without knowing the class at compile time.
Annotation . Then you can move up one level in the meta levels and play with annotations. Annotations describe other elements such as class, method, and fields. Many foundations rely on this.
Dynamic proxy . Dynamic proxies can be created at runtime. In this case, indeed, if you create the class dynamically at runtime. Use with caution, but in some cases it is very convenient and powerful.
I think you will start with structural introspection. Other answers have links to tutorials, but I hope this gives you an overview of what else can be done.
source share