the class inspection in JVM

before the Java classloader begin to excute a class file, it will need to check out the file four times.
1.check the structure of the file
 the first inspection happen before the class was loaded. JVM will check the Magic number 0XCAFEBABE to make sure it load a Java class file. Then it will check the main version and sub version to ensure the JVM can support it.
also JVM will check the type and length of all parts of the class file.
2.check the semantic of the type data
 this phrase happen in the link stage. it will check all parts of the file. the inspection will detect the structures. also it will make sure that the class file observes the java language specification
3.byte code inspection
 in this phrase the jvm will analyse the byte code stream via data graph. it is excuted in the link stage. for example, the jvm will ensure that operate stack contains the correct value and type, the local param has been evaluated before using, and in the class field it contains the rigth type, when a method was called, it pass the right value and type param. the bytecode inspection also will ensure that every operation should be legal.
4.symbol reference inspection
in the dynamic link stage, if a symbol reference including in one class file is resolving, the jvm will trace such reference to make sure it is correct. if the jvm find that the class which the referenc point to can not be loaded it will throw a NoClassDefFoundError exception. if not, the jvm will load the class if necessary and then replace the symbol reference with direct reference.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值