@mustafagoksever/java-inspector 2.0.9 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +145 -161
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +3 -2
- package/dist/cli.js.map +1 -1
- package/dist/decompiler/DecompilerService.d.ts +11 -8
- package/dist/decompiler/DecompilerService.d.ts.map +1 -1
- package/dist/decompiler/DecompilerService.js +91 -74
- package/dist/decompiler/DecompilerService.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +65 -14
- package/dist/index.js.map +1 -1
- package/dist/utils/cachePaths.js +1 -1
- package/dist/utils/cachePaths.js.map +1 -1
- package/dist/utils/methodExtractor.d.ts +6 -0
- package/dist/utils/methodExtractor.d.ts.map +1 -0
- package/dist/utils/methodExtractor.js +122 -0
- package/dist/utils/methodExtractor.js.map +1 -0
- package/lib/vineflower-1.11.2.jar +0 -0
- package/package.json +90 -90
- package/lib/cfr-0.152.jar +0 -0
package/README.md
CHANGED
|
@@ -1,31 +1,74 @@
|
|
|
1
1
|
# Java Inspector
|
|
2
2
|
|
|
3
|
-
**Java source
|
|
3
|
+
> **Decompile Maven dependencies into readable Java source — directly inside your AI agent.**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@mustafagoksever/java-inspector)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## What is this?
|
|
11
|
+
|
|
12
|
+
AI editors can't read compiled `.class` files. Ask *"How does `JpaRepository` work?"* and the agent hallucinates.
|
|
13
|
+
|
|
14
|
+
**Java Inspector** is an MCP server that exposes the internals of your project's Maven dependencies (Spring, Hibernate, Jackson, Micrometer, etc.) as decompiled Java source code. Zero configuration — just point your agent at it.
|
|
15
|
+
|
|
16
|
+
### Supported operations
|
|
17
|
+
|
|
18
|
+
| Tool | What it does |
|
|
19
|
+
|------|--------------|
|
|
20
|
+
| `scan_dependencies` | Kicks off a background scan of every JAR on the Maven classpath. Call again to poll progress. |
|
|
21
|
+
| `decompile_class` | Returns the **full Java source** (method bodies and all) via Vineflower. Optionally extract a single method by `methodName`, or paginate with `offset`/`limit`. |
|
|
22
|
+
| `analyze_class` | Returns the **structural signature** — fields, methods, constructors, inheritance — via `javap`. No method bodies. |
|
|
23
|
+
| `search_class` | Fuzzy-find classes by partial name (e.g. `"ObservationRegistry"`). |
|
|
24
|
+
| `get_inheritance_tree` | Walks the superclass chain up to `java.lang.Object`. |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Architecture
|
|
29
|
+
|
|
30
|
+
```mermaid
|
|
31
|
+
graph LR
|
|
32
|
+
A[AI Agent<br/>Claude / Cursor] -->|MCP| B[java-inspector<br/>TypeScript Server]
|
|
33
|
+
B -->|auto-detect| C{Maven Resolver}
|
|
34
|
+
C -->|priority 1| D[MAVEN_CMD env]
|
|
35
|
+
C -->|priority 2| E[mvnd daemon<br/>~2x faster]
|
|
36
|
+
C -->|priority 3| F[MAVEN_HOME/bin/mvn]
|
|
37
|
+
C -->|priority 4| G[mvn from PATH]
|
|
38
|
+
B -->|dependency:build-classpath| H[~/.m2/repository]
|
|
39
|
+
H -->|JAR streams| I[yauzl extractor]
|
|
40
|
+
I -->|class names| J[JSON Lines Cache]
|
|
41
|
+
B -->|cache hit| J
|
|
42
|
+
B -->|cache miss| I
|
|
43
|
+
B -->|java -jar vineflower.jar| K[Vineflower 1.11.2<br/>Decompiler]
|
|
44
|
+
K -->|*.java source| A
|
|
8
45
|
```
|
|
9
|
-
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
|
|
10
|
-
│ AI Agent │────▶│ java-inspector │────▶│ Maven │
|
|
11
|
-
│ (Claude/Cursor) │ │ MCP Server │ │ + .m2 Repo │
|
|
12
|
-
└─────────────────┘ └──────────────────┘ └─────────────────┘
|
|
13
|
-
│
|
|
14
|
-
▼
|
|
15
|
-
┌──────────────┐
|
|
16
|
-
│ CFR 0.152 │
|
|
17
|
-
│ Decompiler │
|
|
18
|
-
└──────────────┘
|
|
19
|
-
```
|
|
20
46
|
|
|
21
|
-
|
|
47
|
+
### Why JSON Lines?
|
|
48
|
+
|
|
49
|
+
Traditional JSON caches rewrite the entire file on every batch — O(n²) overhead for large projects. We use **append-only JSON Lines**:
|
|
22
50
|
|
|
23
|
-
**
|
|
51
|
+
- **Crash-safe**: each line is independent; a truncated final line is skipped on reload.
|
|
52
|
+
- **Fast startup**: the server replays the JSONL into an in-memory `Map<string, ClassIndexEntry>` on launch.
|
|
53
|
+
- **Low memory**: ~35 MB RAM for 100,000 classes.
|
|
54
|
+
|
|
55
|
+
### Cache layout
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
~/.cache/java-inspector/<project>_<hash>/
|
|
59
|
+
├── classpath.json # pomHash + jarPaths[] + classpathHash + timestamp
|
|
60
|
+
├── class-index.jsonl # Append-only ClassIndexEntry batches
|
|
61
|
+
├── scan-state.json # jarCount, processedJars[], isComplete
|
|
62
|
+
├── decompile-cache-vineflower/ # Cached .java sources
|
|
63
|
+
└── server.log # Append-only structured logs
|
|
64
|
+
```
|
|
24
65
|
|
|
25
66
|
---
|
|
26
67
|
|
|
27
68
|
## Quick Start
|
|
28
69
|
|
|
70
|
+
Add to your MCP client config (Claude Desktop, Cursor, etc.):
|
|
71
|
+
|
|
29
72
|
```json
|
|
30
73
|
{
|
|
31
74
|
"mcpServers": {
|
|
@@ -37,117 +80,119 @@
|
|
|
37
80
|
}
|
|
38
81
|
```
|
|
39
82
|
|
|
40
|
-
Restart your
|
|
83
|
+
Restart your editor and ask: *"Show me the source of `ObservationRegistry`"*
|
|
41
84
|
|
|
42
|
-
|
|
85
|
+
That's it. No `JAVA_HOME` tweaks. No manual decompiler download. The server ships the ~1.8 MB Vineflower JAR inside the package.
|
|
43
86
|
|
|
44
87
|
---
|
|
45
88
|
|
|
46
|
-
##
|
|
89
|
+
## Workflow
|
|
90
|
+
|
|
91
|
+
```mermaid
|
|
92
|
+
sequenceDiagram
|
|
93
|
+
participant U as User
|
|
94
|
+
participant A as AI Agent
|
|
95
|
+
participant S as java-inspector
|
|
96
|
+
participant M as Maven / mvnd
|
|
97
|
+
participant C as Cache
|
|
98
|
+
|
|
99
|
+
U->>A: "Show me JpaRepository source"
|
|
100
|
+
A->>S: decompile_class("org.springframework.data.jpa.repository.JpaRepository")
|
|
101
|
+
alt Index not built yet
|
|
102
|
+
S->>M: dependency:build-classpath
|
|
103
|
+
M-->>S: JAR list
|
|
104
|
+
S->>S: Background scan (20 JARs in parallel)
|
|
105
|
+
S-->>A: Class found via lazy JAR search
|
|
106
|
+
else Cache hit
|
|
107
|
+
S->>C: Map.get(className) — O(1)
|
|
108
|
+
C-->>S: ClassIndexEntry
|
|
109
|
+
end
|
|
110
|
+
S->>S: Extract .class from JAR (yauzl)
|
|
111
|
+
S->>S: java -jar vineflower.jar ...
|
|
112
|
+
S-->>A: Decompiled .java source
|
|
113
|
+
A-->>U: Formatted response
|
|
114
|
+
```
|
|
47
115
|
|
|
48
|
-
|
|
116
|
+
---
|
|
49
117
|
|
|
50
|
-
|
|
51
|
-
|---------|-------------|
|
|
52
|
-
| `scan_dependencies` | Starts a background scan of Maven dependencies. Call again to check progress or `forceRefresh` to rebuild. |
|
|
53
|
-
| `decompile_class` | Decompiles and returns the **full Java source code** (method bodies included) of a dependency class using CFR |
|
|
54
|
-
| `analyze_class` | Returns the **structural signature** (fields, methods, constructors, superclass, interfaces) of a dependency class using `javap` — no method bodies |
|
|
55
|
-
| `search_class` | Fuzzy search for classes in dependencies by partial name (e.g. `"JpaRepository"`) |
|
|
56
|
-
| `get_inheritance_tree` | Returns the superclass hierarchy of a dependency class |
|
|
118
|
+
## Performance
|
|
57
119
|
|
|
120
|
+
Real numbers from a **Spring Boot + Vaadin** project (144 dependencies, 17,405 classes):
|
|
58
121
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
122
|
+
| Phase | Cold start | Warm cache |
|
|
123
|
+
|-------|-----------|------------|
|
|
124
|
+
| Maven classpath resolve | 5–10 s | — |
|
|
125
|
+
| Background JAR index | 20–30 s | — |
|
|
126
|
+
| Per-class lookup | 2–5 s | **< 1 ms** |
|
|
127
|
+
| Fuzzy search | — | **~30 ms** |
|
|
128
|
+
| Vineflower decompile (first) | ~2 s | — |
|
|
129
|
+
| Vineflower decompile (cached) | — | **< 100 ms** |
|
|
64
130
|
|
|
65
|
-
|
|
66
|
-
|--------|--------|-------|
|
|
67
|
-
| First response | 5–10 minutes | **< 10 seconds** |
|
|
68
|
-
| Subsequent lookups | Slow | **< 50 ms** (in-memory) |
|
|
69
|
-
| AI response accuracy | ~60% (guessing) | **100%** (real source) |
|
|
70
|
-
| Agent timeout risk | High | **None** |
|
|
131
|
+
**First tool call** lands in ~10 seconds (classpath resolve + scan kickoff). **Everything after that** is effectively instant.
|
|
71
132
|
|
|
72
133
|
---
|
|
73
134
|
|
|
74
|
-
##
|
|
135
|
+
## Cache invalidation
|
|
75
136
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
137
|
+
```mermaid
|
|
138
|
+
flowchart TD
|
|
139
|
+
A[scan_dependencies called] --> B{isIndexComplete?}
|
|
140
|
+
B -->|pomHash mismatch| C[Invalidate disk + memory]
|
|
141
|
+
B -->|classpathHash mismatch| C
|
|
142
|
+
B -->|both match| D[Return existing index]
|
|
143
|
+
C --> E[Delete ~/.cache/java-inspector/<hash>/*]
|
|
144
|
+
E --> F[Re-run Maven dependency:build-classpath]
|
|
145
|
+
F --> G[Start background scan]
|
|
146
|
+
D --> H[Return Map of classes]
|
|
79
147
|
```
|
|
80
148
|
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
npx -y @mustafagoksever/java-inspector
|
|
84
|
-
```
|
|
149
|
+
Invalidation triggers:
|
|
85
150
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
```
|
|
151
|
+
1. **Module `pom.xml` changes** — `pomHash` mismatch.
|
|
152
|
+
2. **Parent POM / dependency-management changes** — `classpathHash` mismatch.
|
|
153
|
+
3. **Manual** — call `scan_dependencies` with `forceRefresh: true`.
|
|
90
154
|
|
|
91
155
|
---
|
|
92
156
|
|
|
93
|
-
##
|
|
94
|
-
|
|
95
|
-
java-inspector uses a high-performance append-only JSON Lines cache with an in-memory `Map` index.
|
|
96
|
-
|
|
97
|
-
### Cache Directory
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
~/.cache/java-inspector/<project_hash>/
|
|
101
|
-
├── classpath.json # pomHash + JAR list + classpathHash
|
|
102
|
-
├── class-index.jsonl # Append-only ClassIndexEntry batches
|
|
103
|
-
├── scan-state.json # Metadata: jarCount, processedJars, isComplete
|
|
104
|
-
└── decompile-cache/ # Cached decompiled .java sources
|
|
105
|
-
```
|
|
157
|
+
## Platform Support
|
|
106
158
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
159
|
+
| OS | Command |
|
|
160
|
+
|----|---------|
|
|
161
|
+
| Windows | `npx -y @mustafagoksever/java-inspector` |
|
|
162
|
+
| Linux | `npx -y @mustafagoksever/java-inspector` |
|
|
163
|
+
| macOS | `npx -y @mustafagoksever/java-inspector` |
|
|
111
164
|
|
|
112
|
-
**
|
|
113
|
-
- **First tool call:** ~5-10 seconds (Maven `dependency:build-classpath`)
|
|
114
|
-
- **Background scan:** Continues in the background (25 JARs/sec, 20-parallel)
|
|
115
|
-
- **Lookup (cached):** **< 1 ms** (in-memory `Map.get()`)
|
|
116
|
-
- **Search (cached):** **< 50 ms** (in-memory `Map` iteration)
|
|
165
|
+
**Requirements:** Node.js ≥ 16, Java runtime, Maven (or `mvnd` for faster resolves).
|
|
117
166
|
|
|
118
|
-
|
|
119
|
-
- Module `pom.xml` changes → auto-invalidate
|
|
120
|
-
- Parent POM / dependency management changes → auto-invalidate (`classpathHash`)
|
|
121
|
-
- Manual: call `scan_dependencies` with `forceRefresh: true`
|
|
167
|
+
---
|
|
122
168
|
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
# Linux / macOS
|
|
126
|
-
rm -rf ~/.cache/java-inspector
|
|
169
|
+
## Environment variables
|
|
127
170
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
171
|
+
| Variable | Effect |
|
|
172
|
+
|----------|--------|
|
|
173
|
+
| `JAVA_HOME` | Locates `java` and `javap`. |
|
|
174
|
+
| `MAVEN_HOME` | Locates `mvn` / `mvn.cmd`. |
|
|
175
|
+
| `MAVEN_CMD` | Override executable entirely — e.g. `mvnd`, `mvnw`, or a full path. |
|
|
176
|
+
| `MAVEN_REPO` | Overrides `~/.m2/repository`. |
|
|
177
|
+
| `DECOMPILER_PATH` | Use a custom Vineflower JAR instead of the bundled one. |
|
|
178
|
+
| `NODE_ENV=development` | Enables verbose `server.log` output. |
|
|
131
179
|
|
|
132
180
|
---
|
|
133
181
|
|
|
134
|
-
## Installation
|
|
135
|
-
|
|
136
|
-
### Zero-Setup (Recommended)
|
|
182
|
+
## Installation alternatives
|
|
137
183
|
|
|
184
|
+
**Zero-setup (recommended)**
|
|
138
185
|
```bash
|
|
139
186
|
npx @mustafagoksever/java-inspector
|
|
140
187
|
```
|
|
141
188
|
|
|
142
|
-
|
|
143
|
-
|
|
189
|
+
**Global install**
|
|
144
190
|
```bash
|
|
145
191
|
npm install -g @mustafagoksever/java-inspector
|
|
146
192
|
java-inspector start
|
|
147
193
|
```
|
|
148
194
|
|
|
149
|
-
|
|
150
|
-
|
|
195
|
+
**Build from source**
|
|
151
196
|
```bash
|
|
152
197
|
git clone https://github.com/mustafagoksever/java-inspector.git
|
|
153
198
|
cd java-inspector
|
|
@@ -157,79 +202,18 @@ npm run build
|
|
|
157
202
|
|
|
158
203
|
---
|
|
159
204
|
|
|
160
|
-
## Technical
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
**Key Features:**
|
|
175
|
-
- **Non-blocking startup**: MCP server responds immediately; background scan runs asynchronously
|
|
176
|
-
- **Lazy class resolution**: On-demand JAR scanning when a class is not yet indexed
|
|
177
|
-
- **Parallel batch processing**: 20 JARs processed simultaneously
|
|
178
|
-
- **Smart invalidation**: Detects changes in module POM, parent POM, and effective classpath
|
|
179
|
-
- **Zero external dependencies** — CFR decompiler bundled
|
|
180
|
-
- **Cross-platform** — full support on Windows, Linux, and macOS
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
## Performance
|
|
185
|
-
|
|
186
|
-
| Operation | First Call | Background Scan | Cached |
|
|
187
|
-
|-----------|-----------|-----------------|--------|
|
|
188
|
-
| Maven classpath resolve | ~5-10s | — | — |
|
|
189
|
-
| Background JAR scan | — | ~20-30s (144 JARs) | — |
|
|
190
|
-
| Class lookup (cache miss) | ~2-5s | — | — |
|
|
191
|
-
| Class lookup (cache hit) | — | — | **< 1 ms** |
|
|
192
|
-
| Fuzzy search | — | — | **< 50 ms** |
|
|
193
|
-
| Decompile (first) | ~2s | — | **< 100 ms** |
|
|
194
|
-
| Decompile (cached) | — | — | **< 100 ms** |
|
|
195
|
-
|
|
196
|
-
**Real world:** Spring Boot + Vaadin project with 144 dependencies, 17,405 classes
|
|
197
|
-
- First tool call: ~10 seconds (classpath resolve + background scan start)
|
|
198
|
-
- Per class (cached): instant
|
|
199
|
-
- Search: ~30 ms
|
|
200
|
-
|
|
201
|
-
---
|
|
202
|
-
|
|
203
|
-
## Usage Examples
|
|
204
|
-
|
|
205
|
-
### View source code
|
|
206
|
-
```
|
|
207
|
-
User: "Show me the source code of JpaRepository"
|
|
208
|
-
|
|
209
|
-
Agent:
|
|
210
|
-
1. Calls decompile_class(className: "org.springframework.data.jpa.repository.JpaRepository")
|
|
211
|
-
2. Server resolves class on-demand or from index
|
|
212
|
-
3. Returns the real decompiled source code
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Search classes (no need for the full name)
|
|
216
|
-
```
|
|
217
|
-
User: "Find classes related to JPA repository"
|
|
218
|
-
|
|
219
|
-
Agent:
|
|
220
|
-
1. Calls search_class(query: "jpa repository")
|
|
221
|
-
2. Results: JpaRepository, SimpleJpaRepository, QuerydslJpaRepository...
|
|
222
|
-
3. Shows the list to the user, decompiles the one they pick
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
### Inheritance tree
|
|
226
|
-
```
|
|
227
|
-
User: "Show me the superclasses of JpaRepository"
|
|
228
|
-
|
|
229
|
-
Agent:
|
|
230
|
-
1. Calls get_inheritance_tree(className: "org.springframework.data.jpa.repository.JpaRepository")
|
|
231
|
-
2. Result: JpaRepository → Repository → ...
|
|
232
|
-
```
|
|
205
|
+
## Technical stack
|
|
206
|
+
|
|
207
|
+
| Layer | Technology |
|
|
208
|
+
|-------|------------|
|
|
209
|
+
| Language | TypeScript 5.7 |
|
|
210
|
+
| Runtime | Node.js 16+ |
|
|
211
|
+
| Protocol | Model Context Protocol (MCP) |
|
|
212
|
+
| Decompiler | Vineflower 1.11.2 (bundled) |
|
|
213
|
+
| JAR reader | yauzl (streaming, lazy entries) |
|
|
214
|
+
| Build tool | tsc |
|
|
215
|
+
| Package manager | npm |
|
|
216
|
+
| License | Apache-2.0 |
|
|
233
217
|
|
|
234
218
|
---
|
|
235
219
|
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
import { Command } from 'commander';
|
|
2
3
|
import { createRequire } from 'module';
|
|
3
4
|
import { JavaClassAnalyzerMCPServer } from './index.js';
|
|
@@ -27,7 +28,7 @@ program
|
|
|
27
28
|
.option('-p, --project <path>', 'Maven project path')
|
|
28
29
|
.option('-c, --class <className>', 'Class name to test')
|
|
29
30
|
.option('--no-cache', 'Do not use cache')
|
|
30
|
-
.option('--
|
|
31
|
+
.option('--decompiler-path <path>', 'Vineflower decompiler JAR path')
|
|
31
32
|
.action(async (options) => {
|
|
32
33
|
console.log('Test mode - please use test-tools.js for complete testing');
|
|
33
34
|
console.log('Run: node test-tools.js --help for detailed usage');
|
|
@@ -46,7 +47,7 @@ program
|
|
|
46
47
|
NODE_ENV: "production",
|
|
47
48
|
MAVEN_REPO: process.env.MAVEN_REPO || "",
|
|
48
49
|
JAVA_HOME: process.env.JAVA_HOME || "",
|
|
49
|
-
|
|
50
|
+
DECOMPILER_PATH: process.env.DECOMPILER_PATH || ""
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
}
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE/C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACF,IAAI,CAAC,gBAAgB,CAAC;KACtB,WAAW,CAAC,8FAA8F,CAAC;KAC3G,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB,OAAO;KACF,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,kBAAkB,CAAC;KAC/B,MAAM,CAAC,yBAAyB,EAAE,8CAA8C,EAAE,YAAY,CAAC;KAC/F,MAA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
|
|
3
|
+
private decompilerPath;
|
|
4
4
|
constructor();
|
|
5
|
-
private
|
|
5
|
+
private initializeDecompilerPath;
|
|
6
6
|
/**
|
|
7
7
|
* Decompile specified Java class file
|
|
8
8
|
*/
|
|
9
|
-
decompileClass(className: string, projectPath: string, useCache?: boolean,
|
|
9
|
+
decompileClass(className: string, projectPath: string, useCache?: boolean, externalDecompilerPath?: string): Promise<string>;
|
|
10
10
|
/**
|
|
11
11
|
* Get cache file path
|
|
12
12
|
*/
|
|
@@ -16,21 +16,24 @@ export declare class DecompilerService {
|
|
|
16
16
|
*/
|
|
17
17
|
private extractClassFile;
|
|
18
18
|
/**
|
|
19
|
-
* Use
|
|
19
|
+
* Use Vineflower to decompile .class file.
|
|
20
|
+
* Vineflower writes output to a directory, so we create a temporary
|
|
21
|
+
* output folder, run the decompiler, read the generated .java file,
|
|
22
|
+
* and clean up afterwards.
|
|
20
23
|
*/
|
|
21
|
-
private
|
|
24
|
+
private decompileWithVineflower;
|
|
22
25
|
/**
|
|
23
26
|
* Get package root directory (works with npx, npm install -g, and local dev)
|
|
24
27
|
*/
|
|
25
28
|
private getPackageRoot;
|
|
26
29
|
/**
|
|
27
|
-
* Find
|
|
30
|
+
* Find Vineflower jar package path
|
|
28
31
|
*/
|
|
29
|
-
private
|
|
32
|
+
private findVineflowerJar;
|
|
30
33
|
/**
|
|
31
34
|
* Batch decompile multiple classes
|
|
32
35
|
*/
|
|
33
|
-
decompileClasses(classNames: string[], projectPath: string, useCache?: boolean,
|
|
36
|
+
decompileClasses(classNames: string[], projectPath: string, useCache?: boolean, externalDecompilerPath?: string): Promise<Map<string, string>>;
|
|
34
37
|
/**
|
|
35
38
|
* Get Java command path
|
|
36
39
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecompilerService.d.ts","sourceRoot":"","sources":["../../src/decompiler/DecompilerService.ts"],"names":[],"mappings":"AAiBA,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"DecompilerService.d.ts","sourceRoot":"","sources":["../../src/decompiler/DecompilerService.ts"],"names":[],"mappings":"AAiBA,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,cAAc,CAAS;;YAOjB,wBAAwB;IAWtC;;OAEG;IACG,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAc,EAAE,sBAAsB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA4ExI;;OAEG;IACH,OAAO,CAAC,YAAY;IAQpB;;OAEG;YACW,gBAAgB;IA2E9B;;;;;OAKG;YACW,uBAAuB;IAkErC;;OAEG;IACH,OAAO,CAAC,cAAc;IAOtB;;OAEG;YACW,iBAAiB;IAyC/B;;OAEG;IACG,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAc,EAAE,sBAAsB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAiB1J;;OAEG;IACH,OAAO,CAAC,cAAc;CAWzB"}
|