Dynamic Class Loading in Java
来源:互联网 发布:软件怎么发布 编辑:程序博客网 时间:2024/05/02 02:49
It is possible to load and reload classes at runtime in Java, though it is not as straightforward as one might have hoped. This text will explain when and how you can load and reload classes in Java.
The ClassLoader
All classes in a Java application are loaded using some subclass ofjava.lang.ClassLoader
. Loading classes dynamically must therefore also be done using a java.lang.ClassLoader
subclass.
When a class is loaded, all classes it references are loaded too. This class loading pattern happens recursively, until all classes needed are loaded. This may not be all classes in the application. Unreferenced classes are not loaded until the time they are referenced.
Class Loading
The steps a given class loader uses when loading classes are:
- Check if the class was already loaded.
- If not loaded, ask parent class loader to load the class.
- If parent class loader cannot load class, attempt to load it in this class loader.
When you implement a class loader that is capable of reloading classes you will need to deviate a bit from this sequence. The classes to reload should not be requested loaded by the parent class loader.
Dynamic Class Loading
Loading a class dynamically is easy. All you need to do is to obtain a ClassLoader
and call its loadClass()
method
- Dynamic Class Loading in Java
- Java Reflection - Dynamic Class Loading and Reloading
- Dynamic loading in embedded sytem
- Dynamic Class Loading for C++ on Linux
- Custom Class Loading in Dalvik
- Custom Class Loading in Dalvik
- Custom Class Loading in Dalvik
- Custom Class Loading in Dalvik
- Java-Class Loading
- dynamic loading
- Dynamic loading
- Dynamic loading
- Dynamic loading
- Dynamic Loading
- Dynamic developments in Java
- Internals of Java Class Loading
- Internals of Java Class Loading
- Internals of Java Class Loading
- ruby on rails 常用命令
- CloudStack是找Linux社区合作,还是找Java社区合作
- base64加密解密
- 开始整理几年技术生涯的经验和笔记
- C语言中一些关键字的作用
- Dynamic Class Loading in Java
- AJAX请求异常代码含义
- 使用vs2010编译CCV1.5
- Photon服务器引擎 入门教程二
- 使用并行计算大幅提升递归算法效率
- git-svn提交修改出错时的恢复办法
- JAVA经典算法40题(18)
- java实现sftp实例
- 嵌入式系统基础