(Remove html character entities)
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=155
 
|id=155
  +
|previous=154
|title=Decompile Java .class files automatically
 
  +
|next=156
|created=November 7, 2001 3:16
+
|created=November 7, 2001
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=Lawrence Kesteloot
 
|author=Lawrence Kesteloot
 
|version=6.0
 
|version=6.0
 
|rating=9/7
 
|rating=9/7
  +
|category1=Java
|text=
 
  +
|category2=
 
 
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"))
 
 
 
 
 
 
}}
 
}}
 
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).
   
  +
<pre>
== Comments ==
 
 
function s:ReadClass(dir, classname)
 
execute "cd " . a:dir
 
execute "0read !javap -c " . a:classname
  +
1
 
setlocal readonly
 
setlocal nomodified
 
endfunction
   
 
autocmd BufReadCmd *.class
It doesn't work when package is used in java code.
 
 
\ call <SID>ReadClass(expand("<afile>:p:h"), expand("<afile>:t:r"))
  +
</pre>
   
 
==Comments==
Foo.java
 
 
It doesn't work when package is used in java code.
   
  +
<pre>
package com.foo.test;
 
class Foo
+
Foo.java
 
package com.foo.test;
{
 
  +
class Foo
 
{
   
}
+
}
  +
</pre>
   
 
The question is how to save package information?
 
The question is how to save package information?
   
maxiangjiang--AT--hotmail.com
 
, November 7, 2001 10:14
 
 
----
 
----
For jad:
+
For jad:
 
au BufReadCmd *.class setl readonly nomodified | %!jad -p <afile>
 
au BufReadCmd *.class setl readonly nomodified | %!jad -p &lt;afile&gt;
 
 
   
do1--AT--yandex.ru
 
, March 6, 2006 4:06
 
 
----
 
----
<!-- parsed by vimtips.py in 0.654098 seconds-->
 

Latest revision as of 08:34, 28 September 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"))

Comments[edit | edit source]

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>

Community content is available under CC-BY-SA unless otherwise noted.