2011.8.17---2011.8.18 续(android的classloader)

追踪bug的时候由于问题是处在类加载器上,所以今天看了下android的类加载过程,总得来说,类加载原理和jvm是相同的,都是采用双亲委派模型(深入jvm里有讲),简单地说就是一个类加载器在加载一个类时,先交给它的父加载器,一直到BootClassLoader,如果它的父加载器没有找到相应的class文件,那么再把加载任务传给孩子,一层层往下传,直到找到相应的class文件为止,如果最终都没有找到class文件,那么加载失败。

 * Loads classes and resources from a repository. One or more class loaders are
 * installed at runtime. These are consulted whenever the runtime system needs a
 * specific class that is not yet available in-memory. Typically, class loaders
 * are grouped into a tree where child class loaders delegate all requests to
 * parent class loaders. Only if the parent class loader cannot satisfy the
 * request, the child class loader itself tries to handle it.

以上是官方描述

 

在android中有三种类加载器

DexClassLoader:可以加载apk,jar以及dex文件

PathClassLoader:只可以加载本地文件系统的apk

在类加载器的责任链中,

此三种类加载器的父亲加载器都是BootClassLoader,这个BootClassLoader来自于java.lang包。

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值