# atwodots/drvm architecture

> Architecture diagram of the GitHub repository atwodots/drvm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/atwodots/drvm
- Repository: https://github.com/atwodots/drvm

## Overview

DRVM is a C++ Java class-file disassembler and an in-progress JVM, aimed especially at running J2ME games. A user supplies a .class file and selects dumping or execution: the CLI parses the file, then either renders its class metadata or initializes and invokes Java entry points through the VM. The execution side includes class loading, bytecode interpretation, heap objects, and native support. The README documents both general class-file disassembly and execution without external libraries; unsampled implementation details are represented only where documented or indexed.

Main entry points: [`src/classfile/ClassFile.cpp`](https://github.com/atwodots/drvm/blob/main/src/classfile/ClassFile.cpp) (Class-file parser), [`src/main.cpp`](https://github.com/atwodots/drvm/blob/main/src/main.cpp) (CLI options), [`src/vm/VM.cpp`](https://github.com/atwodots/drvm/blob/main/src/vm/VM.cpp) (Bytecode interpreter), [`src/vm/ClassLoader.cpp`](https://github.com/atwodots/drvm/blob/main/src/vm/ClassLoader.cpp) (Class loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Command line"]
  node_cli["CLI options<br/>[main.cpp]"]
  node_help["Help and usage<br/>[Help.cpp]"]
  node_info["Program information<br/>[ProgramInfo.cpp]"]
end

subgraph group_classfile["Class-file analysis"]
  node_reader["Class-file parser<br/>[ClassFile.cpp]"]
  node_binary["Binary reader<br/>[BinaryReader.cpp]"]
  node_pool["Constant pool<br/>[ConstantPool.hpp]"]
  node_attributes["Class attributes<br/>[Attribute.hpp]"]
  node_members["Fields and methods<br/>[Method.hpp]"]
  node_disassembler["Class-file dump<br/>[ClassFile.cpp]"]
  node_classinfo["Class information<br/>[Info.cpp]"]
end

subgraph group_runtime["JVM runtime"]
  node_loader["Class loader<br/>[ClassLoader.cpp]"]
  node_vm["Bytecode interpreter<br/>[VM.cpp]"]
  node_opcodes["Opcode definitions<br/>[Opcode.hpp]"]
  node_heap[("Object and array heap<br/>[Heap.hpp]")]
  node_exceptions["Java exceptions<br/>[JavaException.hpp]"]
end

subgraph group_native["Runtime support"]
  node_system["System natives<br/>[System.cpp]"]
  node_random["Random natives<br/>[Random.cpp]"]
end

node_user(("Class-file user"))

node_user -->|"selects mode"| node_cli
node_cli -->|"requests help"| node_help
node_cli -->|"requests info"| node_info
node_cli -->|"parses file"| node_reader
node_cli -->|"dumps class"| node_disassembler
node_cli -->|"creates loader"| node_loader
node_cli -->|"invokes methods"| node_vm
node_reader -->|"reads bytes"| node_binary
node_reader -->|"uses opcode data"| node_opcodes
node_reader -->|"provides class data"| node_disassembler
node_reader -->|"parses constants"| node_pool
node_reader -->|"parses attributes"| node_attributes
node_reader -->|"parses members"| node_members
node_loader -->|"loads class files"| node_reader
node_vm -->|"loads classes"| node_loader
node_vm -->|"allocates objects"| node_heap
node_vm -->|"dispatches instructions"| node_opcodes
node_vm -->|"handles exceptions"| node_exceptions
node_vm -->|"uses system native"| node_system
node_vm -.->|"supports random native"| node_random

click node_cli "https://github.com/atwodots/drvm/blob/main/src/main.cpp"
click node_help "https://github.com/atwodots/drvm/blob/main/src/maintain/Help.cpp"
click node_info "https://github.com/atwodots/drvm/blob/main/src/maintain/ProgramInfo.cpp"
click node_reader "https://github.com/atwodots/drvm/blob/main/src/classfile/ClassFile.cpp"
click node_binary "https://github.com/atwodots/drvm/blob/main/src/classfile/BinaryReader.cpp"
click node_pool "https://github.com/atwodots/drvm/blob/main/include/classfile/ConstantPool.hpp"
click node_attributes "https://github.com/atwodots/drvm/blob/main/include/classfile/Attribute.hpp"
click node_members "https://github.com/atwodots/drvm/blob/main/include/classfile/Method.hpp"
click node_disassembler "https://github.com/atwodots/drvm/blob/main/src/classfile/ClassFile.cpp"
click node_classinfo "https://github.com/atwodots/drvm/blob/main/src/classfile/Info.cpp"
click node_loader "https://github.com/atwodots/drvm/blob/main/src/vm/ClassLoader.cpp"
click node_vm "https://github.com/atwodots/drvm/blob/main/src/vm/VM.cpp"
click node_opcodes "https://github.com/atwodots/drvm/blob/main/include/Opcode.hpp"
click node_heap "https://github.com/atwodots/drvm/blob/main/include/heap/Heap.hpp"
click node_exceptions "https://github.com/atwodots/drvm/blob/main/include/vm/JavaException.hpp"
click node_system "https://github.com/atwodots/drvm/blob/main/src/java/lang/System.cpp"
click node_random "https://github.com/atwodots/drvm/blob/main/src/java/util/Random.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_help,node_info,node_user toneBlue
class node_reader,node_binary,node_pool,node_attributes,node_members,node_disassembler,node_classinfo toneAmber
class node_loader,node_vm,node_opcodes,node_heap,node_exceptions toneMint
class node_system,node_random toneRose
```

## Components

### Command line

- [CLI options](https://github.com/atwodots/drvm/blob/main/src/main.cpp): `src/main.cpp`
- [Help and usage](https://github.com/atwodots/drvm/blob/main/src/maintain/Help.cpp): `src/maintain/Help.cpp`
- [Program information](https://github.com/atwodots/drvm/blob/main/src/maintain/ProgramInfo.cpp): `src/maintain/ProgramInfo.cpp`

### Class-file analysis

- [Class-file parser](https://github.com/atwodots/drvm/blob/main/src/classfile/ClassFile.cpp): `src/classfile/ClassFile.cpp`
- [Binary reader](https://github.com/atwodots/drvm/blob/main/src/classfile/BinaryReader.cpp): `src/classfile/BinaryReader.cpp`
- [Constant pool](https://github.com/atwodots/drvm/blob/main/include/classfile/ConstantPool.hpp): `include/classfile/ConstantPool.hpp`
- [Class attributes](https://github.com/atwodots/drvm/blob/main/include/classfile/Attribute.hpp): `include/classfile/Attribute.hpp`
- [Fields and methods](https://github.com/atwodots/drvm/blob/main/include/classfile/Method.hpp): `include/classfile/Method.hpp`
- [Class-file dump](https://github.com/atwodots/drvm/blob/main/src/classfile/ClassFile.cpp): `src/classfile/ClassFile.cpp`
- [Class information](https://github.com/atwodots/drvm/blob/main/src/classfile/Info.cpp): `src/classfile/Info.cpp`

### JVM runtime

- [Class loader](https://github.com/atwodots/drvm/blob/main/src/vm/ClassLoader.cpp): `src/vm/ClassLoader.cpp`
- [Bytecode interpreter](https://github.com/atwodots/drvm/blob/main/src/vm/VM.cpp): `src/vm/VM.cpp`
- [Opcode definitions](https://github.com/atwodots/drvm/blob/main/include/Opcode.hpp): `include/Opcode.hpp`
- [Object and array heap](https://github.com/atwodots/drvm/blob/main/include/heap/Heap.hpp): `include/heap/Heap.hpp`
- [Java exceptions](https://github.com/atwodots/drvm/blob/main/include/vm/JavaException.hpp): `include/vm/JavaException.hpp`

### Runtime support

- [System natives](https://github.com/atwodots/drvm/blob/main/src/java/lang/System.cpp): `src/java/lang/System.cpp`
- [Random natives](https://github.com/atwodots/drvm/blob/main/src/java/util/Random.cpp): `src/java/util/Random.cpp`

### Other components

- **Class-file user**

## Connections

- Class-file user → CLI options: selects mode (evidence: `README.md`)
- CLI options → Help and usage: requests help (evidence: `src/main.cpp`)
- CLI options → Program information: requests info (evidence: `src/main.cpp`)
- CLI options → Class-file parser: parses file (evidence: `src/main.cpp`)
- CLI options → Class-file dump: dumps class (evidence: `src/main.cpp`)
- CLI options → Class loader: creates loader (evidence: `src/main.cpp`)
- CLI options → Bytecode interpreter: invokes methods (evidence: `src/main.cpp`)
- Class-file parser → Binary reader: reads bytes (evidence: `src/classfile/ClassFile.cpp`)
- Class-file parser → Opcode definitions: uses opcode data (evidence: `src/classfile/ClassFile.cpp`)
- Class-file parser → Class-file dump: provides class data (evidence: `README.md`)
- Class-file parser → Constant pool: parses constants
- Class-file parser → Class attributes: parses attributes (evidence: `src/classfile/ClassFile.cpp`)
- Class-file parser → Fields and methods: parses members
- Class loader → Class-file parser: loads class files
- Bytecode interpreter → Class loader: loads classes
- Bytecode interpreter → Object and array heap: allocates objects (evidence: `src/vm/VM.cpp`)
- Bytecode interpreter → Opcode definitions: dispatches instructions (evidence: `src/vm/VM.cpp`)
- Bytecode interpreter → Java exceptions: handles exceptions
- Bytecode interpreter → System natives: uses system native
- Bytecode interpreter → Random natives: supports random native
