Announcement

Collapse
No announcement yet.

Java: Newer and supported decompilers (not JAD)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java: Newer and supported decompilers (not JAD)

    TOPIC: Java: Newer and supported decompilers (not JAD)

    (1) Thank you Scooter. BC is great.
    (2) We all need you to keep supporting decompilation of warfile and jarfile s and the resulting seamless comparison within BC.
    (3) You seem to be using the venerable JAD decompiler. This has become an unsupported tool.
    (4) Good news is that there are a few, new and supported decompilers out there. These decompilers are also trying to support the newer features of Java 7 and Java 8
    (5) Here are some URLs for Scooter to reference, to possibly start shipping a new decompiler with BC.
    (6) https://bitbucket.org/mstrobel/procy...a%20Decompiler
    (7) http://www.benf.org/other/cfr/
    (8) http://javapapers.com/core-java/java-decompiler/

    Thank you. Many of us love this feature and will *rely* on it for years and years to com.

  • #2
    To clarify, Beyond Compare 3 does not ship with a decompiler for Java class files. Our File Formats are able to be customized to use External Conversion command lines, such as JAD, to help convert from one file type into plain text.

    We do have some previously created formats available for download (including a JAD based one) on our website. We can certainly review the resources you've posted here to see if we can update or create an alternate format, but Scooter Software does not directly support JAD or the other external programs used by the File Formats.

    If you are comfortable and familiar with using any of the above resources from the command line, all you would need to do is create a new Text format in the Tools menu -> File Formats dialog, with an external conversion command line which takes in a source file (file.class) and outputs a target temp text file (temp.txt). The target temp file is the one that would be opened in BC3, using %s and %t to represent the files in the External Conversion. We have a sample KB article (detailing a custom format for *.resx files) here:
    http://www.scootersoftware.com/suppo...rnalconversion
    Aaron P Scooter Software

    Comment


    • #3
      Thanks Aaron.
      (1) I wonder how many people feel that the seamless comparison of Java warfiles / jarfiles is a "killer feature" for this product ? (I know that I do)
      (2) Java 6, 7, 8 ... changes. Bytecodes change. JAD is not supported.
      (3) I'm guessing that I must have downloaded "these extra formats", as you mentioned. ( " ... We do have some previously created formats available for download ... ").
      If so, then I find your Java decompiler formats extremely important.
      (4) I did a quick peek-under-the-covers, and here is what I can see, without going to too much effort.
      Perhaps others are also interested.
      ---------------
      BeyondCompare >> Tools >> File Formats

      ###############################################
      (1) Name: Java Class to Source
      ###############################################
      Mask: *.class
      Description:
      {
      - Compares Java class files decompiled to source.
      - Uses Java decompiler, Jad:
      http://www.kpdus.com/jad.html
      }
      Tab:Coversion/Loading: Helpers\Java\CLASS_to_JAVA.bat %s %t

      Where: C:\Program Files (x86)\Beyond Compare 3\Helpers\Java\CLASS_to_JAVA.bat"
      {
      Helpers\Java\jad.exe -p %1 > %2
      }

      Tab:Grammar
      {
      Keyword=LOTS_OF_STUFF
      Identifier=LOTS_OF_STUFF
      Number=LOTS_OF_STUFF
      String=LOTS_OF_STUFF
      String=LOTS_OF_STUFF
      Comment=LOTS_OF_STUFF
      Comment=LOTS_OF_STUFF
      Operator=LOTS_OF_STUFF
      }

      ###############################################
      (2) Java Class to Source Tidied
      ###############################################
      Mask: *.class
      Descriptions:
      {
      - Compares Java class files decompiled to tidied source.
      - Uses Java decompiler, Jad: , http://www.kpdus.com/jad.html
      - Uses freeware converter, Jalopy: , http://jalopy.sourceforge.net
      - Requires Java JRE: , http://java.sun.com
      }

      Tab:Conversion/Loading: Helpers\Java\CLASS_to_JAVA_tidied.bat %s %t

      Where: "C:\Program Files (x86)\Beyond Compare 3\Helpers\Java\CLASS_to_JAVA_tidied.bat"
      {
      :GetTempName

      set tmpfile=%TMP%.\JadTidied-%RANDOM%-%TIME:~6,5%.tmp
      if exist "%tmpfile%" goto :GetTempName
      Helpers\Java\jad.exe -p %1 > "%tmpfile%"
      for %%F in (%tmpfile%) do set size=%%~zF
      if /I %size% equ 0 goto :SkipJalopy
      type "%tmpfile%" | java -classpath Helpers\Java\jalopy\lib\getopt.jar;Helpers\Java\ja lopy\lib\jalopy.jar;Helpers\Java\jalopy\lib\jalopy-console.jar;Helpers\Java\jalopy\lib\log4j.jar de.hunsicker.jalopy.plugin.console.ConsolePlugin > %2

      :SkipJalopy
      del "%tmpfile%"


      }

      Comment


      • #4
        The main problem is that JAD will not decompile newer Java class files.

        There are hacks like a program that "downgrades" the classes so that JAD has an easier time of it, but really, what's needed is a Java decompiler that copes with modern classes.

        This claims to fit the bill :

        http://jd.benow.ca/

        .. but it's not distributable for commercial purposes, and not open-source. Alas, there's no command-line variant that just takes a class file and dumps it to a Java source file - just a monolithic executable and an Eclipse plugin.

        Perhaps Scooter could enter into partnership with this guy and license his software? Wouldn't even mind a small extra license fee to buy this as a plugin for BC.

        Comment


        • #5
          Slightly more laborious : manual mode

          What this application will do, is open a JAR file and save all the sources as a zip archive.

          So you can use the manual method ...

          * Open a JAR
          * Use the "Save all source" command
          * Do this for another JAR
          * Compare the two ZIP files in BC

          If only you could use this on the command line...

          ... looking at the innards of the Eclipse plugin (which helpfully comes with libraries and source code) it ought to be possible to rig up a command line utility to produce Java output. But because of the licensing, people would have to do this for themselves (at least assemble it themselves like a kit).

          Comment


          • #6
            I can't find the work I did on it previously, but the one we'd likely switch to would be the FernFlower decompiler included with IntelliJ. It's open source, can run from the command line, and produces good results. What I remember from testing was that it was substantially slower than JAD though, which is why we haven't pursued it more actively.

            Edit: To clarify, the speed difference was annoying but manageable for a single pair of files, but added up quickly if you did a rules-based comparison of an entire .jar.
            Last edited by ZoŽ; 21-Jan-2015, 12:39 PM.
            ZoŽ P Scooter Software

            Comment


            • #7
              Support for Java Decompiler supporting Java 8

              I have written an addition to the Java Decompiler JD.
              Please find the ready to use bcpkg formats.

              Comment


              • #8
                Wow, I was just trying to use JD and found your work. Thanks!

                Comment

                Working...
                X