Decompile Java

The environment is Ubuntu 16.04

Decompiled because the source of the classfile I made about 10 years ago is missing.

jad

"Decompile class with jad" http://qiita.com/Takmiy/items/0c968aab8460d93166b0

Try to see


Jad 1.5.8e for Linux on Intel platform (214917 bytes).
Jad 1.5.8e for Linux (statically linked) (389972 bytes) - take this version if the one above crashes or displays the "seek error" message.

After downloading and running the above


./jad: error while loading shared libraries: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory

Since it became, download the following and execute it. Try discompiling ../PDFConverter.class.


$ ./jad ../PDFConverter.class 
Parsing ../PDFConverter.class...The class file version is 49.0 (only 45.3, 46.0 and 47.0 are supported)
 Generating PDFConverter.jad
Overlapped try statements detected. Not all exception handlers will be resolved in the method main
Couldn't fully decompile method main
Couldn't resolve all exception handlers in method main

Ah, (only 45.3, 46.0 and 47.0 are supported) is out. I thought it wouldn't work, but a file called PDFConverter.jad was created.


$ head -30 PDFConverter.jad 
// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   PDFConverter.java

import com.sun.star.beans.PropertyValue;
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XStorable;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.util.XCloseable;
import java.io.File;

public class PDFConverter
{

    public PDFConverter()
    {
    }

