(defvar jdc-command "jad"
"The name of the decompiler if it's on your path, otherwise
a full qualified path to it.")
(defvar jdc-parameter " -space -t2 "
"Extra parameter which should be added to the call of the decompiler.")
(defvar jdc-extension "jad"
"The extension which is used for the generated java files.")
(defun jdc-find-file ()
"Find a classfile and decompile it, opening the decompiled file instead."
(interactive)
(let ((jdc-classfile (read-file-name ".class file: ")))
(find-file jdc-classfile)
(jdc-buffer)
(jde-mode)))
(defun jdc-buffer ()
"Construct the command for decompiling a class file, call the resulting
command and load the decompiled file."
(let*
(
(jdc-classfile (file-name-nondirectory (buffer-file-name)))
(jdc-javafile (concat (substring jdc-classfile 0 -5) jdc-extension))
(command (concat jdc-command jdc-parameter jdc-classfile)))
(shell-command command)
(find-alternate-file jdc-javafile)))
(add-hook
'find-file-hooks
(lambda ()
(let ((file (buffer-file-name)))
(cond ((string= (substring file -6) ".class")
(progn (jdc-buffer) (jde-mode)))))))
(provide 'javadecomp)
|