[Reflection] Type interface system

The Type interface is the super interface of all types. It provides the following sub-interfaces: ParameterizedType: parameterized type GenericArrayType: Generic array type WildcardType: wildcard type TypeVariable: type variable 1. Preparation 1. Introduce dependencies <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>5.9.3</version> <scope>test</scope> </dependency> <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> <version>3.24.2</version> <scope>test</scope> </dependency> 2. Create entities Create a new FieldTypeClass class under the […]

Java reflection calls ashx

This article has been stuck for about a week. One reason is that I don’t have time and I can only squeeze in some time between taking care of the baby and exercising. The other reason is that I encountered a problem and got stuck. This article implements the basic structure of reflective calling ashx […]

Java-Reflection and Annotations

reflection Reflection, literally means mapping in reverse, and its function is the same. Generally, if we want to obtain the internal information of a class during the running of the program, we must first generate an object of this class, and then use this class to expose it to the outside world. Provided methods to […]

Calling a private method of a class’s private inner class using reflection

Article directory Call private methods of a class using reflection kind Implementation Implement code Calling a private method of a class’s private inner class using reflection kind Implementation Implement code When performing unit testing, we often need to directly access the internal class of a certain class or the private method of a certain class. […]

Java-Reflection and Annotations

Article directory reflection Class class method of obtaining Common Functions 1. Access constructor 2. Access member variables 3. Access member methods annotation Reflection Reflection, literally means mapping in reverse, and its function is the same. Generally, if we want to obtain the internal information of a class during the running of the program, we must […]

[Reflection] Method class

The Method class contains detailed information about the method definition. You can use the methods provided in the Method class to obtain method information. Next, we first obtain the Method object, and then introduce how to use the methods provided in the Method class. 1. Preparation Create new BaseEntity class and UserInfoEntity class under the […]

Javareflective-reflection mechanism

Article directory Preface 1. What is reflection? 2. Class class 3. Utilize the ability of reflection analysis class 4. Create instance objects through reflection Foreword The reflection library provides a very rich and well-designed toolset for writing programs that dynamically manipulate Java code. This feature is heavily used in JavaBeans, which is the Java component […]

Hand-written spring instantiation bean source code, implementing the Object getBean(String beanId) method through the reflection mechanism

The handwritten spring instantiation bean source code only implements the Object getBean(String beanId) method. That is to achieve: ApplicationContext applicationContext = new ClassPathXmlApplicationContext(“xxx”); Object o = applicationContext.getBean(“xxx”); //Define ApplicationContext interface: public interface ApplicationContext {<!– –> Object getBean(String name); } // ClassPathXmlApplicationContext class /** * Parse xml files, read tags, and instantiate objects * @param springPath […]

The use of Java reflection and enumeration

The use of Java reflection and enumeration 1. Java reflection mechanism 1.1 Definition of reflection The concept of reflection: The reflection mechanism means that for any class, all the internal information of the class can be obtained during the running process. And for any object, being able to access and modify all its attributes and […]

[Reflection] Field class

The Field class contains detailed information about the field definition. You can use the methods provided in the Field class to obtain field information. Below we first obtain the Field object, and then introduce how to use the methods provided in the Field class. 1. Preparation Create new BaseEntity class and UserInfoEntity class under the […]