Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Java Decompiler

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I was thinking of a task of creating my own Java Decompiler.
The methods, contructors and fields can be obtained using the Java reflection API. But how to get the functionality that is writtn inside the method, contructor.

Moreover I have seen the decompiler retrives even the comments.

So,for that, do I need to understand the byte code, or Java API provides some mechanism to do so?

Regards
Sandeep Jindal
 
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you need to understand bytecode.

You could have a look at BCEL
http://jakarta.apache.org/bcel/
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Sandeep Jindal:

Moreover I have seen the decompiler retrives even the comments.



No, you haven't. Source code comments aren't put into in a .class file.
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check out Corey's article about JavaP, it may help you to start understanding source code:

The SCJP Tip Line - Looking "Under the Hood" with javap by Corey McGlone
 
author
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the Cookbook I talk about the Reflection API, which you can use to write the easy part of javap.
It has methods like getMethods(), getFields(), getConstructors(), etc. and is actually one of the fun
parts of Java. I jokingly refer to certain other books that are mostly API cross reference generated
mechanically using Reflection, saying "I show you how to write their book, but they don't show
you how to write mine".

That said, the reflection API does not give you access to the bytecode, which you would need for the decompiler project. You could maybe play games with a ClassLoader to get it, there's no need to; as has been pointed out, BCEL provides a toolkit specifically for dealing with bytecode files.

Ian
 
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How obfuscator is working?
 
Pradeep bhatt
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by David Ulicny:
How obfuscator is working?



http://www.cs.arizona.edu/~collberg/Research/Students/DouglasLow/obfuscation.html
 
Pradeep bhatt
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Article on ASM tool kit fro bytecode manipulation
http://www.onjava.com/pub/a/onjava/2004/10/06/asm1.html
 
Pradeep bhatt
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
 
Sandeep Jindal
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ian, Pradeep,

Thanks to all, for the links and the information.
This is helping me a lot.

Regards
 
Pradeep bhatt
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
 
Did you miss me? Did you miss this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic