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" }
-------------------------------------------------------------------------------------------------------------------------------