Vim logo vim online Vim Book Ad

 Tip #155: Decompile Java .class files automatically

 tip karma   Rating 7/4, Viewed by 951 

created:   November 7, 2001 3:16      complexity:   intermediate
author:   Lawrence Kesteloot      as of Vim:   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"))

 rate this tip  Life Changing Helpful Unfulfilling 

<<Mappings to facilitate the creation of text | describe <table name> from vim >>

Additional Notes

[email protected], November 7, 2001 10:14

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?
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
SourceForge Logo