    public static void main(String args[])
    {
        String s = convertToURL(args[0]);
        String s1 = getFilterName(args[0]);
        String s2 = s.replaceAll("\\..{3}\\Z", ".pdf");
        XComponentContext xcomponentcontext = Bootstrap.bootstrap();
        XMultiComponentFactory xmulticomponentfactory = xcomponentcontext.getServiceManager(); 

jd-gui

http://jd.benow.ca/ Download from here

Since the screenshot is Windows, I had a bad feeling, but I am relieved with multi-platform. Download jd-gui_1.4.0-0_all.deb.


$ sudo dpkg -i jd-gui_1.4.0-0_all.deb 
[sudo]nanbuwks password: 
Previously unselected package jd-You have selected gui.
(Loading database...Currently 793826 files and directories are installed.)
jd-gui_1.4.0-0_all.Preparing to deploy deb...
jd-gui (1.4.0-0)Is deploying...
jd-gui (1.4.0-0)Is set...

Call and execute JD-GUI from Dash of Unity

image

I did well.

Comparison


$ diff PDFConverter.jad ../PDFConverter-jdgui.java 
1,5d0
< // Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
< // Jad home page: http://www.geocities.com/kpdus/jad.html
< // Decompiler options: packimports(3) 
< // Source File Name:   PDFConverter.java
< 
19,20c14,16
< 
<     public PDFConverter()
---
>   public static void main(String[] paramArrayOfString)
>   {
>     try
21a18,61
>       String str1 = convertToURL(paramArrayOfString[0]);
>       String str2 = getFilterName(paramArrayOfString[0]);
>       String str3 = str1.replaceAll("\\..{3}\\Z", ".pdf");
>       
>       XComponentContext localXComponentContext = Bootstrap.bootstrap();
>       XMultiComponentFactory localXMultiComponentFactory = localXComponentContext.getServiceManager();
>       
>       Object localObject1 = localXMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", localXComponentContext);
>       
>       XComponentLoader localXComponentLoader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, localObject1);
>       
>       PropertyValue[] arrayOfPropertyValue = new PropertyValue[2];
>       
>       arrayOfPropertyValue[0] = new PropertyValue();
>       arrayOfPropertyValue[0].Name = "Hidden";
>       arrayOfPropertyValue[0].Value = new Boolean(true);
>       arrayOfPropertyValue[1] = new PropertyValue();
>       arrayOfPropertyValue[1].Name = "ReadOnly";
>       arrayOfPropertyValue[1].Value = new Boolean(true);
>       
>       XComponent localXComponent1 = localXComponentLoader.loadComponentFromURL(str1, "_blank", 0, arrayOfPropertyValue);
>       
>       arrayOfPropertyValue[0] = new PropertyValue();
>       arrayOfPropertyValue[0].Name = "FilterName";
>       arrayOfPropertyValue[0].Value = str2;
>       arrayOfPropertyValue[1] = new PropertyValue();
>       arrayOfPropertyValue[1].Name = "Overwrite";
>       arrayOfPropertyValue[1].Value = new Boolean(true);
>       
>       XStorable localXStorable = (XStorable)UnoRuntime.queryInterface(XStorable.class, localXComponent1);
>       
>       localXStorable.storeToURL(str3, arrayOfPropertyValue);
>       
>       XCloseable localXCloseable = (XCloseable)UnoRuntime.queryInterface(XCloseable.class, localXStorable);
>       if (localXCloseable != null)
>       {
>         localXCloseable.close(false);
>       }
>       else
>       {
>         XComponent localXComponent2 = (XComponent)UnoRuntime.queryInterface(XComponent.class, localXStorable);
>         
>         localXComponent2.dispose();
>       }
23,24c63
< 
<     public static void main(String args[])
---
>     catch (Exception localException)
26,69c65,66
<         String s = convertToURL(args[0]);
<         String s1 = getFilterName(args[0]);
<         String s2 = s.replaceAll("\\..{3}\\Z", ".pdf");
<         XComponentContext xcomponentcontext = Bootstrap.bootstrap();
<         XMultiComponentFactory xmulticomponentfactory = xcomponentcontext.getServiceManager();
<         Object obj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.Desktop", xcomponentcontext);
<         XComponentLoader xcomponentloader = (XComponentLoader)UnoRuntime.queryInterface(com/sun/star/frame/XComponentLoader, obj);
<         PropertyValue apropertyvalue[] = new PropertyValue[2];
<         apropertyvalue[0] = new PropertyValue();
<         apropertyvalue[0].Name = "Hidden";
<         apropertyvalue[0].Value = new Boolean(true);
<         apropertyvalue[1] = new PropertyValue();
<         apropertyvalue[1].Name = "ReadOnly";
<         apropertyvalue[1].Value = new Boolean(true);
<         XComponent xcomponent = xcomponentloader.loadComponentFromURL(s, "_blank", 0, apropertyvalue);
<         apropertyvalue[0] = new PropertyValue();
<         apropertyvalue[0].Name = "FilterName";
<         apropertyvalue[0].Value = s1;
<         apropertyvalue[1] = new PropertyValue();
<         apropertyvalue[1].Name = "Overwrite";
<         apropertyvalue[1].Value = new Boolean(true);
<         XStorable xstorable = (XStorable)UnoRuntime.queryInterface(com/sun/star/frame/XStorable, xcomponent);
<         xstorable.storeToURL(s2, apropertyvalue);
<         XCloseable xcloseable = (XCloseable)UnoRuntime.queryInterface(com/sun/star/util/XCloseable, xstorable);
<         if(xcloseable != null)
<         {
<             xcloseable.close(false);
<         } else
<         {
<             XComponent xcomponent1 = (XComponent)UnoRuntime.queryInterface(com/sun/star/lang/XComponent, xstorable);
<             xcomponent1.dispose();
<         }
<         System.exit(0);
<         break MISSING_BLOCK_LABEL_321;
<         Exception exception;
<         exception;
<         exception.printStackTrace();
<         System.exit(1);
<         System.exit(0);
<         break MISSING_BLOCK_LABEL_321;
<         Exception exception1;
<         exception1;
<         System.exit(0);
<         throw exception1;
---
>       localException.printStackTrace();
>       System.exit(1);
71,73c68
< 
<     private static String convertToURL(String s)
<         throws Exception
---
>     finally
75,78c70
<         File file = new File(s);
<         StringBuffer stringbuffer = new StringBuffer("file:///");
<         stringbuffer.append(file.getCanonicalPath().replace('\\', '/'));
<         return stringbuffer.toString();
---
>       System.exit(0);
80,99c72,97
< 
<     private static String getFilterName(String s)
<         throws Exception
<     {
<         String s1 = s.substring(s.length() - 4).toLowerCase();
<         String s2 = "";
<         if(s1.equals(".doc") || s1.equals(".dot") || s1.equals(".sxw") || s1.equals(".stw") || s1.equals(".odt") || s1.equals(".ott"))
<             s2 = "writer_pdf_Export";
<         else
<         if(s1.equals(".xls") || s1.equals(".xlt") || s1.equals(".sxc") || s1.equals(".stc") || s1.equals(".ods") || s1.equals(".ots"))
<             s2 = "calc_pdf_Export";
<         else
<         if(s1.equals(".ppt") || s1.equals(".pot") || s1.equals(".sxi") || s1.equals(".sti") || s1.equals(".odp") || s1.equals(".otp"))
<             s2 = "impress_pdf_Export";
<         else
<         if(s1.equals(".sxd") || s1.equals(".std") || s1.equals(".odg") || s1.equals(".otg"))
<             s2 = "draw_pdf_Export";
<         else
<             throw new Exception("There is no corresponding filter.");
<         return s2;
---
>   }
>   
>   private static String convertToURL(String paramString)
>     throws Exception
>   {
>     File localFile = new File(paramString);
>     StringBuffer localStringBuffer = new StringBuffer("file:///");
>     localStringBuffer.append(localFile.getCanonicalPath().replace('\\', '/'));
>     return localStringBuffer.toString();
>   }
>   
>   private static String getFilterName(String paramString)
>     throws Exception
>   {
>     String str1 = paramString.substring(paramString.length() - 4).toLowerCase();
>     String str2 = "";
>     if ((str1.equals(".doc")) || (str1.equals(".dot")) || (str1.equals(".sxw")) || (str1.equals(".stw")) || (str1.equals(".odt")) || (str1.equals(".ott"))) {
>       str2 = "writer_pdf_Export";
>     } else if ((str1.equals(".xls")) || (str1.equals(".xlt")) || (str1.equals(".sxc")) || (str1.equals(".stc")) || (str1.equals(".ods")) || (str1.equals(".ots"))) {
>       str2 = "calc_pdf_Export";
>     } else if ((str1.equals(".ppt")) || (str1.equals(".pot")) || (str1.equals(".sxi")) || (str1.equals(".sti")) || (str1.equals(".odp")) || (str1.equals(".otp"))) {
>       str2 = "impress_pdf_Export";
>     } else if ((str1.equals(".sxd")) || (str1.equals(".std")) || (str1.equals(".odg")) || (str1.equals(".otg"))) {
>       str2 = "draw_pdf_Export";
>     } else {
>       throw new Exception("There is no corresponding filter.");
100a99,100
>     return str2;
>   }

Recommended Posts

Decompile Java
JAVA decompile (decompile)
Java
Java
Java learning (0)
Studying Java ―― 3
[Java] array
Java protected
[Java] Annotation
[Java] Module
Java array
Studying Java ―― 9
Java scratch scratch
Java tips, tips
Java methods
Java method
java (constructor)
Java array
java (override)
java (method)
Java Day 2018
Java string
Java static
Java serialization
java beginner 4
JAVA paid
Studying Java ―― 4
Java (set)
[Java] compareTo
Studying Java -5
java reflexes
java (interface)
Java memorandum
☾ Java / Collection
Java array
[Java] Array
Studying Java # 0
Java review
java framework
Java features
[Java] Inheritance
FastScanner Java
Java features
java beginner 3
Java memo
Java inheritance
[Java] Overload
Java basics
[Java] Annotation
java notes
java beginner
Java (add2)
JAVA (Map)
[java] interface
Java9 collection
Java basics
How to decompile java class files
Java methods
Java diary
Java inheritance
[Java] enum