Wikia

Vim Tips Wiki

Changes: Decompile Java .class files automatically

Edit

Back to page

(Move categories to tip template)
(Remove html character entities)
 
Line 24: Line 24:
   
 
autocmd BufReadCmd *.class
 
autocmd BufReadCmd *.class
\ call <SID>ReadClass(expand("<afile>:p:h"), expand("<afile>:t:r"))
+
\ call <SID>ReadClass(expand("<afile>:p:h"), expand("<afile>:t:r"))
 
</pre>
 
</pre>
   
Line 43: Line 43:
 
----
 
----
 
For jad:
 
For jad:
au BufReadCmd *.class setl readonly nomodified | %!jad -p &lt;afile&gt;
+
au BufReadCmd *.class setl readonly nomodified | %!jad -p <afile>
   
 
----
 
----

Latest revision as of 08:34, September 28, 2008

Tip 155 Printable Monobook Previous Next

created November 7, 2001 · complexity intermediate · author Lawrence Kesteloot · version 6.0


Here's a plugin to automatically decompile Java .class files as they're read in. Tweak the javap flags for what you want to see. I didn't post this as a script because it's too simple and it's really more useful for demonstrating how to read decompilable files (or other binary files that can be converted to text).

function s:ReadClass(dir, classname)
  execute "cd " . a:dir
  execute "0read !javap -c " . a:classname
  1
  setlocal readonly
  setlocal nomodified
endfunction

autocmd BufReadCmd *.class
  \ call <SID>ReadClass(expand("<afile>:p:h"), expand("<afile>:t:r"))

CommentsEdit

It doesn't work when package is used in java code.

Foo.java
package com.foo.test;
class Foo
{

}

The question is how to save package information?


For jad:

au BufReadCmd *.class setl readonly nomodified | %!jad -p <afile>

Around Wikia's network

Random Wiki