Java class file format specfication
Java class file format spec Link: https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html
Here is an example:
-----------------------------------------------------java source file---------------------------------------------------------
public class Main {
    public static void main(String[] args) {
        System.out.println("hello");
    }
}
-----------------------------------------------------java class file----------------------------------------------------------
0000000: cafe babe 0000 0033 001d 0a00 0600 0f09  .......3........
0000010: 0010 0011 0800 120a 0013 0014 0700 1507  ................
0000020: 0016 0100 063c 696e 6974 3e01 0003 2829  .....<init>...()
0000030: 5601 0004 436f 6465 0100 0f4c 696e 654e  V...Code...LineN
0000040: 756d 6265 7254 6162 6c65 0100 046d 6169  umberTable...mai
0000050: 6e01 0016 285b 4c6a 6176 612f 6c61 6e67  n...([Ljava/lang
0000060: 2f53 7472 696e 673b 2956 0100 0a53 6f75  /String;)V...Sou
0000070: 7263 6546 696c 6501 0009 4d61 696e 2e6a  rceFile...Main.j
0000080: 6176 610c 0007 0008 0700 170c 0018 0019  ava.............
0000090: 0100 0568 656c 6c6f 0700 1a0c 001b 001c  ...hello........
00000a0: 0100 044d 6169 6e01 0010 6a61 7661 2f6c  ...Main...java/l
00000b0: 616e 672f 4f62 6a65 6374 0100 106a 6176  ang/Object...jav
00000c0: 612f 6c61 6e67 2f53 7973 7465 6d01 0003  a/lang/System...
00000d0: 6f75 7401 0015 4c6a 6176 612f 696f 2f50  out...Ljava/io/P
00000e0: 7269 6e74 5374 7265 616d 3b01 0013 6a61  rintStream;...ja
00000f0: 7661 2f69 6f2f 5072 696e 7453 7472 6561  va/io/PrintStrea
0000100: 6d01 0007 7072 696e 746c 6e01 0015 284c  m...println...(L
0000110: 6a61 7661 2f6c 616e 672f 5374 7269 6e67  java/lang/String
0000120: 3b29 5600 2100 0500 06 B: 0000 0000 00 0200  ;)V.!...........
0000130: 0100 0700 0800 0100 0900 0000 1d00 0100  ................
0000140: 0100 0000 052a b700 01b1 0000 0001 000a  .....*..........
0000150: 0000 0006 0001 0000 0002 0009 000b 000c  ................
0000160: 0001 0009 0000 0025 0002 0001 0000 0009  .......%........
0000170: b200 0212 03b6 0004 b100 0000 0100 0a00  ................
0000180: 0000 0a00 0200 0000 0400 0800 05 00 0100  ................
0000190: 0d00 0000 0200 0e                      ........
---------------------------------------------------java class file parse--------------------------------------------------------
magic number: {CA FE BA BE}
minor_version: {00 00}
major_version: {00 33}
constant_pool_count: {00 1d} (29) --> (28)
constant_pool[01]: {0a 0006 000f}--> CONSTANT_Methodref_Info
constant_pool[02]: {09 0010 0011} --> CONSTANT_Fieldref_Info
constant_pool[03]: {08 0012} -->  CONSTANT_String_info
constant_pool[04]: {0a 0013 0014} -->  CONSTANT_Methodref_Info
constant_pool[05]: {07 0015} -->  CONSTANT_Class_info
constant_pool[06]: {07 0016} -->  CONSTANT_Class_info
constant_pool[07]: {01 0006} --{3c 69 6e 69 74 3e}--"<init>" -->  CONSTANT_Utf8_info
constant_pool[08]: {01 0003} --{28 29 56}--"()V"--> CONSTANT_Utf8_info
constant_pool[09]: {01 0004} --{43 6f 64 65}--"Code" --> CONSTANT_Utf8_info
constant_pool[10]: {01 000f} --{4c 69 6e 65 4e 75 6d 62 65 72 54 61 62 6c 65} --> "LineNumberTable" --> CONSTANT_Utf8_info
constant_pool[11]: {01 0004} --{6d 61 69 6e}--"main"--CONSTANT_Utf8_info
constant_pool[12]: {01 0016} --{285b4c6a6176612f 6c61 6e67 2f53 7472 696e 673b 2956} --"([Ljava/lang/String;)V" -->CONSTANT_Utf8_info
constant_pool[13]: {01 000a} --{53 6f757263 6546 696c 65} -- "SourceFile" --> CONSTANT_Utf8_info
constant_pool[14]: {01 0009} --{4d61 696e 2e6a 6176 61} -- "Main.java" --> CONSTANT_Utf8_info
constant_pool[15]: {0c 0007 0008}-->  {<init>()V} -- CONSTANT_NameAndType_info
constant_pool[16]: {07 0017} -- CONSTANT_Class_info
constant_pool[17]: {0c 0018 0019} CONSTANT_NameAndType_info
constant_pool[18]: {01 0005} -- {68 656c 6c6f} "hello" --> CONSTANT_Utf8_info
constant_pool[19]: {07 001a} --> CONSTANT_Class_info
constant_pool[20]: {0c 001b 001c}  --> CONSTANT_NameAndType_info
constant_pool[21]: {01 0004} --> {4d 6169 6e} -- "Main" --> CONSTANT_Utf8_info
constant_pool[22]: {01 0010} --> {6a61 7661 2f6c 616e 672f 4f62 6a65 6374} -- "java/lang/Object"-->CONSTANT_Utf8_info
constant_pool[23]: {01 0010} --> {6a 6176612f 6c61 6e67 2f53 7973 7465 6d} -- "java/lang/System"-->CONSTANT_Utf8_info
constant_pool[24]: {01 0003} --> {6f 75 74}--"out"--> CONSTANT_Utf8_info
constant_pool[25]: {01 0015} --> {4c6a 6176 612f 696f 2f507269 6e74 5374 7265 616d 3b} -- "Ljava/io/PrintStream;"-->CONSTANT_Utf8_info
constant_pool[26]: {01 0013} --> {6a617661 2f69 6f2f 5072 696e 7453 7472 65616d} -- "java/io/PrintStream" --> CONSTANT_Utf8_info
constant_pool[27]: {01 0007} --> {7072 696e 746c 6e}--"println"-->CONSTANT_Utf8_info
constant_pool[28]: {01 0015} --> {284c 6a61 7661 2f6c 616e 672f 5374 7269 6e67 3b29 56} -->"(Ljava/lang/String;)V"
      access_flag: {00 21} --> {ACC_PUBLIC | ACC_SUPER}
	   this_class: {00 05} --> "Main"
	  super_class: {0006} --> "java/lang/Object"
  interface_count: {00 00} --> 0
	  field_count: {00 00} --> 0
	methods_count: {00 02: 2} 
	    methods[1]: {0001: ACC_PUBLIC, 00 07: "<init>", 00 08: "()V", 00 01: 1, attributes[1]{00 09: Code, 00 0000 1d: 29, info:{next line}}}
		           Code{00 01 00 0100 0000 052a b700 01b1 0000 0001 000a 0000 0006 0001 0000 0002}
		methods[2]: {0009: ACC_PUBLIC | ACC_STATIC, 000b, 00 0b: "main", 000c: ([Ljava/lang/String;)V, 0001: 1, attributes[1]{0009: Code, 0000 0025: 37}}
		           Code{0002 0001 0000 0009 b200 0212 03b6 0004 b100 0000 0100 0a00 0000 0a00 02 0200 0000 0400 0800 05}
 attributes_count:{00 01}
 attributes[1]:{00, 0d:SourceFile, 00 00 00 02: 2,  00 0e:"Main.java" }
-------------------------------------------------------------------------------------------------------------------------------
Java class file format specfication的更多相关文章
- Java API —— File类
		
1.File类的概述 文件和目录路径名的抽象表示形式,创建File对象后,仅仅是一个路径的表示,不代码具体的事物一定是存在的. 2.构造方法 · public File ...
 - 配置tomcat连接器后,启动服务报错“No Certificate file specified or invalid file format"异常
		
1:原来的配置是 <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true&quo ...
 - Java ZIP File Example---refernce
		
In this tutorial we are going to see how to ZIP a file in Java. ZIP is an archive file format that e ...
 - 配置CAS错误No Certificate file specified or invalid file format
		
配置tomcat证书 keystore文件后启动一直报错:(tomcat版本:apache-tomcat-6.0.43) tomcat配置: <Connector port="8443 ...
 - java中File类的常用所有方法及其应用
		
创建:createNewFile()在指定位置创建一个空文件,成功就返回true,如果已存在就不创建,然后返回false.mkdir() 在指定位置创建一个单级文件夹.mkdirs() 在指定位置 ...
 - 【java】文件操作java.io.File
		
package 文件操作; import java.io.File; import java.io.IOException; public class TestFile { public static ...
 - Java的File.separator
		
一.File类 在Windows下的路径分隔符(\)和在Linux下的路径分隔符(/)是不一样的,当直接使用绝对路径时,跨平台会报No Such file or diretory异常. File中还有 ...
 - Java中File常用的方法汇总
		
创建:createNewFile()在指定位置创建一个空文件,成功就返回true,如果已存在就不创建,然后返回false.mkdir() 在指定位置创建一个单级文件夹.mkdirs() 在指定位置创建 ...
 - 关于Java的File类、字节流和字符流
		
一.File类: 在Windows下的路径分隔符(\)和在Linux下的路径分隔符(/)是不一样的,当直接使用绝对路径时,跨平台会报No Such file or diretory异常. File中还 ...
 
随机推荐
- 《我是一只IT小小鸟》读书笔记
			
大一进来的第一个学期 我对我所读的软件工程专业感到迷茫与不知.就这么昏昏沉沉的度过了一个学期,第二个学期一开始,在上第一节新增加的“大学生创业与指导”课程充满了好奇,在课上老师推荐的一本书<我是 ...
 - Android自定义View之倒计时Countdown实现
			
先看一下效果: 在点击OK键之后,开始倒计时. 实现步骤 1.新建Android工程"CountdownView" 2.自定义Drawable 自定义View并没有直接的用户交互, ...
 - 编译c
			
1.打开vs工具 2.弄到相同路径(同所编译文件) 3.cl(微软编译器) 生成 obj exe文件 4.system是一个通用指令 可以在windows linux mac用
 - Linear Algebra lecture10 note
			
Four fundamental subspaces( for matrix A) if A is m by n matrix: Column space C(A) in Rm (列空间在m维实 ...
 - TimeStamp
			
private void Form1_Load(object sender, EventArgs e) { textBox1.Text= GenerateTimeStamp(System.DateTi ...
 - compile vim with lua & python support
			
vim在macosx 10.9默认没有带lua和python支持,因为装的有些插件是lua写的,有些是python写的,运行不起来,于是决定自己编译一个,下载vim源码,执行以下命令就可以编译vim: ...
 - UI崩溃的解决方案
			
在unity加载的时候主动强制关闭后,竟然ui崩溃,一直报错UnityEngine.UI.dll is in timestamps but is not known in assetdatabase. ...
 - python fork 用法
			
import os import sys ips = ( "192.168.45.%s" % i for i in range(1,255)) for ip in ips: pid ...
 - Linux常用的安全工具 转自https://yq.aliyun.com/articles/52540?spm=5176.100239.blogcont24250.8.CfBYE9
			
摘要: 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://chenguang.blog.51cto.com/350944/85790 ...
 - hibernate:Named query not known: findXXXX or XXXX is not mapped
			
.hbm.xml文件所放的位置怎么看怎么都在spring配置的扫描路径中,就是会出现标题所示错误,查看log日志,的确也没发现XXXX被mapped的记录~ 参考解决方案: 在eclipse导出jar ...