1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//! Java class file disassembler example
//!
//! This example demonstrates how to use the mokapot library to parse and
//! display the contents of Java class files. It provides functionality
//! similar to the Java `javap` tool, showing class structure, fields,
//! methods, and bytecode instructions.
use ;
use Parser;
use ;
use Error;
/// Command line arguments for the disassembler
///
/// This struct mirrors the `javap` tool's command-line interface,
/// allowing users to specify class files and output format options.
/// Custom error type for disassembler operations
///
/// Uses thiserror to provide clean error handling with automatic
/// conversion from common error types and formatted error messages.
/// Entry point for the disassembler
///
/// Parses command-line arguments and processes the specified class files.
/// Returns an I/O Result to properly handle potential errors.
/// Formatters for Java class components
///
/// This module contains types that implement Display for class components,
/// converting JVM structures into human-readable text representations.
/// It handles formatting of class access flags, field declarations,
/// and method signatures.
/// Printer for class information
///
/// This module contains the ClassPrinter that orchestrates the display of
/// all class information, including class structure, fields, methods,
/// and bytecode instructions when in verbose mode.
/// Process all specified class files
///
/// Iterates through each class file path, attempts to parse it, and prints
/// its contents. When processing multiple files, adds headers and separators.
///
/// # Arguments
///
/// * `class_files` - Slice of paths to the class files to process
/// * `verbose` - Whether to display detailed information including bytecode
///
/// # Returns
///
/// An IoResult indicating success or any I/O errors that occurred
/// Parse a class file into a Class structure
///
/// Opens and reads the class file at the specified path, then uses mokapot
/// to parse it into a Class object that can be analyzed and displayed.
///
/// # Arguments
///
/// * `path` - Path to the class file to parse
///
/// # Returns
///
/// A Result containing either the parsed Class or a DisassemblerError
///
/// # Error Handling
///
/// This function will automatically convert I/O errors or parsing errors
/// into the appropriate DisassemblerError variant through the ? operator
/// and the From trait implementations on DisassemblerError.