if such a creature exists for a java .class
Several, in fact: https://www.libhunt.com/l/java/topic/decompiler
I cannot see how having a plugin do it would make the process any easier
Maybe a script instead?
# -*- coding: utf-8 -*-
from __future__ import print_function # for py 2.7
import sys
import subprocess
import tempfile
from os import path
from Npp import notepad
"""
Shells out to the Procyon decompiler and opens the generated source in Notepad++
https://github.com/mstrobel/procyon/wiki/Java-Decompiler
ASSUMPTIONS
-----------
1. a JAVA_HOME environment variable is set, or the path to java.exe is on the PATH
2. procyon.jar is on the class path; otherwise provide the absolute path,
e.g., r'C:\java\tools\procyon\0.5.36\procyon.jar'
"""
def show_decompiled():
try:
binary = notepad.prompt('File path to the compiled class/jar:', 'Java Decompiler Script', 'Hello.class')
if binary is None:
# assume current file is a Java source file that's been compiled *in situ*
binary = path.splitext(notepad.getCurrentFilename())[0] + '.class'
elif not path.exists(binary):
raise IOError('Can''t find class/jar "%s"!' % binary)
CMD = [
'java',
'-jar',
'procyon.jar',
'-dl', # debug line numbers
binary
]
if subprocess.check_call(CMD, shell=True) == 0:
decompiled = subprocess.check_output(CMD, shell=True).decode('utf-8')
_, java_src = tempfile.mkstemp(suffix='.java', text=True)
if java_src:
with open(java_src, 'w') as file:
file.write(decompiled)
notepad.open(java_src)
except (subprocess.CalledProcessError, IOError) as exc:
notepad.messageBox(str(exc), 'Java Decompiler Script')
print(exc, file=sys.stderr)
if __name__ == '__main__':
show_decompiled()
jdecomp-py-select
jdecomp-py-enter
jdecomp-py-profit