当前位置:网站首页>JVM——》类文件

JVM——》类文件

2022-06-10 00:28:00 小仙。

推荐链接:
    总结——》【Java】
    总结——》【JVM】
    总结——》【Mysql】
    总结——》【Spring】
    总结——》【SpringBoot】

一、类文件的结构

参考链接:【官网】jvms-4.The class File Format

ClassFile {
    u4             magic;
    u2             minor_version;
    u2             major_version;
    u2             constant_pool_count;
    cp_info        constant_pool[constant_pool_count-1];
    u2             access_flags;
    u2             this_class;
    u2             super_class;
    u2             interfaces_count;
    u2             interfaces[interfaces_count];
    u2             fields_count;
    field_info     fields[fields_count];
    u2             methods_count;
    method_info    methods[methods_count];
    u2             attributes_count;
    attribute_info attributes[attributes_count];
}

u:unsigned,无符号整数
u1:1个字节
u2:2个字节
u4:4个字节
_info:表类型,是hotspot源码中的写法
在这里插入图片描述

二、类文件的查看

1、16进制

(1)sublime / notepad

![](https://img-blog.csdnimg.cn/img_convert/6881d625462e761d18004de13a6fca33.png#crop=0&crop=0&crop=1&crop=1&from=url&id=MVfVz&margin=[object Object]&originHeight=577&originWidth=597&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)

(2)idea plugin:BinEd

2、字节码

(1)javap

public class T0100_ByteCode01 {
    
}

/** * 1、打开cmd * 2、执行javap -v E:\IdeaProjects_mine\msb\JVM\out\production\JVM\com\mashibing\jvm\c1_bytecode\T0100_ByteCode01.class */

在这里插入图片描述

(2)idea plugin:Jclasslib Bytecode viewer

下载IDEA的插件:Settings->plugin->BinEd
查看view:show bytecode with jclasslib

<1>信息

在这里插入图片描述

<2>常量池

在这里插入图片描述
在这里插入图片描述

<3>方法

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

(3)JBE

原网站

版权声明
本文为[小仙。]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_43453386/article/details/125068797