jarp-mcp 1.0.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 -0
- package/README.md +365 -0
- package/dist/analyzer/JavaClassAnalyzer.d.ts +61 -0
- package/dist/analyzer/JavaClassAnalyzer.d.ts.map +1 -0
- package/dist/analyzer/JavaClassAnalyzer.js +314 -0
- package/dist/analyzer/JavaClassAnalyzer.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +73 -0
- package/dist/cli.js.map +1 -0
- package/dist/decompiler/DecompilerService.d.ts +35 -0
- package/dist/decompiler/DecompilerService.d.ts.map +1 -0
- package/dist/decompiler/DecompilerService.js +238 -0
- package/dist/decompiler/DecompilerService.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +258 -0
- package/dist/index.js.map +1 -0
- package/dist/scanner/DependencyScanner.d.ts +52 -0
- package/dist/scanner/DependencyScanner.d.ts.map +1 -0
- package/dist/scanner/DependencyScanner.js +235 -0
- package/dist/scanner/DependencyScanner.js.map +1 -0
- package/lib/cfr-0.152.jar +0 -0
- package/package.json +85 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { exec } from 'child_process';
|
|
3
|
+
import { promisify } from 'util';
|
|
4
|
+
import { DependencyScanner } from '../scanner/DependencyScanner.js';
|
|
5
|
+
const execAsync = promisify(exec);
|
|
6
|
+
export class JavaClassAnalyzer {
|
|
7
|
+
scanner;
|
|
8
|
+
constructor() {
|
|
9
|
+
this.scanner = new DependencyScanner();
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Analyze Java class structure information
|
|
13
|
+
*/
|
|
14
|
+
async analyzeClass(className, projectPath) {
|
|
15
|
+
try {
|
|
16
|
+
// 1. Get class file path
|
|
17
|
+
const jarPath = await this.scanner.findJarForClass(className, projectPath);
|
|
18
|
+
if (!jarPath) {
|
|
19
|
+
throw new Error(`JAR package for class ${className} not found`);
|
|
20
|
+
}
|
|
21
|
+
// 2. Use javap to analyze class in JAR package directly
|
|
22
|
+
const analysis = await this.analyzeClassWithJavap(jarPath, className);
|
|
23
|
+
return analysis;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error(`Failed to analyze class ${className}:`, error);
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Use javap tool to analyze class structure in JAR package
|
|
32
|
+
*/
|
|
33
|
+
async analyzeClassWithJavap(jarPath, className) {
|
|
34
|
+
try {
|
|
35
|
+
const javapCmd = this.getJavapCommand();
|
|
36
|
+
const quotedJavapCmd = javapCmd.includes(' ') ? `"${javapCmd}"` : javapCmd;
|
|
37
|
+
const quotedJarPath = jarPath.includes(' ') ? `"${jarPath}"` : jarPath;
|
|
38
|
+
// Use javap -v to get detailed information (including parameter names)
|
|
39
|
+
const { stdout } = await execAsync(`${quotedJavapCmd} -v -cp ${quotedJarPath} ${className}`, { timeout: 10000 });
|
|
40
|
+
return this.parseJavapOutput(stdout, className);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.error('javap analysis failed:', error);
|
|
44
|
+
throw new Error(`javap analysis failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parse javap output
|
|
49
|
+
*/
|
|
50
|
+
parseJavapOutput(output, className) {
|
|
51
|
+
const lines = output.split('\n');
|
|
52
|
+
const analysis = {
|
|
53
|
+
className: className.split('.').pop() || className,
|
|
54
|
+
packageName: '',
|
|
55
|
+
modifiers: [],
|
|
56
|
+
superClass: undefined,
|
|
57
|
+
interfaces: [],
|
|
58
|
+
fields: [],
|
|
59
|
+
methods: []
|
|
60
|
+
};
|
|
61
|
+
let currentMethod = null;
|
|
62
|
+
let inLocalVariableTable = false;
|
|
63
|
+
let methodParameters = {};
|
|
64
|
+
for (let i = 0; i < lines.length; i++) {
|
|
65
|
+
const line = lines[i];
|
|
66
|
+
const trimmedLine = line.trim();
|
|
67
|
+
// Parse class declaration
|
|
68
|
+
if (trimmedLine.startsWith('public class') || trimmedLine.startsWith('public interface') ||
|
|
69
|
+
trimmedLine.startsWith('public enum')) {
|
|
70
|
+
this.parseClassDeclaration(trimmedLine, analysis);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
// Parse method declaration
|
|
74
|
+
if (trimmedLine.startsWith('public ') && trimmedLine.includes('(') && trimmedLine.includes(')')) {
|
|
75
|
+
currentMethod = this.parseMethodFromJavap(trimmedLine);
|
|
76
|
+
if (currentMethod) {
|
|
77
|
+
analysis.methods.push(currentMethod);
|
|
78
|
+
methodParameters = {};
|
|
79
|
+
}
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
// Detect LocalVariableTable start
|
|
83
|
+
if (trimmedLine === 'LocalVariableTable:') {
|
|
84
|
+
inLocalVariableTable = true;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
// Parse parameter names in LocalVariableTable
|
|
88
|
+
if (inLocalVariableTable && currentMethod) {
|
|
89
|
+
if (trimmedLine.startsWith('Start') || trimmedLine.startsWith('Slot')) {
|
|
90
|
+
continue; // Skip header
|
|
91
|
+
}
|
|
92
|
+
if (trimmedLine === '') {
|
|
93
|
+
// LocalVariableTable ended, immediately update current method's parameter names
|
|
94
|
+
if (Object.keys(methodParameters).length > 0) {
|
|
95
|
+
const updatedParams = [];
|
|
96
|
+
for (let j = 0; j < currentMethod.parameters.length; j++) {
|
|
97
|
+
const paramType = currentMethod.parameters[j];
|
|
98
|
+
const paramName = methodParameters[j] || `param${j + 1}`;
|
|
99
|
+
updatedParams.push(`${paramType} ${paramName}`);
|
|
100
|
+
}
|
|
101
|
+
currentMethod.parameters = updatedParams;
|
|
102
|
+
}
|
|
103
|
+
inLocalVariableTable = false;
|
|
104
|
+
methodParameters = {};
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
// Parse parameter line: "0 6 0 file Ljava/io/File;"
|
|
108
|
+
const paramMatch = trimmedLine.match(/^\s*\d+\s+\d+\s+(\d+)\s+(\w+)\s+(.+)$/);
|
|
109
|
+
if (paramMatch) {
|
|
110
|
+
const slot = parseInt(paramMatch[1]);
|
|
111
|
+
const paramName = paramMatch[2];
|
|
112
|
+
const paramType = paramMatch[3];
|
|
113
|
+
// Only handle parameters (slot >= 0, but exclude local variables)
|
|
114
|
+
// Parameters are usually in the first few slots, local variables come after
|
|
115
|
+
if (slot >= 0 && slot < currentMethod.parameters.length) {
|
|
116
|
+
methodParameters[slot] = paramName;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Detect method end - when next method or class end is encountered
|
|
121
|
+
if (currentMethod && ((trimmedLine.startsWith('public ') && trimmedLine.includes('(') && trimmedLine.includes(')')) ||
|
|
122
|
+
trimmedLine.startsWith('}') ||
|
|
123
|
+
trimmedLine.startsWith('SourceFile:'))) {
|
|
124
|
+
// Update method's parameter names
|
|
125
|
+
if (Object.keys(methodParameters).length > 0) {
|
|
126
|
+
const updatedParams = [];
|
|
127
|
+
for (let j = 0; j < currentMethod.parameters.length; j++) {
|
|
128
|
+
const paramType = currentMethod.parameters[j];
|
|
129
|
+
const paramName = methodParameters[j] || `param${j + 1}`;
|
|
130
|
+
updatedParams.push(`${paramType} ${paramName}`);
|
|
131
|
+
}
|
|
132
|
+
currentMethod.parameters = updatedParams;
|
|
133
|
+
}
|
|
134
|
+
currentMethod = null;
|
|
135
|
+
inLocalVariableTable = false;
|
|
136
|
+
methodParameters = {};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return analysis;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Parse class declaration
|
|
143
|
+
*/
|
|
144
|
+
parseClassDeclaration(line, analysis) {
|
|
145
|
+
// Extract modifiers
|
|
146
|
+
const modifiers = line.match(/\b(public|private|protected|static|final|abstract|strictfp)\b/g) || [];
|
|
147
|
+
analysis.modifiers = modifiers;
|
|
148
|
+
// Extract package name (inferred from class name)
|
|
149
|
+
const classMatch = line.match(/(?:public\s+)?(?:class|interface|enum)\s+([a-zA-Z_$][a-zA-Z0-9_$.]*)/);
|
|
150
|
+
if (classMatch) {
|
|
151
|
+
const fullClassName = classMatch[1];
|
|
152
|
+
const parts = fullClassName.split('.');
|
|
153
|
+
if (parts.length > 1) {
|
|
154
|
+
analysis.packageName = parts.slice(0, -1).join('.');
|
|
155
|
+
analysis.className = parts[parts.length - 1];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// Extract superclass
|
|
159
|
+
const extendsMatch = line.match(/extends\s+([a-zA-Z_$][a-zA-Z0-9_$.]*)/);
|
|
160
|
+
if (extendsMatch) {
|
|
161
|
+
analysis.superClass = extendsMatch[1];
|
|
162
|
+
}
|
|
163
|
+
// Extract interfaces
|
|
164
|
+
const implementsMatch = line.match(/implements\s+([^{]+)/);
|
|
165
|
+
if (implementsMatch) {
|
|
166
|
+
const interfaces = implementsMatch[1]
|
|
167
|
+
.split(',')
|
|
168
|
+
.map(iface => iface.trim())
|
|
169
|
+
.filter(iface => iface);
|
|
170
|
+
analysis.interfaces = interfaces;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Parse method from javap output
|
|
175
|
+
*/
|
|
176
|
+
parseMethodFromJavap(line) {
|
|
177
|
+
try {
|
|
178
|
+
const trimmedLine = line.trim();
|
|
179
|
+
// Extract modifiers
|
|
180
|
+
const modifiers = [];
|
|
181
|
+
let startIndex = 0;
|
|
182
|
+
const modifierWords = ['public', 'private', 'protected', 'static', 'final', 'abstract', 'synchronized', 'native'];
|
|
183
|
+
// Handle multiple modifiers
|
|
184
|
+
let remainingLine = trimmedLine;
|
|
185
|
+
while (true) {
|
|
186
|
+
let foundModifier = false;
|
|
187
|
+
for (const modifier of modifierWords) {
|
|
188
|
+
if (remainingLine.startsWith(modifier + ' ')) {
|
|
189
|
+
modifiers.push(modifier);
|
|
190
|
+
remainingLine = remainingLine.substring(modifier.length + 1);
|
|
191
|
+
startIndex += modifier.length + 1;
|
|
192
|
+
foundModifier = true;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (!foundModifier) {
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// Find method name and parameters part
|
|
201
|
+
const parenIndex = trimmedLine.indexOf('(');
|
|
202
|
+
if (parenIndex === -1)
|
|
203
|
+
return null;
|
|
204
|
+
const closeParenIndex = trimmedLine.indexOf(')', parenIndex);
|
|
205
|
+
if (closeParenIndex === -1)
|
|
206
|
+
return null;
|
|
207
|
+
// Extract return type and method name
|
|
208
|
+
const beforeParen = trimmedLine.substring(startIndex, parenIndex).trim();
|
|
209
|
+
const lastSpaceIndex = beforeParen.lastIndexOf(' ');
|
|
210
|
+
if (lastSpaceIndex === -1)
|
|
211
|
+
return null;
|
|
212
|
+
const returnType = beforeParen.substring(0, lastSpaceIndex).trim();
|
|
213
|
+
const methodName = beforeParen.substring(lastSpaceIndex + 1).trim();
|
|
214
|
+
// Extract parameters
|
|
215
|
+
const paramsStr = trimmedLine.substring(parenIndex + 1, closeParenIndex).trim();
|
|
216
|
+
const parameters = [];
|
|
217
|
+
if (paramsStr) {
|
|
218
|
+
// Handle parameters, need to consider generics and nested types
|
|
219
|
+
const paramParts = this.splitParameters(paramsStr);
|
|
220
|
+
for (const param of paramParts) {
|
|
221
|
+
const trimmedParam = param.trim();
|
|
222
|
+
if (trimmedParam) {
|
|
223
|
+
parameters.push(trimmedParam);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return {
|
|
228
|
+
name: methodName,
|
|
229
|
+
returnType,
|
|
230
|
+
parameters,
|
|
231
|
+
modifiers
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
console.error('Failed to parse method:', line, error);
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Smart parameter splitting, handling generics and nested types
|
|
241
|
+
*/
|
|
242
|
+
splitParameters(paramsStr) {
|
|
243
|
+
const params = [];
|
|
244
|
+
let current = '';
|
|
245
|
+
let angleBracketCount = 0;
|
|
246
|
+
for (let i = 0; i < paramsStr.length; i++) {
|
|
247
|
+
const char = paramsStr[i];
|
|
248
|
+
if (char === '<') {
|
|
249
|
+
angleBracketCount++;
|
|
250
|
+
}
|
|
251
|
+
else if (char === '>') {
|
|
252
|
+
angleBracketCount--;
|
|
253
|
+
}
|
|
254
|
+
else if (char === ',' && angleBracketCount === 0) {
|
|
255
|
+
params.push(current.trim());
|
|
256
|
+
current = '';
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
current += char;
|
|
260
|
+
}
|
|
261
|
+
if (current.trim()) {
|
|
262
|
+
params.push(current.trim());
|
|
263
|
+
}
|
|
264
|
+
return params;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Get javap command path
|
|
268
|
+
*/
|
|
269
|
+
getJavapCommand() {
|
|
270
|
+
const javaHome = process.env.JAVA_HOME;
|
|
271
|
+
if (javaHome) {
|
|
272
|
+
return path.join(javaHome, 'bin', 'javap.exe');
|
|
273
|
+
}
|
|
274
|
+
return 'javap';
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Get class inheritance hierarchy
|
|
278
|
+
*/
|
|
279
|
+
async getInheritanceHierarchy(className, projectPath) {
|
|
280
|
+
const analysis = await this.analyzeClass(className, projectPath);
|
|
281
|
+
const hierarchy = [className];
|
|
282
|
+
if (analysis.superClass) {
|
|
283
|
+
try {
|
|
284
|
+
const superHierarchy = await this.getInheritanceHierarchy(analysis.superClass, projectPath);
|
|
285
|
+
hierarchy.unshift(...superHierarchy);
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
// If parent class is not in current project, add directly
|
|
289
|
+
hierarchy.unshift(analysis.superClass);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return hierarchy;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Find all subclasses of a class
|
|
296
|
+
*/
|
|
297
|
+
async findSubClasses(className, projectPath) {
|
|
298
|
+
const allClasses = await this.scanner.getAllClassNames(projectPath);
|
|
299
|
+
const subClasses = [];
|
|
300
|
+
for (const cls of allClasses) {
|
|
301
|
+
try {
|
|
302
|
+
const analysis = await this.analyzeClass(cls, projectPath);
|
|
303
|
+
if (analysis.superClass === className) {
|
|
304
|
+
subClasses.push(cls);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
// Ignore types that failed analysis
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return subClasses;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
//# sourceMappingURL=JavaClassAnalyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JavaClassAnalyzer.js","sourceRoot":"","sources":["../../src/analyzer/JavaClassAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAyBlC,MAAM,OAAO,iBAAiB;IAClB,OAAO,CAAoB;IAEnC;QACI,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,SAAiB,EAAE,WAAmB;QACrD,IAAI,CAAC;YACD,yBAAyB;YACzB,M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AC;gBACzB,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,oCAAoC;YACxC,CAAC;QACL,CAAC;QAED,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { JavaClassAnalyzerMCPServer } from './index.js';
|
|
4
|
+
const program = new Command();
|
|
5
|
+
program
|
|
6
|
+
.name('jarp-mcp')
|
|
7
|
+
.description('JARP MCP - Java Archive Reader for AI. MCP server that gives AI agents instant access to decompiled Java code.')
|
|
8
|
+
.version('1.0.1');
|
|
9
|
+
program
|
|
10
|
+
.command('start')
|
|
11
|
+
.description('Start MCP server')
|
|
12
|
+
.option('-e, --env <environment>', 'Runtime environment (development|production)', 'production')
|
|
13
|
+
.action(async (options) => {
|
|
14
|
+
// Set environment variables
|
|
15
|
+
if (options.env) {
|
|
16
|
+
process.env.NODE_ENV = options.env;
|
|
17
|
+
}
|
|
18
|
+
console.log(`Starting Java Class Analyzer MCP Server (${options.env} mode)...`);
|
|
19
|
+
const server = new JavaClassAnalyzerMCPServer();
|
|
20
|
+
await server.run();
|
|
21
|
+
});
|
|
22
|
+
program
|
|
23
|
+
.command('test')
|
|
24
|
+
.description('Test MCP server functionality')
|
|
25
|
+
.option('-p, --project <path>', 'Maven project path')
|
|
26
|
+
.option('-c, --class <className>', 'Class name to test')
|
|
27
|
+
.option('--no-cache', 'Do not use cache')
|
|
28
|
+
.option('--cfr-path <path>', 'CFR decompiler tool path')
|
|
29
|
+
.action(async (options) => {
|
|
30
|
+
console.log('Test mode - please use test-tools.js for complete testing');
|
|
31
|
+
console.log('Run: node test-tools.js --help for detailed usage');
|
|
32
|
+
});
|
|
33
|
+
program
|
|
34
|
+
.command('config')
|
|
35
|
+
.description('Generate MCP client configuration example')
|
|
36
|
+
.option('-o, --output <file>', 'Output configuration file path', 'mcp-client-config.json')
|
|
37
|
+
.action(async (options) => {
|
|
38
|
+
const config = {
|
|
39
|
+
mcpServers: {
|
|
40
|
+
"jarp-mcp": {
|
|
41
|
+
command: "jarp-mcp",
|
|
42
|
+
args: ["start"],
|
|
43
|
+
env: {
|
|
44
|
+
NODE_ENV: "production",
|
|
45
|
+
MAVEN_REPO: process.env.MAVEN_REPO || "",
|
|
46
|
+
JAVA_HOME: process.env.JAVA_HOME || "",
|
|
47
|
+
CFR_PATH: process.env.CFR_PATH || ""
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const fs = await import('fs-extra');
|
|
53
|
+
await fs.default.writeJson(options.output, config, { spaces: 2 });
|
|
54
|
+
console.log(`MCP client configuration generated: ${options.output}`);
|
|
55
|
+
console.log('\nUsage instructions:');
|
|
56
|
+
console.log('1. Add this configuration to your MCP client configuration file');
|
|
57
|
+
console.log('2. Modify environment variable settings as needed');
|
|
58
|
+
console.log('3. Restart MCP client');
|
|
59
|
+
});
|
|
60
|
+
// Default command
|
|
61
|
+
if (process.argv.length === 2) {
|
|
62
|
+
// If no subcommand provided, start server by default
|
|
63
|
+
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
64
|
+
const server = new JavaClassAnalyzerMCPServer();
|
|
65
|
+
server.run().catch((error) => {
|
|
66
|
+
console.error('Server startup failed:', error);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
program.parse();
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA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GAAG,IAAI,0BAA0B,EAAE,CAAC;IAChD,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACzB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;AACP,CAAC;KAAM,CAAC;IACJ,OAAO,CAAC,KAAK,EAAE,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare class DecompilerService {
|
|
2
|
+
private scanner;
|
|
3
|
+
private cfrPath;
|
|
4
|
+
constructor();
|
|
5
|
+
private initializeCfrPath;
|
|
6
|
+
/**
|
|
7
|
+
* Decompile specified Java class file
|
|
8
|
+
*/
|
|
9
|
+
decompileClass(className: string, projectPath: string, useCache?: boolean, cfrPath?: string): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Get cache file path
|
|
12
|
+
*/
|
|
13
|
+
private getCachePath;
|
|
14
|
+
/**
|
|
15
|
+
* Extract specified .class file from JAR package
|
|
16
|
+
*/
|
|
17
|
+
private extractClassFile;
|
|
18
|
+
/**
|
|
19
|
+
* Use CFR to decompile .class file
|
|
20
|
+
*/
|
|
21
|
+
private decompileWithCfr;
|
|
22
|
+
/**
|
|
23
|
+
* Find CFR jar package path
|
|
24
|
+
*/
|
|
25
|
+
private findCfrJar;
|
|
26
|
+
/**
|
|
27
|
+
* Batch decompile multiple classes
|
|
28
|
+
*/
|
|
29
|
+
decompileClasses(classNames: string[], projectPath: string, useCache?: boolean, cfrPath?: string): Promise<Map<string, string>>;
|
|
30
|
+
/**
|
|
31
|
+
* Get Java command path
|
|
32
|
+
*/
|
|
33
|
+
private getJavaCommand;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=DecompilerService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecompilerService.d.ts","sourceRoot":"","sources":["../../src/decompiler/DecompilerService.ts"],"names":[],"mappings":"AAeA,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,OAAO,CAAS;;YAOV,iBAAiB;IAU/B;;OAEG;IACG,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAc,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA+DzH;;OAEG;IACH,OAAO,CAAC,YAAY;IAQpB;;OAEG;YACW,gBAAgB;IA6D9B;;OAEG;YACW,gBAAgB;IAmC9B;;OAEG;YACW,UAAU;IAgCxB;;OAEG;IACG,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAc,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAiB3I;;OAEG;IACH,OAAO,CAAC,cAAc;CAQzB"}
|