Skip to content

Commit 7a3d708

Browse files
committed
Final documentation update before 0.1
1 parent 3fb5918 commit 7a3d708

File tree

5 files changed

+93
-30
lines changed

5 files changed

+93
-30
lines changed
File renamed without changes.

doc/About JavOC/Goals.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# About goals behind JavOC project
2+
JavOC ***[Jav-ok]*** (Java for Open Computers) is a simple implementation of Java Virtual Machine, designed to run on machines from [OpenComputers](https://www.curseforge.com/minecraft/mc-mods/opencomputers) Minecraft mod.
3+
4+
Language - **Lua 5.2**
5+
6+
Project was heavily inspired by Zen1th's JVM - [lukyt](https://github.com/zenith391/lukyt).
7+
8+
## Goals
9+
Since Java Virtual Machine is a colossal piece of software, main goal of the project is not to implement a "real" JVM, but to create an **educational** project to explain to everyone basics of JVM architecture by example.
10+
11+
It makes very important to make code and documentation very detailed, comprehensive and clear for everyone. Other aspects, such as functionality, speed, effectivness, etc. are **not** the main focus, and, if it will be required, will be sacrificed in order to meet the primary goal

doc/Class File Format.md renamed to doc/Class Loading and structure/Class File Format.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ Looks complicated... But here is the pretty diagram, that explains everything!
2626

2727
![image](/doc/Diagrams/Class%20File%20Structure.drawio.svg)
2828

29-
Still complicated...
29+
Still complicated... But at least it is more clear now!
30+
31+
Let's start describing each field, one by one:
32+
33+
<details>
34+
<summary>Magic Value</summary>
35+
36+
Each `.class` value starts with special 'magic value'
37+
</details>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Java class file structure by example
2+
As you already know from "Class File Format" document, Java classes have a relatively complex structure. And the best way to study it - compile something and see these beatiful files in the wild!
3+
4+
For such a purpose, you can use `javac` and `javad` command line tools - official compiler and disassembler, that are included into every Java Development Kit.
5+
6+
However, there is a much more convinient method - [javap.yawk.at](https://javap.yawk.at) website!
7+
8+
It lets you to both compile and disassemble your Java code in one click!
9+
10+
For the beginning, let's compile a simple class.
11+
12+
Something like **this**:
13+
```java
14+
class Main {}
15+
```
16+
<details>
17+
<summary>Disassembler output</summary>
18+
19+
20+
Classfile /tmp/1059625032030680147/classes/Main.class
21+
Last modified Aug 7, 2020; size 237 bytes
22+
SHA-256 checksum <>
23+
Compiled from "Main.java"
24+
class Main
25+
minor version: 0
26+
major version: 58
27+
flags: (0x0020) ACC_SUPER
28+
this_class: #7 // Main
29+
super_class: #2 // java/lang/Object
30+
interfaces: 0, fields: 0, methods: 1, attributes: 1
31+
32+
Constant pool:
33+
#1 = Methodref #2.#3 // java/lang/Object."<init>":()V
34+
#2 = Class #4 // java/lang/Object
35+
#3 = NameAndType #5:#6 // "<init>":()V
36+
#4 = Utf8 java/lang/Object
37+
#5 = Utf8 <init>
38+
#6 = Utf8 ()V
39+
#7 = Class #8 // Main
40+
#8 = Utf8 Main
41+
#9 = Utf8 Code
42+
#10 = Utf8 LineNumberTable
43+
#11 = Utf8 LocalVariableTable
44+
#12 = Utf8 this
45+
#13 = Utf8 LMain;
46+
#14 = Utf8 SourceFile
47+
#15 = Utf8 Main.java
48+
49+
{
50+
Main();
51+
descriptor: ()V
52+
flags: (0x0000)
53+
54+
Code:
55+
56+
stack=1, locals=1, args_size=1
57+
start local 0 s// Main this
58+
0: aload_0
59+
1: invokespecial #1 // Method java/lang/Object."<init>":()V
60+
4: return
61+
end local 0 // Main this
62+
63+
LineNumberTable:
64+
65+
LocalVariableTable:
66+
67+
Start Length Slot Name Signature
68+
0 5 0 this LMain;
69+
70+
}
71+
SourceFile: "Main.java"
72+
73+
</details>

doc/Java class file structure by example.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)