版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiaoqiu_cr/article/details/86695091
什么是类索引、父类索引、接口索引集合:
类索引:this_class(u2类型)2个字节 16位
父类索引:super_class(u2类型)2个字节 16位
接口索引集合:interfaces(这里为什么是集合呢,因为我们知道Java中继承接口的时候是可以多继承的)(注意在接口索引集合的入口处还有两个字节的实现接口的数量)
那么我们写一个Java文件分析一下
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class HelloWorld extends FileInputStream implements Runnable,ActionListener{
public HelloWorld(String name) throws FileNotFoundException {
super(name);
}
public HelloWorld(File file) throws FileNotFoundException {
super(file);
}
public HelloWorld(FileDescriptor fdObj) {
super(fdObj);
}
@Override
public void actionPerformed(ActionEvent e) {
}
@Override
public void run() {
}
}
我们查看class文件
类索引(this.class)位0x0004
父类索引为(super.class):0x0005
接口计数器(interface_count):0x0002
第一个接口索引为:0x0006
第二个接口索引为:0x0007
这里的常量池我们同样可以直接通过javap工具进行查看