java反射测试
来源:互联网 发布:从入门到精通java 编辑:程序博客网 时间:2024/06/05 03:04
测试类
public class T {/** * @param args * @throws ClassNotFoundException * @throws NoSuchMethodException * @throws SecurityException * @throws InvocationTargetException * @throws IllegalAccessException * @throws IllegalArgumentException */@SuppressWarnings("unchecked")public static void main(String[] args) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {// TODO Auto-generated method stubClassLoader cl = T.class.getClassLoader();Class<StaticTest> staticTest = (Class<StaticTest>) cl.loadClass("com.study.StaticTest");Method startup = staticTest.getMethod("startup", Integer.class);startup.invoke(staticTest, 13);System.out.println(staticTest);}}
被测试类
public class StaticTest {static {System.out.println("I'm static");}public StaticTest() {System.out.println("I'm constructor ");}public static void startup(Integer time) {System.out.println(time);}}
输出结果:
I'm static13class com.study.StaticTest
0 0
- 测试Java反射效率
- JAVA反射性能测试
- JAVA反射测试
- java 反射 测试
- java反射机制测试
- JAVA反射性能测试
- java反射性能测试
- java反射测试
- java反射测试
- 测试java反射机制
- java反射性能测试分析
- java反射性能测试分析
- java反射性能测试分析
- 成功测试java反射机制
- Java中反射性能测试
- Java中反射性能测试
- java的反射性能测试
- JAVA反射--通过反射对pojo进行UT覆盖率测试
- Linux下程序调试相关工具与技巧
- 对面向切面编程的简单理解
- 说说做二飞日志的目的
- 玻璃瓶 给产品穿上最靓丽的“外衣”
- hdu 3516 Tree Construction(四边形优化)
- java反射测试
- 代码碎片
- 使用SharedPreferences对象保存数据
- 创建ServerSocket对象
- Fibonacci数
- codeforces #508B# Anton and currency you all know(贪心)
- 自动清除日期目录shell脚本
- 亿级用户下的新浪微博平台架构
- Android如何监控本应用被卸载