decompiling class files

Discussion in 'Java' started by Aryeh M. Friedman, Nov 1, 2007.

  1. In switch machines I lost a critical set or source code but I still
    have the .class files is there anyway decompile them and/or make my
    life a little easier instead of a ground up rewrite (will take maybe 4
    hours)
     
    Aryeh M. Friedman, Nov 1, 2007
    #1
    1. Advertising

  2. On Nov 1, 3:49 pm, "Aryeh M. Friedman" <>
    wrote:
    > In switch machines I lost a critical set or source code but I still
    > have the .class files is there anyway decompile them and/or make my
    > life a little easier instead of a ground up rewrite (will take maybe 4
    > hours)


    JAD (http://www.kpdus.com/jad.html) is pretty common dis-assembler for
    Java class files.

    -cheers,
    Manish
     
    Manish Pandit, Nov 1, 2007
    #2
    1. Advertising

  3. Aryeh M. Friedman wrote:
    > In switch machines I lost a critical set or source code but I still
    > have the .class files is there anyway decompile them and/or make my
    > life a little easier instead of a ground up rewrite (will take maybe 4
    > hours)


    JAD

    http://www.kpdus.com/jad.html

    Arne
     
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=, Nov 1, 2007
    #3
  4. Aryeh M. Friedman

    Roedy Green Guest

    On Thu, 01 Nov 2007 22:49:15 -0000, "Aryeh M. Friedman"
    <> wrote, quoted or indirectly quoted someone
    who said :

    >In switch machines I lost a critical set or source code but I still
    >have the .class files is there anyway decompile them and/or make my
    >life a little easier instead of a ground up rewrite (will take maybe 4
    >hours)


    see http://mindprod.com/jgloss/decompiler.html
    you won't get your comments back or your local variable names.
    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Nov 2, 2007
    #4
  5. Aryeh M. Friedman

    Roedy Green Guest

    On Thu, 01 Nov 2007 22:49:15 -0000, "Aryeh M. Friedman"
    <> wrote, quoted or indirectly quoted someone
    who said :

    >In switch machines I lost a critical set or source code but I still
    >have the .class files is there anyway decompile them and/or make my
    >life a little easier instead of a ground up rewrite (will take maybe 4
    >hours)


    see http://mindprod.com/bgloss/backup.html
    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Nov 2, 2007
    #5
  6. Aryeh M. Friedman

    Lew Guest

    Roedy Green wrote:
    > On Thu, 01 Nov 2007 22:49:15 -0000, "Aryeh M. Friedman"
    > <> wrote, quoted or indirectly quoted someone
    > who said :
    >
    >> In switch machines I lost a critical set or source code but I still
    >> have the .class files is there anyway decompile them and/or make my
    >> life a little easier instead of a ground up rewrite (will take maybe 4
    >> hours)

    >
    > see http://mindprod.com/bgloss/backup.html


    I'll bet it takes longer than four hours to decompile and work out all the kinks.

    --
    Lew
     
    Lew, Nov 2, 2007
    #6
  7. "Aryeh M. Friedman" <> writes:

    > In switch machines I lost a critical set or source code but I still
    > have the .class files is there anyway decompile them and/or make my
    > life a little easier instead of a ground up rewrite (will take maybe 4
    > hours)


    Decompilers exist, but you'd have to google around (for "java decompiler"),
    download one, install it, spend some time getting familiar with it, etc.
    And after you were done, you'd have only the .java files - you'd still have
    to recreate the IDE project, ant file, or whatever other build environment
    you used for it.

    You'd be just as well off doing the four-hour rewrite, IMHO.

    sherm--

    --
    Web Hosting by West Virginians, for West Virginians: http://wv-www.net
    Cocoa programming in Perl: http://camelbones.sourceforge.net
     
    Sherman Pendley, Nov 2, 2007
    #7
  8. On Nov 1, 8:21 pm, Lew <> wrote:
    > Roedy Green wrote:
    > > On Thu, 01 Nov 2007 22:49:15 -0000, "Aryeh M. Friedman"
    > > <> wrote, quoted or indirectly quoted someone
    > > who said :

    >
    > >> In switch machines I lost a critical set or source code but I still
    > >> have the .class files is there anyway decompile them and/or make my
    > >> life a little easier instead of a ground up rewrite (will take maybe 4
    > >> hours)

    >
    > > seehttp://mindprod.com/bgloss/backup.html

    >
    > I'll bet it takes longer than four hours to decompile and work out all the kinks.
    >
    > --
    > Lew


    Took 45 mins with jad
     
    Aryeh M. Friedman, Nov 2, 2007
    #8
  9. On Nov 1, 8:34 pm, Sherman Pendley <> wrote:
    > "Aryeh M. Friedman" <> writes:
    >
    > > In switch machines I lost a critical set or source code but I still
    > > have the .class files is there anyway decompile them and/or make my
    > > life a little easier instead of a ground up rewrite (will take maybe 4
    > > hours)

    >
    > Decompilers exist, but you'd have to google around (for "java decompiler"),
    > download one, install it, spend some time getting familiar with it, etc.
    > And after you were done, you'd have only the .java files - you'd still have
    > to recreate the IDE project, ant file, or whatever other build environment
    > you used for it.
    >
    > You'd be just as well off doing the four-hour rewrite, IMHO.


    Took 45 mins with Jad. Very obvious command line interface (jad
    *.class) and then just some file manipulation to move it back to the
    right location.... Since I don't use an IDE it was probably easier
    then typical
     
    Aryeh M. Friedman, Nov 2, 2007
    #9
  10. Aryeh M. Friedman

    Lew Guest

    Lew wrote:
    >> I'll bet it takes longer than four hours to decompile and work out all the kinks.


    Aryeh M. Friedman wrote:
    > Took 45 mins with jad


    That is very impressive.

    I will look into this Jad thing. Does it do Java 6?

    It doesn't look like any of the ones mentioned on mindprod.com are new enough
    to handle Java 6.

    I do see that
    > since the version 1.5.6 it's no longer free for commercial use.
    > ... At the same time, Jad can be used freely for personal needs
    > in a commercial or non-commercial environments.


    So the loss of comments and local variable names wasn't a problem?

    What about all the Javadocs? How long did it take to redo those?

    --
    Lew
     
    Lew, Nov 2, 2007
    #10
  11. Lew wrote:
    > Lew wrote:
    >>> I'll bet it takes longer than four hours to decompile and work out
    >>> all the kinks.

    >
    > Aryeh M. Friedman wrote:
    >> Took 45 mins with jad

    >
    > That is very impressive.
    >
    > I will look into this Jad thing. Does it do Java 6?
    >
    > It doesn't look like any of the ones mentioned on mindprod.com are
    > new enough to handle Java 6.
    >
    > I do see that
    >> since the version 1.5.6 it's no longer free for commercial use.
    >> ... At the same time, Jad can be used freely for personal needs
    >> in a commercial or non-commercial environments.

    >
    > So the loss of comments and local variable names wasn't a problem?


    If the .class file was compiled for debug, jad will preserve local variable
    names.
     
    Mike Schilling, Nov 2, 2007
    #11
  12. On Nov 1, 11:47 pm, Lew <> wrote:
    > Lew wrote:
    > >> I'll bet it takes longer than four hours to decompile and work out all the kinks.

    > Aryeh M. Friedman wrote:
    > > Took 45 mins with jad

    >
    > That is very impressive.
    >
    > I will look into this Jad thing. Does it do Java 6?
    >
    > It doesn't look like any of the ones mentioned on mindprod.com are new enough
    > to handle Java 6.


    No I had to redo the generics by hand and thats why it was 45 mins not
    15. (I will at some point have to go back and rename/restyle stuff
    also)

    >
    > I do see that
    >
    > > since the version 1.5.6 it's no longer free for commercial use.
    > > ... At the same time, Jad can be used freely for personal needs
    > > in a commercial or non-commercial environments.

    >
    > So the loss of comments and local variable names wasn't a problem?


    If your goal is to get back your work without having to do an other
    debug cycle yes... but if it is maintain the complete formating of the
    orginal code oh well.

    >
    > What about all the Javadocs? How long did it take to redo those?


    That is part of the renaming/restyling but in my case it is only 10
    classes and about 3 methods each so it was pretty fast.
     
    Aryeh M. Friedman, Nov 2, 2007
    #12
  13. Aryeh M. Friedman

    Lew Guest

    Aryeh M. Friedman wrote:
    > No I had to redo the generics by hand and thats why it was 45 mins not
    > 15. (I will at some point have to go back and rename/restyle stuff
    > also)


    So the 45 minutes is not true. I was counting the rename/restyle in my
    estimate of how long it would take.

    --
    Lew
     
    Lew, Nov 2, 2007
    #13
  14. Aryeh M. Friedman

    Lew Guest

    Lew wrote:
    > Aryeh M. Friedman wrote:
    >> No I had to redo the generics by hand and thats why it was 45 mins not
    >> 15. (I will at some point have to go back and rename/restyle stuff
    >> also)

    >
    > So the 45 minutes is not true. I was counting the rename/restyle in my
    > estimate of how long it would take.


    I repeat:
    > What about all the Javadocs? How long did it take to redo those?


    --
    Lew
     
    Lew, Nov 2, 2007
    #14
  15. Lew wrote:
    > Lew wrote:
    >> Aryeh M. Friedman wrote:
    >>> No I had to redo the generics by hand and thats why it was 45 mins not
    >>> 15. (I will at some point have to go back and rename/restyle stuff
    >>> also)

    >>
    >> So the 45 minutes is not true. I was counting the rename/restyle in
    >> my estimate of how long it would take.

    >
    > I repeat:
    >> What about all the Javadocs? How long did it take to redo those?

    >


    There are two milestones in this sort of recovery:

    1. Getting to the point of having source code that can compiled,
    supporting continued development in other parts of the system.

    2. Being fully whole, with meaningful identifiers, javadocs, etc.

    Milestone #1 could be on the critical path for current development. In
    that case, I would look for the fastest way to achieve it, even if it is
    not necessarily any faster at getting to milestone #2. The remaining
    work needs doing, but can be done on a less urgent basis, perhaps as
    part of a refactoring pass.

    Patricia
     
    Patricia Shanahan, Nov 2, 2007
    #15
  16. Patricia Shanahan wrote:
    > Lew wrote:
    >> Lew wrote:
    >>> Aryeh M. Friedman wrote:
    >>>> No I had to redo the generics by hand and thats why it was 45 mins
    >>>> not 15. (I will at some point have to go back and rename/restyle stuff
    >>>> also)
    >>>
    >>> So the 45 minutes is not true. I was counting the rename/restyle in
    >>> my estimate of how long it would take.

    >>
    >> I repeat:
    >>> What about all the Javadocs? How long did it take to redo those?

    >>

    >
    > There are two milestones in this sort of recovery:
    >
    > 1. Getting to the point of having source code that can compiled,
    > supporting continued development in other parts of the system.
    >
    > 2. Being fully whole, with meaningful identifiers, javadocs, etc.
    >
    > Milestone #1 could be on the critical path for current development. In
    > that case, I would look for the fastest way to achieve it, even if it
    > is not necessarily any faster at getting to milestone #2. The
    > remaining work needs doing, but can be done on a less urgent basis,
    > perhaps as part of a refactoring pass.


    It's not obvious to me that the "four hour" estimate was for milestone 2
    rather than milestone 1. The other advantage of the decompilation route is
    that it's much less likely to introduce subtle changes in behavior than
    rewriting from scratch would be.
     
    Mike Schilling, Nov 2, 2007
    #16
  17. Lew wrote:
    > It doesn't look like any of the ones mentioned on mindprod.com are new
    > enough to handle Java 6.


    Well, I am currently writing a Java decompiler capable of handling Java
    6 right now.

    > What about all the Javadocs? How long did it take to redo those?


    One of my ideas is to add on a filter that can reproduce the Javadoc
    comments from the HTML documentation files.

    Would you like me to tell you when I finish it?

    --
    Beware of bugs in the above code; I have only proved it correct, not
    tried it. -- Donald E. Knuth
     
    Joshua Cranmer, Nov 2, 2007
    #17
  18. Joshua Cranmer wrote:
    > Lew wrote:
    >> It doesn't look like any of the ones mentioned on mindprod.com are
    >> new enough to handle Java 6.

    >
    > Well, I am currently writing a Java decompiler capable of handling
    > Java 6 right now.
    >
    >> What about all the Javadocs? How long did it take to redo those?

    >
    > One of my ideas is to add on a filter that can reproduce the Javadoc
    > comments from the HTML documentation files.


    What about generating empty Javadoc descriptions of all the methods?
    (assuming there's enough debug information present to get the parameter
    names right.)

    Speaking of which, I'd assumed a decompiler like jad wuld only find local
    variable names when the java file was compiled -g, but I see them being
    correct even with -g:none. Is the local variable table always present?
     
    Mike Schilling, Nov 2, 2007
    #18
  19. Aryeh M. Friedman

    Lew Guest

    Patricia Shanahan wrote:
    >> There are two milestones in this sort of recovery:
    >>
    >> 1. Getting to the point of having source code that can compiled,
    >> supporting continued development in other parts of the system.
    >>
    >> 2. Being fully whole, with meaningful identifiers, javadocs, etc.
    >>
    >> Milestone #1 could be on the critical path for current development. In
    >> that case, I would look for the fastest way to achieve it, even if it
    >> is not necessarily any faster at getting to milestone #2. The
    >> remaining work needs doing, but can be done on a less urgent basis,
    >> perhaps as part of a refactoring pass.


    Excellent points, and convincing.

    Mike Schilling wrote:
    > It's not obvious to me that the "four hour" estimate was for milestone 2


    Sorry, it was meant to represent complete recovery of the class. It never
    occurred to me that a partial recovery could be acceptable, or I'd've
    accounted for that possibility.

    I also hadn't known how easy Jad was to use, as I mentioned upthread. So even
    though I meant milestone #2 (not being aware that there was an earlier
    milestone), I was still wrong.

    > rather than milestone 1. The other advantage of the decompilation route is
    > that it's much less likely to introduce subtle changes in behavior than
    > rewriting from scratch would be.


    Another good point.

    --
    Lew
     
    Lew, Nov 2, 2007
    #19
  20. On Nov 2, 5:13 pm, "Mike Schilling" <>
    wrote:
    > Joshua Cranmer wrote:
    > > Lew wrote:
    > >> It doesn't look like any of the ones mentioned on mindprod.com are
    > >> new enough to handle Java 6.

    >
    > > Well, I am currently writing a Java decompiler capable of handling
    > > Java 6 right now.

    >
    > >> What about all the Javadocs? How long did it take to redo those?

    >
    > > One of my ideas is to add on a filter that can reproduce the Javadoc
    > > comments from the HTML documentation files.

    >
    > What about generating empty Javadoc descriptions of all the methods?
    > (assuming there's enough debug information present to get the parameter
    > names right.)


    Even if the names are not quite right you will have all your @params,
    @returns and @throws so that will help a lot for large projects
    (global search and replace is your friend)
     
    Aryeh M. Friedman, Nov 2, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sue
    Replies:
    1
    Views:
    1,087
    Andrew Thompson
    Jun 7, 2005
  2. Shane McDaniel
    Replies:
    0
    Views:
    1,594
    Shane McDaniel
    Jun 23, 2003
  3. E. Robert Tisdale
    Replies:
    2
    Views:
    1,485
    Default User
    Jun 23, 2003
  4. Juda
    Replies:
    3
    Views:
    562
    John Carson
    Jul 2, 2003
  5. IanT

    decompiling perl2exe files

    IanT, Feb 10, 2005, in forum: Perl Misc
    Replies:
    2
    Views:
    219
Loading...

Share This Page