I have configured vim to automatically decompile ".class" files similar to the instructions in: http://vim.wikia.com/wiki/VimTip54.
I have made a minor change to use cfr_0_115 as below:
augr class au! au bufreadpost,filereadpost *.class silent %!java -jar /blah/cfr_0_115.jar % au bufreadpost,filereadpost *.class set readonly au bufreadpost,filereadpost *.class set ft=java au bufreadpost,filereadpost *.class silent normal gg=G au bufreadpost,filereadpost *.class set nomodified augr END
This works fine when opening files from the shell.
Sometimes I work with JAR files and would like to achieve the following workflow:
:Explore(and navigate to the JAR file)
- View the JAR file and select a Class
- When this Class is opened, it should be ran through CFR.
Currently, when I get to step "3" the class is not decompiled for viewing. I'd love to know how I can get the class file from a JAR opened 'through' the class decompiler.
Edit 1 -
With Vim logging enabled, when I open a class file that is NOT within a JAR file, I see
Executing BufRead Auto commands for "*.class include the command I wish to run. However, when I open the class file from within a jar, I do not see the command in the logs.
Edit 2 - Relevant log entries when opening a JAR:
Executing BufReadCmd Auto commands for "zipfile:*/*" autocommand call zip#Read(expand("<amatch>"), 1) Calling shell to execute: "(unzip -p -- '/blah/original-httpclienttest-1.0.jar' 'com/atlassianlabs/sslclient/Main.class') >/var/folders/ys/18xytj217f749_vx7rhs4t7w0000gp/T/vwqRYKe/1 2>&1" chdir(zipfile:/blah/original-httpclienttest-1.0.jar::com/) fchdir() to previous dir Reading viminfo file "/blah/.viminfo" marks
Executing BufRead Auto commands for "*.class" autocommand setf stata
However when I open a class file by navigating to it directly with the file explore (:Explore) I see:
Executing BufRead Auto commands for "*.class" autocommand silent %!java -jar /blah/cfr_0_115.jar
I don't know why the autocmd's that exist are not getting picked up when opening from a JAR, because VIM is actually running some autocmd, just not the one I want and "autocommand setf stata" is not even present when opening a class. I'm blocked in terms of how to debug this further.
I got this working to some extent by adding a function to the filetype.vim file on class files. However, vim reports the file name in the format: ZIPFILEPATH::PATHTOCLASS in the JAR.. I was hoping it would send though the temp file path instead.