`
comain
  • 浏览: 2849 次
文章分类
社区版块
存档分类
最新评论

Re: 问个classloader的问题

阅读更多

找到了一个解释,期待更深入的。

Class.forName vs ClassLoader.loadClass. There are some subtle differences
between these two APIs. The method call CL.loadClass(C), where CL is our ClassLoader and C is the name of the class to load, queries the ClassLoader directly for the class by name. This in turn relies on ClassLoader delegation to ask the bootstrap ClassLoader to determine if the class has already been loaded. Conversely, the method call Class.forName(C, false, CL) uses the VM’s internal class resolution mechanism to do the actual loading. Among other things, this allows Class.forName to support the loading of arrays of Classes as a type; for example, calling CL.loadClass(“[C;”) will result in failure, where doing the same with Class.forName(“[C;”, false, CL) will succeed.

分享到:
评论

相关推荐

    classloader 热部署

    3. **重定义类(Re-definition)**:Java提供了一个名为`Instrumentation`的接口,通过Java代理API(java.lang.instrument)可以实现对已加载类的动态修改,这在热部署中起到关键作用。 4. **线程安全与同步**:在...

    Android 换皮肤源码.zip

    "Android 换皮肤源码.zip"可能包含了一个实现这一功能的示例项目,我们可以从这个压缩包中的两个文件名"Re_Skin1"和"Re_Skin"推测,它们可能是实现换肤功能的不同部分或者不同版本。 Android换肤技术主要涉及到以下...

    java中File的相对路径与绝对路径总结

    - **使用绝对路径时**,虽然可以更精确地定位文件,但同时也需要注意跨平台兼容性的问题,如Windows和Linux下的路径分隔符不同。 - **在使用`getResource()`方法时**,如果路径不以`/`开头,则默认是从调用该方法的...

    tomcat-8_API

    and putting them in the shared classloader instead (JARs should be put in the "lib" folder, and classes should be put in the "classes" folder). ====================== Security manager URLs: ========...

    tomcat-7_API_帮助文档

    and putting them in the shared classloader instead (JARs should be put in the "lib" folder, and classes should be put in the "classes" folder). ================ Tomcat on Linux: ================ ...

Global site tag (gtag.js) - Google Analytics