reflect

Practical Applications of Reflection - Building Log Objects

Preface In our practical development, we often use reflection, I present an example of the logging function done by reflection in practical development. Traditional logging Some basic knowledge about reflection can be found in Reflection Primer. I believe that logging is not new to you, in the actual development of some more sensitive data tables we need to record every operation of it. First, let’s look at the traditional way of writing.

Java reflection mechanism

What is Reflection In the runtime state, for any class, you can know all the properties and methods of the class; for any object, you can call any of its methods and properties; this dynamically obtained information and dynamic invocation of the object’s methods is called the reflection mechanism of the Java language. So what can we do with reflection? Analyze classes at runtime. Look at objects at runtime. We can also use reflection to write a toString method for all classes to use.