Atitit. External class automatic loading mechanism of Trojan Horse virus ------ Summary of the method for loading class, atitit .------
Atitit. External class automatic loading mechanism of Trojan Horse virus ------ Summary of the method for loading class
Atitit. java load class methods
1. dynamically load jar and class files. 1
2. Use the Class static method Class. forName 1
2.1. Use ClassLoader 1
2.2. Direct new 2
3. Ref 2
1. dynamically load jar and class files.
After completing the above two steps, you can use Class. forName to load the Java class contained in the jar or. Class file.
2. Use Class static method Class. forName
Class cls = Class. forName ("com. rain. B ");
B B B = (B) cls. newInstance ();
2.
Author: nickname: old wow's paw (full name: Attilax Akbar Al Rapanui Attila Akba Arla Panui) Name: AI long, EMAIL: 1466519819@qq.com
Reprinted please indicate Source: http://www.cnblogs.com/attilax/
2.1. Use ClassLoader
/* Step 1. Get ClassLoader */
ClassLoader cl; // for how to obtain ClassLoader, refer to 1.6.
/* Step 2. Load the class */
Class cls = cl. loadClass ("com. rain. B"); // use the ClassLoader obtained in step 1 to load B.
/* Step 3. new instance */
B B B = (B) cls. newInstance (); // a class with B gets an instance of B.
2.2. Direct new
B B = new B ();
1.
3. Ref
ClassLoader detailed explanation and usage (incorrect description)-mcuflower-chinaunixbok.htm
Dynamic Loading of jar files and class files in Java-blog channel-CSDN.NET.htm