首页 > 其他分享 >【JVM】Class文件结构详解

【JVM】Class文件结构详解

时间:2023-02-10 08:11:24浏览次数:41  
标签:appservice Ljava dto Utf8 customs goldjet 详解 JVM Class

1  简介

Class文件是一组以字节为基础单位的二进制流。

JVM的数据入口就是我们平时代码编译后的Class文件,那么要搞懂JVM的原理之前,就要了解Class文件里边都是什么,才能更好的理解JVM原理。

内容比较多,希望看到的小伙伴也能自己动手,边看边解析一个自己的Class文件,光看不操作其实等于白看,因为过两天你就忘了

2  准备工作

一个Class文件 、NotePad++文本文件查看

Class文件,用文本工具打开,是一堆乱码,因为它本身是二进制流的。

用NotePad++的插件有个HEX插件,就是以16进制的方式显示。

 

javap -verbose .class 反编译看看Class文件信息

  1 kuku@DESKTOP-KQS9B3J MINGW64 ~/Desktop
  2 $ javap -verbose BscDictService.class
  3 Classfile /C:/Users/kuku/Desktop/BscDictService.class
  4   Last modified 2022-6-9; size 1727 bytes
  5   MD5 checksum 87ad0a7a75e3755bdbb266ee5e77a998
  6   Compiled from "BscDictService.java"
  7 public interface com.goldjet.appservice.customs.application.bsc.BscDictService extends com.bitsun.core.framwork.application.IApplicationService
  8   minor version: 0
  9   major version: 52
 10   flags: ACC_PUBLIC, ACC_INTERFACE, ACC_ABSTRACT
 11 Constant pool:
 12    #1 = Class              #31            // com/goldjet/appservice/customs/application/bsc/BscDictService
 13    #2 = Class              #32            // java/lang/Object
 14    #3 = Class              #33            // com/bitsun/core/framwork/application/IApplicationService
 15    #4 = Utf8               save
 16    #5 = Utf8               (Lcom/goldjet/appservice/customs/dto/req/bcs/BscDictReqDto;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 17    #6 = Utf8               MethodParameters
 18    #7 = Utf8               reqDto
 19    #8 = Utf8               deleteByIds
 20    #9 = Utf8               (Ljava/lang/String;)Ljava/lang/Void;
 21   #10 = Utf8               ids
 22   #11 = Utf8               doPager
 23   #12 = Utf8               (Ljava/util/Map;)Lcom/bitsun/core/common/persistence/Pager;
 24   #13 = Utf8               params
 25   #14 = Utf8               Signature
 26   #15 = Utf8               (Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;)Lcom/bitsun/core/common/persistence/Pager<Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;>;
 27   #16 = Utf8               selectOne
 28   #17 = Utf8               (Ljava/lang/Long;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 29   #18 = Utf8               id
 30   #19 = Utf8               (Ljava/util/Map;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 31   #20 = Utf8               (Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 32   #21 = Utf8               updateProps
 33   #22 = Utf8               (Ljava/lang/Long;Ljava/util/Map;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 34   #23 = Utf8               (Ljava/lang/Long;Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 35   #24 = Utf8               (Ljava/lang/Long;Lcom/goldjet/appservice/customs/dto/req/bcs/BscDictReqDto;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 36   #25 = Utf8               selectDictItemByDictCode
 37   #26 = Utf8               (Ljava/lang/String;)Ljava/util/List;
 38   #27 = Utf8               dictCode
 39   #28 = Utf8               (Ljava/lang/String;)Ljava/util/List<Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictItemResDto;>;
 40   #29 = Utf8               SourceFile
 41   #30 = Utf8               BscDictService.java
 42   #31 = Utf8               com/goldjet/appservice/customs/application/bsc/BscDictService
 43   #32 = Utf8               java/lang/Object
 44   #33 = Utf8               com/bitsun/core/framwork/application/IApplicationService
 45 {
 46   public abstract com.goldjet.appservice.customs.dto.res.bcs.BscDictResDto save(com.goldjet.appservice.customs.dto.req.bcs.BscDictReqDto);
 47     descriptor: (Lcom/goldjet/appservice/customs/dto/req/bcs/BscDictReqDto;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 48     flags: ACC_PUBLIC, ACC_ABSTRACT
 49     MethodParameters:
 50       Name                           Flags
 51       reqDto
 52 
 53   public abstract java.lang.Void deleteByIds(java.lang.String);
 54     descriptor: (Ljava/lang/String;)Ljava/lang/Void;
 55     flags: ACC_PUBLIC, ACC_ABSTRACT
 56     MethodParameters:
 57       Name                           Flags
 58       ids
 59 
 60   public abstract com.bitsun.core.common.persistence.Pager<com.goldjet.appservice.customs.dto.res.bcs.BscDictResDto> doPager(java.util.Map<java.lang.String, java.lang.Object>);
 61     descriptor: (Ljava/util/Map;)Lcom/bitsun/core/common/persistence/Pager;
 62     flags: ACC_PUBLIC, ACC_ABSTRACT
 63     MethodParameters:
 64       Name                           Flags
 65       params
 66     Signature: #15                          // (Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;)Lcom/bitsun/core/common/persistence/Pager<Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;>;
 67 
 68   public abstract com.goldjet.appservice.customs.dto.res.bcs.BscDictResDto selectOne(java.lang.Long);
 69     descriptor: (Ljava/lang/Long;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 70     flags: ACC_PUBLIC, ACC_ABSTRACT
 71     MethodParameters:
 72       Name                           Flags
 73       id
 74 
 75   public abstract com.goldjet.appservice.customs.dto.res.bcs.BscDictResDto selectOne(java.util.Map<java.lang.String, java.lang.Object>);
 76     descriptor: (Ljava/util/Map;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 77     flags: ACC_PUBLIC, ACC_ABSTRACT
 78     MethodParameters:
 79       Name                           Flags
 80       params
 81     Signature: #20                          // (Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 82 
 83   public abstract com.goldjet.appservice.customs.dto.res.bcs.BscDictResDto updateProps(java.lang.Long, java.util.Map<java.lang.String, java.lang.Object>);
 84     descriptor: (Ljava/lang/Long;Ljava/util/Map;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 85     flags: ACC_PUBLIC, ACC_ABSTRACT
 86     MethodParameters:
 87       Name                           Flags
 88       id
 89       params
 90     Signature: #23                          // (Ljava/lang/Long;Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 91 
 92   public abstract com.goldjet.appservice.customs.dto.res.bcs.BscDictResDto updateProps(java.lang.Long, com.goldjet.appservice.customs.dto.req.bcs.BscDictReqDto);
 93     descriptor: (Ljava/lang/Long;Lcom/goldjet/appservice/customs/dto/req/bcs/BscDictReqDto;)Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictResDto;
 94     flags: ACC_PUBLIC, ACC_ABSTRACT
 95     MethodParameters:
 96       Name                           Flags
 97       id
 98       reqDto
 99 
100   public abstract java.util.List<com.goldjet.appservice.customs.dto.res.bcs.BscDictItemResDto> selectDictItemByDictCode(java.lang.String);
101     descriptor: (Ljava/lang/String;)Ljava/util/List;
102     flags: ACC_PUBLIC, ACC_ABSTRACT
103     MethodParameters:
104       Name                           Flags
105       dictCode
106     Signature: #28                          // (Ljava/lang/String;)Ljava/util/List<Lcom/goldjet/appservice/customs/dto/res/bcs/BscDictItemResDto;>;
107 }
108 SourceFile: "BscDictService.java"
View Code

3 文件结构

Class文件是一组以8位字节为基础单位的二进制流,内容是以《Java虚拟机规范》规定的一种固定的格式存储数据。存储数据用到了两个数据类型:“无符号数”和“表”。

无符号数:无符号数是基本数据类型,以u1、u2、u4、u8来分别代表1个字节、2个字节、4个字节和8个字节的无符号数,无符号数可以用来描述数字、索引引用、数量表或者按照UTF-8编码构成字符串值。
:由多个无符号数或者其他表作为数据项构成的复合数据类型,以“_info”结尾,用户描述有层次关系的复合结构的数据。

下图是《Java虚拟机规范》规定的Class文件的固定格式,所有Class文件均按照一下格式存储内容。(注意:每个class文件内容都是按照以下列表按列表中从上到下顺序组成,如果某些类型不涉及可以为空)

 

 

 

4 文件结构分析

4.1 魔数

 

标签:appservice,Ljava,dto,Utf8,customs,goldjet,详解,JVM,Class
From: https://www.cnblogs.com/kukuxjx/p/17107692.html

相关文章

  • 神经网络基础部件-BN层详解
    一,数学基础1.1,概率密度函数1.2,正态分布二,背景2.1,如何理解InternalCovariateShift2.2,InternalCovariateShift带来的问题2.3,减少InternalCovariateShift......
  • 使用jps+jinfo也可以测试当前jvm的垃圾回收器
    使用命令行使用jps+jinfo也可以测试当前jvm的垃圾回收器#查看当前运行java线程jps#找到运行的线程使用jinfo-flagjinfo-flagUseG1GC[jps看到的线程id]例:出现+Us......
  • react 路由详解
    简述路由的本质就是在一个页面上,通过交互,不刷新页面但能改变页面视图的一种方法。react-router就是一个扩展react从而实现路由的第三方库router实例在线演......
  • 第二十二天python3 classmethod、staticmethod、property装饰器学习笔记
    classmethod1、在类定义中,使用@classmethod装饰器修饰的方法;2、必须至少有一个参数,且第一个参数留给了cls,cls指代调用者即类对象自身;3、cls这个标识符可以是任意合法名......
  • 预处理指令详解(C语言
    一、预处理符号预处理符号是C语言内置的符号,是可以直接使用的。其中,若遵顼ANSIC,则__STDC__为1,否则未定义。二、#define1)定义标识符define可以用来定义标识符,其语法......
  • zookeeper详解
    ————————————————什么时候新建日志文件:1、在进行事务日志写入之前,zookeeper会判断是否正在关联一个可写的事务日志文件,如果有则继续追加,如果没有就新......
  • kafka配置详解
    关闭自动消费Spring-Boot-kafka的配置中有一个参数,提供了自动消费的功能。使用自动消费我们在收到消息的时候会自动向kafka确认消费。但是在一些特殊场景中我们可能需要使......
  • js构造函数详解
    1.构造函数介绍构造函数是专门用来生成对象的函数,它提供模板,描述对象的基本结构。一个构造函数,可以生成多个对象,这些对象都有相同的结构。构造函数的写法就是一个普通的函......
  • jvm内存模型
    1. jvm的本质     用于解释和运行Java程序的C++程序,本质就是一个程序。2.  JVM主要由三部分组成    (1)执行引擎:用于解释字节码    (2)类加载......
  • LSA 2 详解
    <ar3>displayospflsdbnetworkOSPFProcess1withRouterID3.3.3.3Area:0.0.0.0LinkStateDatabaseType:Network//LSA类型network,也就是LSA-2......