classloader总结

来源:互联网 发布:哈工大数据结构与算法 编辑:程序博客网 时间:2024/05/18 21:49
项目时需要对外提供一些服务接口,写了接口及其实现发现报castClassException,当时newInstance时采用
Thread.currentContext.getClassLoader的形式,分析了一下发现平台采用了自己的classloader

1.java的classloader采用双亲委托的机制
2.当前类加载器和线程上下文的区别是,当前类加载器在加载caller类时已经确定,但thread's context classloader is modifiable
3.thread's classloader can break through the parent delegation mechanism of classloader
4.it is should keep the thread's classloader same as current class classloader
5.the default form of class.forname isn't recommend,because of exception of initializing static field if the classloader is not
destroied
6.banq comment about adoption thread's  classloader is not correctly

原创粉丝点击