Atitit. 木马病毒的外部class自动加载机制------加载class的方法总结

Atitit. 木马病毒的外部class自动加载机制------加载class的方法总结

Atitit.java load class methods

 

1动态加载jar文件和class文件。 1

2 使用Class静态方法 Class.forName  1

2.1. 使用ClassLoader  1

2.2. 3. 直接new  2

3Ref 2

 

1. 动态加载jar文件和class文件。

完成上述两步操作后,即可使用Class.forName来加载jar中或.class文件包含的Java类了。

 

2.  使用Class静态方法 Class.forName  



    Class cls = Class.forName("com.rain.B"); 
    B b = (B)cls.newInstance(); 

2. 

作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙,  EMAIL:1466519819@qq.com

转载请注明来源: http://blog.csdn.net/attilax

 

2.1. 使用ClassLoader  


    /* Step 1. Get ClassLoader */ 
    ClassLoader cl; // 如何获得ClassLoader参考1.6 

    /* Step 2. Load the class */ 
    Class cls = cl.loadClass("com.rain.B"); // 使用第一步得到的ClassLoader来载入B 
     
    /* Step 3. new instance */ 
    B b = (B)cls.newInstance(); // 有B的类得到一个B的实例 

2.2. 3. 直接new  


    B b = new B();

1.

3. Ref 

 

ClassLoader 详解及用途(写的不错)-mcuflower-ChinaUnix博客.htm

 

Java中动态加载jar文件和class文件 - - 博客频道 - CSDN.NET.htm

原文地址:https://www.cnblogs.com/attilax/p/5963447.html