MCPcopy Create free account
hub / github.com/RuoJi6/java-decompile-mcp / run_cfr

Function run_cfr

java_decompiler_mcp/__init__.py:72–97  ·  view source on GitHub ↗

运行 CFR 反编译

(cfr_path: str, input_path: str, output_dir: str)

Source from the content-addressed store, hash-verified

70
71
72def run_cfr(cfr_path: str, input_path: str, output_dir: str) -> tuple[bool, str]:
73 """运行 CFR 反编译"""
74 cmd = [
75 "java", "-jar", cfr_path,
76 input_path,
77 "--outputdir", output_dir
78 ]
79
80 try:
81 result = subprocess.run(
82 cmd,
83 capture_output=True,
84 text=True,
85 timeout=300
86 )
87
88 if result.returncode == 0:
89 return True, result.stdout or "反编译成功"
90 else:
91 return False, result.stderr or result.stdout or "反编译失败"
92 except subprocess.TimeoutExpired:
93 return False, "反编译超时(超过5分钟)"
94 except FileNotFoundError:
95 return False, "未找到 Java 运行时,请确保已安装 Java 并添加到 PATH"
96 except Exception as e:
97 return False, f"反编译出错: {str(e)}"
98
99
100def collect_files(path: str, extensions: tuple = (".class", ".jar")) -> list[str]:

Callers 3

decompile_fileFunction · 0.85
decompile_filesFunction · 0.85
process_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected